cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2068
Views
0
Helpful
1
Replies

Format for Ansible Inventory File

Steven Williams
Level 4
Level 4

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$

1 Reply 1

gbekmezi-DD
Level 5
Level 5

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>

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: