These are chat archives for gitterHQ/ansible

20th
Feb 2016
Joel Baranick
@kadaan
Feb 20 2016 18:15

I’m trying to create a ansible module in python that will collect facts from Qubole. I’ve created the module like:

def main():
    module = AnsibleModule(
        argument_spec=dict(
            api_token=dict(required=True, type='str'),
            cluster_label_id=dict(required=True, type='str')
        ),
        supports_check_mode=True)
    …
        if content['state'] == 'UP':
        module.exit_json(changed=False, qubole_master_hostname=[x['hostname'] for x in content['nodes'] if x['role'] == 'master'][0])
    else:
        module.fail_json(msg="cluster {} was not found".format(cluster_label_id))

from ansible.module_utils.basic import *

if __name__ == '__main__':
    main()

When I run it under the test-module it works correctly.

ansible/hacking/test-module -m qubole_facts.py -a "cluster_label_id=1 api_token=2"

However, when I include it in my ansible project:

- name: get qubole facts
  qubole_facts: api_token="{{ qubole_api_token }}" cluster_label_id=“{{ qubole_cluster_name }}"
  become: true
  tags:
    - configure

I get the following error:

TASK: [qubole_facts ] ********************************************************* 
failed: [server] => {"failed": true}
msg: missing required arguments: cluster_label_id,api_token

FATAL: all hosts have already failed -- aborting

Any idea what I am doing wrong?