The Ansible Learning Path
By Sudheer S
Ansible Prerequisites
Before jumping on to learning Ansible, have a firm grounding in Linux system administration and shell scripting. You can use Ansible for a lot of automation projects. The primary target audience for this blog post are DevOps engineers, IT infrastructure engineers and system administrators who create and manage IT infrastructure to run workloads. A good understanding of YAML is required before starting to write Ansible playbooks. A background in at least one programming language helps. Python programing is not a requirement per se. But Python programming familiarity helps put together some automated testing.
##Stage 1: Explore Ansible
Learn elementary Ansible concepts such as inventory, playbooks, variables, tasks, become, etc. Explore some common modules such as copy
, template
, file
. Write a playbook.
List of Ansible modules for day-to-day automation operations
- copy
- template
- file
- user
- apt, apt-key, apt-repository
- yum
- service, systemd
- uri, get_url
- debug
- git
##Stage 2: Write More Playbooks And Use Third Party Roles
Write more playbooks. Learn about handlers, include statements, vault, lookups, conditionals, loops, filters etc.
As you keep writing more and more playbooks, you will notice that, it becomes hard to manage large, monolith playbooks
that perform a lot of tasks. It helps to split the tasks into logical categories and use the include
statement.
There is a better way of organizing your tasks, handlers, variables, etc. Enter Ansible Roles. Ansible Galaxy offers
ready-made open source roles for various automation undertakings. Use Roles and Collections from the Ansible Galaxy.
##Stage 3: Write Your Own Ansible Role
There comes a time, when roles and collections from Ansible Galaxy won’t cut it. You will have to write your own
Ansible role. You can host roles and collections in a Git repository and still consume them from ansible-galaxy
command line utility.
##Stage 4. Test Your Ansible Roles
Write tests for your Ansible roles using molecule
.
##Stage 5: Use Continuous Integration For Your Ansible Role When a pull request is created for your role, run the test suite against the pull request.
##Stage 6. Contribute To Ansible Galaxy List your open source roles and collections in Ansible Galaxy.
##Stage 7: Contribute To Open Source Ansible Projects There are a lot of open source Ansible Roles And Collections. Contribute to them.
##Stage 8: Contribute To Ansible Project And its various sub-projects.
##Stage 9: Share Your Learning Blog and create videos about your Ansible journey. Join the Ansible community. Attend Ansible local and virtual events.
##Stage 10: Fix The Knowledge Gaps The blog post does not cover every aspect of learning Ansible. If you have moved with a fast pace in the previous stages, chances are that you have created some gaps in the ideal knowledge path. Research what areas of Ansible you have left out. Practice them. For example, we didn’t talk about writing Ansible modules. Find them, fix them.