Professional Documents
Culture Documents
How To Be An Ansible Controbutor AnsibleFest 2019 Johnamcdonough
How To Be An Ansible Controbutor AnsibleFest 2019 Johnamcdonough
Step-by-Step
John McDonough
Cisco DevNet – Developer Advocate
My automation story
https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html
Read Some Docs
Someone wrote these Docs for you! Don't make them Ugly Cry!
https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html
Fork Ansible on Github
Fork Ansible (docs say clone – I say fork)
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_general.html#common-environment-setup
Read Some Docs … again
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_general.html#common-environment-setup
Create an Ansible Module
Create an Ansible Module
• Be concise – "Do One Thing Well"
• A user does not need to know all the options
• Encompass much of the logic for a resource
• Think CRUD (Create / Read / Update / Delete)
– Or DRUC, CURD, URCD, DURC, RUCD, etc.
– Whatever seems to work best!
Create an Ansible Module
• 'cd' to the desired directory or create a new directory
• Create a new file
• Use the "New module development" Template
• Test the Module
– Locally – JSON formatted ANSIBLE_MODULE_ARGS file
– Playbook – YAML formatted playbook
• Run Sanity Tests
• Create/Run Unit Tests
Read Some Docs … again
https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#starting-a-new-module
Read Some Docs … again and again
https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#contributing-back-to-ansible
Read Some Docs … again and again
https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#contributing-back-to-ansible
Submit a Pull Request
Create an Ansible Module – Revised
• Create feature branch
• 'cd' to the desired directory or create a new directory
• Create a new file
• Use the "New module development" Template
• Test the Module
– Locally
– Playbook
• Run Sanity Tests
• Create Unit Tests
• Commit and Push YOUR Code to YOUR feature branch
• Create Pull Request
Submit a Pull Request
https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/index.html
Submit a Pull Request
Submit a Pull Request
Submit a Pull Request – After the Click
• Automated testing happens
https://help.github.com/articles/syncing-a-fork/
Delete Your Branch
• git branch -d branch1 <--- locally
• git push origin :branch1 <--- remote
• Ansible Links:
– Ansible on Github - https://github.com/ansible/ansible
– Ansible module development: getting started -
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_general.html
– Testing Ansible - https://docs.ansible.com/ansible/devel/dev_guide/testing.html
• Learning
– DevNet Learning Labs an introduction - https://developer.cisco.com/learning/modules/sdx-ansible-intro
– DevNet Learning Labs a bunch of labs - https://developer.cisco.com/learning/modules?keywords=ansible
Got Questions? This is where I'm at!
jomcdono@cisco.com
@johnamcdonough
http://github.com/movinalot
@CiscoDevNet
facebook.com/ciscodevnet
http://github.com/CiscoDevNet
https://developer.cisco.com/join/ansiblefest20