DevOps(Day-70): Ansible - Creating Inventory, Ansible Master-Node Configuration

 

  • Task-02: Creating Inventory

  • Task-03: Ansible Master-Node Configuration

  • Ansible Inventory - Ansible automates tasks on managed nodes or “hosts” in your infrastructure, using a list or group of lists known as inventory. You can pass host names at the command line, but most Ansible users create inventory files. Your inventory defines the managed nodes you automate, with groups so you can run automation tasks on multiple hosts at the same time. Once your inventory is defined, you use patterns to select the hosts or groups you want Ansible to run against.

    1. Create an inventory file in the below path and name the file as host.

      sudo nano /etc/ansible/hosts

    2. Before that, we need to create two Ansible node servers which will be connected to the Ansible master server.

    3. Assign the values in the file as shown in the below screenshot and save.

    4. Let's verify the inventory that we have created.

      ansible-inventory --list -y

  • Setup 2 more EC2 instances with the same Private keys as the previous instance (Node)

    We have created the two servers and set up the server to master the above task.

  • Copy the private key to the master server where Ansible is set up.

    1. Create a public key on the master server and copy the key using the ssh-keygen command.

    2. We can see id_rsa.pub which is the public key of the master server.

    3. Copy the above public key of the master to both the node server.

  • Try a ping command using Ansible to the Nodes.

    1. Now, use the ping command with the input of inventory file to it so that it will ping both the node servers.

    2. We can see both pings are successful which indicates servers are in active states.

Thanks for reading my article. Have a nice day

Comments

Popular posts from this blog

DevOps(Day-97): Meta-Arguments in Terraform

DevOps(Day-95): Auto Scaling with Terraform

DevOps (Day-1) Introduction