In this story, I am going to illustrate “Configuration management using Ansible Dynamic Inventory” in AWS EC2 instances.
What is Ansible Dynamic Inventory and what is the need for dynamic inventory?
There are two types of Inventories in Ansible.
1. Static Inventory
2. Dynamic Inventory
Static Inventory: In this inventory file where you define hostname, host ip’s, host variables of the slave's machines for the configuration management.
In real-time, there will be hundreds of machines where you need to do configuration management. So you cannot write those hostnames and host ip’s manually in the static inventory file. …
1. Launch an Amazon EC2 Linux instance.
2. Open the default port 8080 in the inbound rules of your instance security group.
Step 1: Create a jenkins-installation script file and give executable permissions to the file.
$ sudo vi jenkins-installation.sh
$ sudo chmod u+x jenkins-installation.sh
Step 2: Add the below commands in the script file.
#!/bin/bash# Step 1
echo "Installing the Oracle Java JDK as a prerequisite for jenkins set-up"sudo wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpmsudo rpm -ivh jdk-8u131-linux-x64.rpm# Step 2
echo "Downloading Jenkins Repo"
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo# Step 3
echo "Importing repo key"