Ansible is an open-source automation tool, which commonly used for IT tasks such as installation and configuration of any software on multiple nodes and also
Check the following git hub link to automate the installation of ansible On Centos 8 using script. Download the git repo and run the install-ansible.sh script on the instance where you want to install the ansible.
Git Hub Repo:https://github.com/smarttechfunda/install-ansible.git
The command to Download git repo: $ git clone -b release/1.0.1 https://github.com/smarttechfunda/install-ansible.git
$ cd install-ansible$ chmod +x install-ansible
$ ./install-ansible
OR use the following step to install and configure ansible manually.
Note:
Log in as a non-root user, but the user should have
Step 1:
Install Python3$ sudo yum install python3
$ python -V
Step 2:
Install python3-pip$ sudo yum install python3-pip
Step 3:
Install ansible
On Ubuntu 18.20, 20.08:$ sudo apt install ansible -y
On CentOS 8:$ sudo yum install -y epel-release && sudo yum install -y ansible
/etc/ansible/hosts:
This is an inventory file for the nodes. You can add the number of nodes in this file.
Make the following entry at bottom of the "/etc/ansible/hosts"
file.
For example:[test]
192.168.0.104
Note: Skip step 5 and follow from step 6 directly.
OR$ pip3 install ansible --user
Note: Do not skip any step after the above pip3 install command.
Step 4:
Test Ansible on the
Check the ssh service is running.
$
Step 5:
Create the Ansible directory structur
Create the ansible directory under /etc/ path and create the hosts file under the /etc/ansible path on ansible instance.$ sudo mkdir /etc/ansible
This is an inventory file for the nodes. You can add the number of nodes in this file.
$ sudo touch /etc/ansible/hosts
/etc/ansible/hosts:
Make the following entry to the "/etc/ansible/hosts"
file.
For example:[test]
192.168.0.104
Step 6:
Passwordless SSH
Create the SSH key
Create the SSH keys and copy the public key on the remote node.
$ ssh-keygen
Step 6:
Copy ssh public key on the remote node
Run the following command to copy the ssh key on the remote node.$ ssh-copy-id ansible@<remote_host_ip>
For example:$ ssh-copy-id ansible@192.168.0.104
Step 7:
Test Ansible
Run the following command to test the ansible on the remote node.$ ansible -i /etc/ansible/hosts test -m ping
Convert the shell script to binary file automation:
Git hub repo:https://github.com/smarttechfunda/shell-to-binary.git
The command to Download git repo:git clone https://github.com/smarttechfunda/shell-to-binary.git
No comments! Be the first commenter?