Ansible: Register – store and display output of a command
At times we may want to run certain command in the managed nodes, and would like to see the output to verify if the command ran correctly. The module commonly used to run commands on…
At times we may want to run certain command in the managed nodes, and would like to see the output to verify if the command ran correctly. The module commonly used to run commands on…
While ansible runs playbook on group of managed nodes which are also present in the Inventory file, we can run tasks on selected nodes based on defined conditions. For example we may want to install…
Roles is a feature provided by Ansible were once a standardized directory structure is created, you can automatically load related vars, files, tasks, handlers, and other Ansible artifacts. Using roles we have opportunities to reuse code from playbooks that…
The include_tasks module imports a list of tasks to the current playbook for execution. It is one way for organizing tasks in separate files and it also helps in reusing the tasks in other playbooks….
While the copy module helps to copy a file from the controller node to managed nodes, the fetch module helps to retrieve files from a managed node to controller node. In the below example we will…
Usually the Handlers work with a single task. However the “blocks” feature in Ansible helps us to group multiple tasks under one block section and attach handlers or rescue feature to it. In the below…
Do not misunderstand the concept error handling in this document with error handling in usual software programming terminology. Usually when one writes a program, a syntax check will check for syntax including indentation, spacing, etc. But…
At times when certain tasks are executed by a playbook, it may be desired to run certain other task immediately. However, if the first task did not get executed successfully for what ever reason, we may…
At times one may want to run certain tasks or command only if certain conditions are met. For example add a user called “RedhatUser01” only if the managed node is a Redhat node. Similarly add…
At times you may want to execute a single tasks with multiple variable values one after the other. For example create 3 user accounts using one task. One way is to write three tasks in the…