DevOps Classroom Series – 07/Mar/2020

How Ansible Works

Preview

  • User writes declarative stuff in playbooks
  • User creates inventory (list of nodes)
  • User executes playbook with the inventory
  • Now ansible converts the playbook into python objects
  • With the user credentials configured ansible log’s using (ssh/any other communication protocol) and executes the converted python code and displays the result to the user.

Ansible Terms

  • Playbook: Declarative specification for your application deployment using YAML.
  • Inventory: Node information.(List of nodes)
  • Ansible Control Server: The machine/system on which ansible is installed
  • Managed Node or Node: The machine/system which has python installed and which we want to control from Ansible.

Install Ansible

Installation

  • Create 2 t2.micro with ubuntu 18 image
  • Login into ansible control server
    • Windows 10 (with no updates) or Windows 7 : Install Git for windows from here
  • Install ansible from here
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
  • Login into node
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install python
  • We need to configure an admin user on the ansible control server and also nodes
  • Login into ansible control server and
    • Ensure password based authentication is enabled
    • Create a user called as admin
    • Give admin user sudo privileges
    • Now create a key for the user admin
  • Login into node
    • Ensure password based authentication is enabled
    • Create a user called as admin
    • Give admin user sudo privileges
    • Now create a key for the user admin
  • Login into ansible control server
    • Copy the public key to ansible node for seamless authentication

Preview

Leave a Reply

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

About learningthoughtsadmin