DevOps- Ansible

Configuration management tools:
configuration management→ Process of maintaining the servers, according to the requirements.
→ If we have hundreds of servers, and it is not possible to do configurations manually, then this configurations management tools comes to resolve the issue, we can configure the server, software by using this configuration management tools.
→ Few configuration management tools are ansible, puppet, chef, saltstack
Ansible:
→ Ansible is a open-source configuration management tool and Deployment tool maintained by RedHat.
→ Ansible is written in python.
→ The main components of ansible are playbook, configuration management, deployment.
→ Ansible uses playbook to deploy, manage, build, test and configure anything from full server environment to custom compiled source code for applications.
→ Configurations can be anything which we can perform on servers(hosts),
it can be,
→ Install/update/uninstall the software(packages).
→ Copy files and changing the permissions on the files or directories.
→ start/stop/restart the services.
→ Ansible playbook→ it contains what kind of tasks that we want to perform and that configurations are in the playbook.
Ansible Features/Advantages:
→ Ansible configure machines in an agent- less manner using SSH.'
→ Built on top of python, and hence provides a lot of python functionality.
→ YAML based playbook.
→ uses SSH for secure connections.
→ Follows push based architecture for sending configurations.
Push based Vs Pull Based:
→ Tools like puppet and chef are pull based
Agents on the server periodically checks for the configuration information from central server(master).
→ Ansible is push based
central server pushes the configuration information on target servers, you can control when the changes are made on the server.
→ Push based Architecture
→ Pull based Architecture
Ansible Architecture:
Ansible playbook→ it contains what kind of tasks that we want to perform and that configurations are in the playbook.
Inventory file→ Ansible inventory hosts file is used to list and group your servers. It’s default location is /etc/ansible/hosts.
Demo of Playbook:
→ Control Node :
A system on which Ansible is installed, you run Ansible commands such as ‘ansible’ or ‘ansible-inventory’ on a control node.
Inventory- A list of managed nodes that are logically organized. You can create an inventory on the control node to describe host deployments to Ansible.
Managed Nodes- A remote system or host that Ansible controls.
→User(system admin/devops) create a playbook. In that playbook we are going to define a task which we want to perform on that managed nodes.
→ In that playbook we will specify which modules to be used by ansible to perform the task.
→ Ansible connects to the managed nodes using connection methods(SSH, WINRM).
→ Ansible push the necessary configurations or tasks by executing on that node.
Ansible Installation:
→ Ansible is available in 2 distributions(from v2.0 onwards)
→ Ansible Core
→ Ansible
Ansible Core -
→ The actual engine that runs ad-hoc commands and playbooks
It includes:
Minimal package
Small set of core modules
No bundled community plugins/modules, they must be installed separately via ansibe galary.
Ansible -
It is built on-top of ansible-core, includes many community modules/plugins.
Differences between ansible core and ansible community:
→ Ansible installation:
→ We cannot install ansible in windows OS, but we can configure ansible in windows using ansibel.
→ Create a server and ssh the server using git blash/mobxsterm
→ python3 --version
To check python is installed or not, most of the Linux versions, it is defaultly installed.
→ Then install the linux by using the shell script, create a sh file named ‘Ansibleinstall.sh’ and insert the ansible installation script in that file.
→ then give execute access to the file before running it
chmod +x Ansibleinstall.sh
→ Now, run the file
./Ansibleinstall.sh
→ Now check for the Ansible version
ansible --version
→ Now create another server for configuring the servers
→ ssh the server and check the python is installed or not
→ create a host file which contains all the ip address we have to maintain
→ create a pem file in the ansible server and copy the pem file content that is in your desktop to the pem file in the server. and configure that file in the host fle
→ Now execute the ansible
ansible all -m ping
→ before executing give the permissions to the pem file and then execute
Subscribe to my newsletter
Read articles from Sandhya Kalikiri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
