FreeKB - Managed Nodes file format (INI vs YAML)
Ansible - Managed Nodes file format (INI vs YAML)

The default hosts file or inventory file can use different formats. The most commonly used formats are INI and YAML. Follow are example INI and YAML configurations.

INI

server1.example.com
server2.example.com
[linux]
server3.example.com
server4.example.com
[windows]
server5.example.com
server6.example.com

 

YAML

all:
  hosts:
    server1.example.com:
    server2.example.com:
  children:
    linux:
      hosts:
        server3.example.com:
        server4.example.com:
    windows:
      hosts:
        server5.example.com:
        server6.example.com:

 

Once the default hosts file or inventory file has been updated to contain managed nodes (e.g. target systems), you can run tasks against the managed nodes. For example, the following command would ping every managed node. If you do not use the -i option, the default hosts file will be used, like this.

ansible all -m ping

 

If you use the -i command line option, your inventory file will be used, like this.

ansible all -m ping -i inventory.yml

 

Issuing a command should return the following.

server1.example.org | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 42a38 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |