What are Ansible facts? Ansible facts are pieces of information regarding the remote systems to which you have connected. It contains information like IP addresses, the OS installed, Ethernet devices, mac address, time/date related data, hardware information etc. These are very useful for scenarios where you need to take conditional operations based on […]
Long
How to Create a Directory in Ansible
You will need to create directories or folders in Ansible many times during may of the DevOps process. Although you could do create directories using shell or command module, ansible provides a better and safer method for creating directories using the ‘file’ module. Ansible Directory Creation example To create a directory using the file module, […]
Working with Ansible User Module
Ansible user module helps us to manage user accounts in Linux systems including creating user accounts, deleting them, setting passwords, adding groups to each user, etc. How to create users in Ansible Let us first see how to write a basic task for creating a Linux user using the Ansible user module. There is only […]
The Basics of Ansible Variables
Variables are used to store values in programs and as the name suggests the values can be changed throughout the program. These values are essential to deciding the code flow. Ansible variables help to determine how the tasks execute on different systems based on the values assigned to these variables. Ansible variable names should be letters, […]
Using the Ansible find module to search for files/folder
Ansible find module is used when you need to retrieve a list of files in the remote server which matches some conditions like name, size, etc. You will have to provide the path(s) to the remote server where the search should be done. It also supports searching for directories and links. The module returns the list of […]
How to delete multiple files / directories in Ansible
There are multiple methods in Ansible by which you can delete a particular file or directory, delete all files in a directory, delete files using regex etc. The safe way is to use the Ansible file module. You can also use the shell module to achieve the task. But it is not idempotent and hence […]
How to Work with Ansible Template Module with Examples
Managing configurations of multiple servers and environments are one of the significant uses of Ansible. But these configuration files may vary for each remote servers or each cluster. But apart from some few parameters, all other settings will be same. Creating static files for each of these configurations is not an efficient solution. And It will […]
Using Ansible blockinfile Module
Ansible blockinfile module is used to insert/update/remove a block of lines. The block will be surrounded by a marker, like begin and end, to make the task idempotent. If you want to modify/ insert only a line, use lineinfile module. You can find the documentation in You can find more details of blockinfile module in Ansible documentation. […]
How to Copy Files and Directories in Ansible Using Copy and Fetch Modules
Ansible provides the basic functionality of copying files and directories through the copy and fetch modules. You can use the copy module to copy files and folders from the local server to the remote servers, between remote servers(only files), change the permission of the files, etc. You can use the fetch module to copy files […]
Introduction to Shell and Command Modules in Ansible
The Ansible shell and command modules are used for executing commands in remote servers. Both modules take the command name followed by a list of arguments. Ansible Shell Module and Command Module We can use the shell module when we need to execute a command in remote servers, in the shell of our choice. By […]