DevOps Classroom Series – 06/Oct/2021

How Ansible Works

  • Configuration Management server in the case of the Ansible is called as Ansible Control Node which can be any linux, unix or mac instance.
  • On all the NOdes Python should be installed
  • Ansible uses python to do configuration management on the nodes, As an ansible user we would not need to know python to do Configuration Management
  • Now lets consider that we would want to install apache on the web1, web2 and web3 nodes
    • Ansible should be configured
    • For doing deployment/installation we need to write a playbook which is a yaml.
    • Now we would ask ansible to execute playbook, Now Ansible will do the following
      • Generate a Python script that installs the apache
      • Copy the script to web1, web2 and web3
      • Execute the script on web1, web2 and web3
      • Wait for the script to complete and show the results
    • For copying and executing the python script created from playbook, Ansible needs to know the server details and credentials, we create a file called as inventory with server details where configuration management has to be executed.

Whats so great about Ansible

  • Simple: Ansible was designed to have a simple setup process & minimum learning curve
  • Easy to Read Syntax
  • Easy to Audit
  • Nothing to Install on Remote Hosts
  • Easy to Share
  • Powerful
    • Batteries
    • Paralled Execution
    • Master less

What Do i Need to Know to work with Ansible

  • The following are the topics which we need to know about linux systems
    • Connect to a remote machine using SSH
    • Interact with command line shell
    • Install packages
    • Using the sudo command
    • Check and set file permissions
    • Start and stop Services
    • Set Environment variables

Ansible Lab Environment

  • We would create two ec2 instances in AWS with ubuntu 20.04
  • Note:
  • Now lets try to install ansible on one node which would be ansible control node
    • Log in to the ansible control node
    • Install on ubuntu Refer Here
    sudo apt update
    sudo apt install software-properties-common
    sudo add-apt-repository --yes --update ppa:ansible/ansible
    sudo apt install ansible -y
    
    • Now lets try to install python on the node 1. Python is already installed
    • In AWS instances, the password is disabled by default. So lets enable password based authentication on both ansible control node and node1
      • In the /etc/ssh/sshd_config lets set the value of PasswordAuthentication to yes
    • Then we would create an ansible user which simulates it admin on both the machines.
      • Log in to nodes and execute
    sudo adduser ansible
    
    • Now we need to give ansible user sudo privileges without prompting for password.
    sudo visudo
    
    • So now we have a sudo user ansible, so we need to configure in Ansible control node so that when ansible connects to node1, it connects as ansible user

Leave a ReplyCancel reply

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

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%