[Ansible] – Inventories

The inventory is the file where you will config the host which will be used for ansible connect via SSH and execute the scripts. Following an example.

[local]
localhost

[webserver]
web.mydomain.com

[databases] 
# match hosts in the 10.1.0.0/16 address range 10.1.[0:255].[0:255] [app:children] webserver databases

Following some examples over useful commands regards inventories

  • $ ansible [group] –list-hosts: To return the list of hosts in a group.
$ ansible app --list-hosts
hosts (2):
    web.mydomain.com
    10.1.[0:255].[0:255]
  • ansible –version OR ansible [group] –list-hosts -v: will return the location/path of the configuration file used in the execution of the command when it is performed.
$ ansible app --list-hosts -v
Using /home/myused/myansibleproject/ansible.cfg as config file
hosts (2):
    web.mydomain.com
    10.1.[0:255].[0:255]

For further information see Configuring Ansible in its documentation.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s