Format for Ansible Inventory File

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 08:54 AM
Looking to see how others are formatting their ansible inventory files (hosts)
I can't seem to get the INI file formatting to work so I am working with YAML format.
How do you build groups or group devices within this format? I have read the ansible documentation but do not really understand. The output doesn't read as I would expect.
MacBook-Pro:ansible stevenwiliams$ cat hosts
all:
hosts:
cisco routers:
hosts:
R01:
R02:
R03:
R04:
MacBook-Pro:ansible stevenwiliams$ ansible --list-hosts all
hosts (1):
cisco routers
MacBook-Pro:ansible stevenwiliams$
- Labels:
-
Network Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2021 12:32 PM - edited 06-09-2021 12:33 PM
This is very old, but I'm going to respond in case someone stumbles across this in the future. Here's the format I've got working:
[mydevices]
host1.domain.com
host2.domain.com
host3.domain.com
[mydevices:vars]
ansible_become=no
ansible_become_method=enable
ansible_network_os=cisco.ios.ios
ansible_user=<username>
ansible_password=<password>
