What are your favorite Ansible modules or playbooks for automating common tasks in your environment?
Share your tips and tricks for writing efficient and reusable Ansible code.
1) For me there is no favourite module, everything depends on the task. I think most extensively used module would be "ansible.builtin.debug" we can find it in almost all plabooks. Few of the heavyweight modules/collections that I worked on and find them quite efficient are the modules to create vms like : "ovirt_vm", "vmware_guest" etc.
2) For writing efficient and reusable ansible code we should use roles (https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html). If someone needs to use "include_role" in the playbook then it is better to use "import_role" during the development of the playbook as it helps to include the features like "tags,skip-tags,start-at-task" easily.
Hello @masharma you are absolutely right about "debug" module and also what a really nice & useful second point!
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.