These are chat archives for gitterHQ/ansible

Feb 2016
Joel Baranick
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(
            api_token=dict(required=True, type='str'),
            cluster_label_id=dict(required=True, type='str')
        if content['state'] == 'UP':
        module.exit_json(changed=False, qubole_master_hostname=[x['hostname'] for x in content['nodes'] if x['role'] == 'master'][0])
        module.fail_json(msg="cluster {} was not found".format(cluster_label_id))

from ansible.module_utils.basic import *

if __name__ == '__main__':

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

ansible/hacking/test-module -m -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
    - 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?