Bootstrap FreeKB - Ansible - Inventory file format (INI YAML)
Ansible - Inventory file format (INI YAML)

Updated:   |  Ansible articles

Tasks are run against target servers. Some Ansible documentation refers to the target servers as "hosts".

 

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

Here is an example using the INI format.

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

 

And here is the YAML format.

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

 

Once the default hosts file or your own 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 in your default hosts file.

ansible all -m ping

 

Which should return something like this.

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

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


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