DevOps Classroomnotes 06/Aug/2022

Ansible Contd

Configuring Password Less Authentication

  • We create a public/private key pair in the Ansible control node, Then we copy the public key to the nodes which ansible will connect
  • Create a keypair in the ansible control node as a devops user.
  • Now lets copy the ssh public key generated from ansible control node to node1
  • Now lets copy the ssh public key generated from ansible control node to node2
  • Now install ansible on the control node use the node 1 and node 2 ip address in some inventory file and use the ansible ping
  • Ansible passwordless authentication overview

Inventory files

  • Ansible has a default inventory file created when the ansible is installed
  • When ansible is installed in /etc/ansible/ansible.cfg a default configuration for ansible is created
  • Refer Here for the Sample config file
  • Inventory file in ansible can be written in two formats
    • ini
    • yaml
  • INI Format sample
  • The above inventories are called as static inventories, there are ways to create dynamic inventories as well.
  • Inventory file can have groups. An entry can be duplicate in many groups.
  • The ideal way of dealing with inventory files is to create a inventory file with the name of the environment and ensure the groups names are consistent across different inventories
    • systemtest_hosts
    • performancetests_hosts
    • pre_prod_hosts
    • prod_hosts
  • Lets create a hosts file for devenv, qaenv
  • Create an ansible playbook to install utilites
sudo apt update
sudo apt install nano git tree -y

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner