Skip to main content

Collect ansible Inventory from directories

Hello

Thanks for visiting RvKmR.blogspot.in

In this blog post, I am explaining about ansible inventory.

While working with ansible we need to provide inventory to ansible commands.

We may have ansible inventory structure as like below. There can be some tasks that you wish to perform on all of the inventory. But it is difficult to collect or merge these into one file.

Lets do it ...

level1/
├── level2-0
│   └── inventory
│       ├── server01
│       ├── server02
│       ├── server03
│       ├── server04
│       ├── server05
│       ├── server06
│       ├── server07
│       ├── server08
│       ├── server09
│       └── server10
├── level2-1
│   └── inventory
│       ├── server11
│       ├── server12
│       ├── server13
│       ├── server14
│       ├── server15
│       ├── server16
│       ├── server17
│       ├── server18
│       ├── server19
│       └── server20
└── level2-2
    └── inventory
        ├── server21
        ├── server22
        ├── server23
        ├── server24
        ├── server25
        ├── server26
        ├── server27
        ├── server28
        ├── server29
        └── server30

But we may need it in like all={[file1,file2......file30]}
So for that we can do that it like as below. Your inventory will be in host.ini

echo "all={[" >> host.ini;
ls -l level1/*/inventory/ | awk '{print $9","}' | grep -v '^$' | grep -v '^,'>> host.ini;
echo "]}" >> host.ini









Comments

Popular posts from this blog

Wheel Users in Linux

Hello, Thanks for visiting RvKmR.blogspot.in In this blog post, I am explaining about Wheel users in Linux. Red Hat release that I am working on is as below.  [ravi@localhost vagrant]$ cat /etc/redhat-release CentOS release 6.9 (Final) An Linux system can have many users like System users, normal users, and admin (root) user. Its common sens that we have is not to share root user credentials with other user, but here is case that we wish to run administrative command by normal user. In that case we need to aware about wheel users group. Let's first understand what is wheel user in Linux and why we needed it. Wheel is one of Linux user group that allow members of that group to run administrative commands those need root access of system, Wheel user facilitate to do that with sudo (superuser do ) privileges. Lets do it on terminal : Add an user and set password [root@localhost vagrant]# useradd ravi [root@localhost vagrant]# passwd rav...

Ansible for Microsoft's Windows

Hello Thanks for visiting RvKmR's blogs T oday we are discussing managing Microsoft Windows machines with Ansible. We know that managing Linux machines with Ansible is quite common nowadays. but managing windows machines with Ansible is quite new. SSH service is used to manage Linux machine and for windows WinRM. Please check more details about WinRM here . L ets checkout steps to configure WINRM for ansible. Below are requirements for WINRM configuration on target windows machine. Admin Credentials of target windows machine. Stop firewall on target windows machine. Powershell version 3.0 and .net framework 4.0 Let's start configuring Windows machine: I am considering you have administrator account credentials with you. Open Firewall in windows machines and turn of it or allow port 5985 and 5986. Update Powershell and .Net Framework with below commands on PowerShell. $url ="https://raw.githubusercontent.com/jborean93/ansible...

Understanding Linux Cluster

Hello Thanks for visiting RvKmR's blogs. So, What means of clusters and why we need them. Cluster is set of servers or say computers working together to achieve single goal or a task. Now you may have idea why we need cluster.  Types of Cluster: High Availability Cluster / HA Cluster  HA Cluster again grouped in two types. Active-Active Cluster Active-Passive Cluster In Active-Active Cluster Service is running on all nodes in cluster. That means all nodes serving independently. In Active-Passive Cluster Service is running on one of node from cluster and other nodes in passive state. If primary node fails then only other node in cluster will start service.   Storage Cluster In this cluster type, all members provides a single cluster file system that can be accessed by different servers. These file system can be used to read-write data simultaneously. EX: GFS2  OK, Then what is High Availability. This type of cluster provides ...