1
votes

I am editing the variables names here for easier understanding. My issue is about an Ansible playbook which uses an Ansible custom module. Executing the playbook brings the following error:

TASK [ansiblecustommodulename.service_scale] ******************************************************************************************************************************************************
fatal: [myenv.mydomain]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (ansiblecustommodulename) module: param3 Supported parameters include: param1, param2"}

The playbook includes the following (skipping first playbook part for brevity)

   - name: ansiblecustommodulename.service_scale
     ansiblecustommodulename:
       action: service.scale
       param1: "{{ otherapp_param1 }}"
       param2: "{{ otherapp_param2 }}"
       param3: "{{ otherapp_param3 }}"

In the custom_module.py file, AnsibleModule has been used:

def main():
    """
    Manage mydomain services.
    """

    module = AnsibleModule(
        argument_spec={
            'param1': {'required': None},
            'param2': {'default': None},
            'param3': {'default': None},
            'action': {'required': True, 'choices': [
                'service.scale',
            ]}
        }

I inserted the debugger option at the end of the playbook. Launching p task_vars shows me the variable param3 has been correctly initialized:

          'param1': 'ec2',
          'param2': 'default',
          'param3': '3',
 'param1': 'ec2',
 'param2': 'default',
 'param3': '3',

But I still getting the "Unsupported .." error. Any ideas on this?

1

1 Answers

2
votes

Resolved by removing a backup version .py in the /library folder. It turned out that Ansible actually loads all the .py files in the library folder (if you have local module). This leaded into reading the wrong .py module and not considering the newest changes which fixed the bug.

We can consider this closed.