ARTH TASK 10

 

Ansible

Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows.

Docker

Docker is a software platform for building applications based on containers — small and lightweight execution environments that make shared use of the operating system kernel but otherwise run in isolation from one another. Containers, by contrast, isolate applications’ execution environments from one another, but share the underlying OS kernel. They’re typically measured in megabytes, use far fewer resources than VMs, and start up almost immediately.

Objectives:

To write an Ansible PlayBook that does the following operations in the managed nodes:

  1. Configure Docker
  2. Start and enable Docker services
  3. Pull the httpd server image from the Docker Hub
  4. Run the docker container and expose it to the public
  5. Copy the html code in the document root directory
  6. Then start the web server

Let's start the practical....

Step 1: Create ansible.cfg file that is the ansible configuration file as shown below. Here we are using ec2-instance as our managed node.

No alt text provided for this image

Step 2: Setup your ansible inventory file.

No alt text provided for this image

Step 3: Create ansible playbook with the following tasks.

  1. Create yum repo for docker.
  2. Install docker
  3. Start and enable docker services
  4. Install python and docker-py to support ansible docker modules.
  5. Pull httpd image using docker modules.
  6. Run the httpd container and start service
  7. Create an handler to copy the html code to the docker container.
No alt text provided for this image

Here we have used command module of ansible to install docker because we are using RHEL8 as our managed node in which we need to pass an option called --nobest that will forcefully install docker, and such option is not available in package module.

No alt text provided for this image
No alt text provided for this image

STEP 4: Execute the playbook using ansible-playbook command.

No alt text provided for this image
No alt text provided for this image

Comments

Popular posts from this blog

ARTH TASK 23 [📌 Automate Kubernetes Cluster Using Ansible 🔅 Launch ec2-instances on AWS Cloud eg. for master and slave. 🔅 Create roles that will configure master node and slave node seperately. 🔅 Launch a wordpress and mysql database connected to it in the respectine slaves. 🔅 Expose the wordpress pod and client able hit the wordpress ip with its respective port. ]

Arth Task6 "Create High Availability Architecture with AWS CLI" #awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #awsbylw #arthbylw

RH294 real used cases workshop #RedHat #vimaldaga #righteducation #educationredefine #rightmentor #linuxworld #makingindiafutureready #righeducation #arthbylw #ansiblebylw #ansible #expertsession #sreejith #arun #practicalimplementation #rh294