When writing new modules, the ansible documentation is quite vague. Here more information about it.

The official documentation link,


Give you only the definition of the module class:
class ansible.module_utils.basic.AnsibleModule(argument_spec, bypass_checks=False, no_log=False, check_invalid_arguments=None, mutually_exclusive=None, required_together=None, required_one_of=None, add_file_common_args=False, supports_check_mode=False, required_if=None, required_by=None)

Here a useful blog that explains some of the options:


And some extra notes about required_if:
Make sure you are consistent with the lists required. If you write:

required_if=[['show_uplink', 'True', 'vlanid']]

Ansible will give you:

TASK [Test] *
fatal: [host]: FAILED! => {“ansible_facts”: {“discovered_interpreter_python”: “/usr/bin/python”}, “changed”: false, “msg”: “show_uplink is True but all of the following are missing: v, l, a, n, i, d“}

You get the point.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s