Building upon the last module, let's utilize the common module boilerplate from Ansible that's stated in the module development documentation (http://docs.ansible.com/ansible/dev_guide/developing_modules_general.html). We will modify the last custom module and create custom_module_2.py to ingest inputs from the playbook.
First, we will import the boilerplate code from ansible.module_utils.basic:
from ansible.module_utils.basic import AnsibleModule if __name__ == '__main__': main()
From there, we can define the main function where we will house our code. AnsibleModule, which we have already imported, provides lots of common code for handling returns and parsing arguments. In the following example, we will parse three ...