DevOps Classroom Series – 23/Dec/2020

Inventories

  • In Ansible inventories are list of nodes
  • Inventories can be static or dynamic
  • Inventories can be written in two formats in static
    • INI
    • YAML
  • Inventory orderding: A new play level keyword called as order is added which supports the following values
    • inventory: This is default. It simply means Ansible will execute the order in the way they are written in inventory
    • reverse_inventory
    • sorted: hosts are alphabetically sorted
    • reverse_sorted: hosts are reverse alphabetically sorted
    • shuffle

INI

  • In Inventories entries can be grouped together
[group1]
10.100.100.101
10.200.10.101

[group2]
192.168.10.11
192.168.11.11

[group3]
10.200.10.101
192.168.11.11

[group4:children]
group1
group2
  • In any inventory ansible will have two default groups
    • all: This is list of the nodes (unique)
    • ungrouped: This is list of the nodes which donot belong to any group.

Ansible Inventory Scenarios

  • Scenario-1:

    • Install utility Softwares like git, tree and nano on all machines
      • manual steps:
        • ubuntu sudo apt install git tree nano -y
        • rhel sudo yum install git tree nano -y
      • In ansible we have a generic package module Refer Here.
      • Refer Here for the changes
    • Install apache on centos
      • manual steps:
      sudo yum install httpd
      sudo systemctl enable httpd
      sudo systemctl start httpd
      
    • Install java on ubuntu
  • As of now we have two nodes

    • node-1: ubuntu
    • node-2: centos
  • Scenario 2: Install Lamp stack on webservers. In web servers we have ubuntu and centos nodes. Try Creating one playbook for this.

    • ubuntu: manual steps
      • sudo apt update
      • sudo apt install apache2 -y
      • sudo apt install php libapache2-mod-php php-mysql php-cli -y
      • echo "<?php phpinfo(); ?>" > /var/www/html/info.php
    • centos: manual steps
      • sudo yum install httpd -y
      • sudo systemctl enable httpd.service
      • sudo systemctl start httpd.service
      • sudo yum install php php-mysql php-fpm -y
      • echo "<?php phpinfo(); ?>" > /var/www/html/info.php

Leave a Reply

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

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube