Skip to main content

Command Palette

Search for a command to run...

Day 57 : Understanding Configuration Management with Ansible

Updated
2 min read
  • Task-01: Installing Ansible on AWS EC2 (Master Node)

    1. Create an EC2 instance (Master)

    To install Ansible, follow these steps:

    • SSH into your EC2 instance.

    • Run the following commands one by one:

    sudo apt-add-repository ppa:ansible/ansible 
    sudo apt update 
    sudo apt install ansible

  1. Checking the Hosts file

    To verify the contents of the Hosts file, use the following command:

    cat /etc/ansible/hosts

  1. Checking the inventory

Task-02: Setting up additional EC2 instances (Nodes)

To set up additional EC2 instances, follow these steps:

Launch two more EC2 instances similar to the previous one.

Select master instance , Go to action then image and templates and then click on Launch more like this.

Choose same private keys and launch 2 instances

  1. Copy the private key of the new instances to the master server where Ansible is set up.

Go to the .ssh folder and create an ansible_key file. Paste the private key that you used to create the instances.

Create an inventory file using the vim command or any other text editor.

Enter the public IP addresses of both instances (servers) in the inventory file.

To verify the inventory, use the following command:

ansible-inventory -i inventory --list

  1. Try a ping command using Ansible to the nodes. Run the following command:

To ping run following command.

Make sure to change the permissions of your private key. The output should display a successful ping to the nodes.

and your output will be like following.

That was all for today. See you another day with another challenge.

More from this blog

Ajay Patel

116 posts