Automated configuration management using RedHat Ansible
Tags: redhat, ansible, devops, automation
Published: 2021-03-20 18:46:35

<h3>About RedHat:</h3>

<b>Red Hat</b>, Inc. is an American multinational software company that is the world's leading provider of enterprise open source solutions.
<br />
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgk78hn32h9ptipy4lmq.png)
<br />

<h3>About Ansible:</h3>
<b>Ansible</b> is an open source configuration management, and application-deployment tool that ends repetitive tasks and frees up DevOps teams for more strategic work.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ezv6q5850l2d6t4jxf7n.png)
<br />
<h3>   Installing Ansible</h3>
<ul>
<h4>‣ Ansible is agentless</h4>
<p>So, we need to install ansible only on the Controller Node.</p>
<h5>Ways to install Ansible</h5>
<li>pip3 install ansible</li>
<p>[ Python3 installed on Control Node ]</p>
<li>yum installed ansible</li>
<p>[ Pre configured yum with additional epel repo ]</p>
<br />
<h3>Ansible Architecture</h3>
<ul>
<li><b>Controller Node~</b></li>
<p>Controller Node also referred to as Master Node as the name suggests is the epitome of the Ansible architecture and this is where we run the tasks and playbooks.</p>
<li><b>Managed Node~</b></li>
<p>Managed Nodes are the worker nodes that needs to be configured.</p>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlybcnu6ow823jkmr3i5.png)
<br />
<h3>How does Ansible work:</h3>
<ul>
<li><b>Ansible Inventory~</b></li>
<p>- The inventory consists of the hosts that we want to configure.</p>
<li><b>Host User Authentication~</b></li>
<p>- We need to authenticate the user either with ssh-key or using the help of password authentication.</p>
<li><b>Ansible Configuration~</b></li>
<p>- The ansible.cfg file consists of the location of the inventory, and other necessary ansible parameters</p>
<a href="https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg" target="_blank">Sample GitHub ansible.cfg template</a>
<br />
<h5>Once we have a stable connectivity with the hosts we can proceed with the configurations</h5>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zyil0dxaod5oa2pt4qb2.png)
<br />
<h3>How do we automate the host configuration using ansible?</h3> 
<br />
<ul>
<li><b>Ad-Hoc Commands~</li>
<p>Ansible Ad-Hoc Commands uses the /usr/bin/ansible command line tool to automate a <b>single</b>task on the Managed hosts.
<b>ansible hostgroup/ip -m module</b>
<h5>What are Modules?</h5>
<p>Ansible Modules are standalone scripts that can be used by the Ansible API or Playbooks Programs</p>
<a href="https://docs.ansible.com/ansible/2.8/modules/list_of_all_modules.html"> List of all the ansible modules</a>
</p>
<br />
<li><b>Ansible Playbooks~</li>
<p>Ansible Playbooks are blueprints of automation tasks, which record and execute Ansible's configuration, deployment and orchestartion function.</p>
<br />
<br />
<h3>What are Ansible Roles?</h3>
<p>Ansible Roles lets us automatically load variables, tasks, handlers and other Ansible artifacts based on a known file structure.
<b>Roles Hierarchy</b>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jayufc7s2imo3qp97ikd.png)
<br />
<h3>Integrations Using Ansible</h3>
<b>Splunk</b>
<p>Many of today's top organizations are using Splunk & Ansible.</p>
<p>Splunk and ansible are complimentary to each other.</p>
<p>Using Ansible Tower built in logging integrations we can pass our ops data describing our infrastructure from Ansible Tower to Splunk.</p>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkmijmql34hlimq4mzkl.png)
Other integrations include <b>Microsoft Azure, AWS, GCP</b> ....
source: Redhat(https://www.redhat.com/en), Ansible(https://www.ansible.com/)
Thanks for reading ⚡⚡