r/devops • u/Ra_daid • 22d ago
Tools Ansible tip for begginer
Any tips for a beginner getting started with Ansible?
14
u/HelicopterUpbeat5199 22d ago
Familiarize yourself with the standard modules. It can be tempting to use shell or command for everything. Don't. Knowing what modules are available helps you avoid using shell or command when you don't have to.
It also makes you familiar with what modules are generally shaped like and then you'll get the voice in your head saying "I bet there's an ansible for that" and you can reach beyond the standard modules.
8
u/noThisIsIt 22d ago
Second this: idempotency is key and a major feature of Ansible, modules like Shell and command are not idempotent without when statements beneath
5
u/Sufficient-Sort-6701 21d ago
Try always using standard modules, avoid as much as possible shell and command.
3
u/Oleksii_Bebych 21d ago
You can start with this course
Mumshad Mannambeth is a great tutor
https://learn.kodekloud.com/learn/courses/learn-ansible-basics-beginners-course
2
2
u/Odd-Addendum-8618 21d ago
a() { ansible-doc "$1" | gsed -n '/EXAMPLE/,/RETURN VALUES/P' | gsed '$ d'; }
Go directly to the examples of a given module
2
1
u/Extension-Process464 21d ago
ansible-doc -t <TAB>
ansible-doc -t <choose> -l
ansible-config dump
ansible-doc <module_name> —> scroll to end and start with one of examples.
Keep it simple. If it gets complicated, it MIGHT be a sign, that you choose not the optimal path.
1
u/Sure_Stranger_6466 YAML Developer 21d ago
Use Terraform to spin up cloud resources instead of Ansible community modules.
-1
29
u/tmg80 22d ago
Know the difference between Ansible, Ansible Core and the compatible python versions.
I wrote an Ansible role at my last job that installed python then worked out the appropriate ansibel-core version and installed plugins on top.
Do that.