cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Commander Commander
Commander
  • 320 Views

Ansible Inventory Definition - INI vs YAML Format

I need to write an inventory definition, in INI and YAML format, based on the following:

- "Carribean" group
- "Barbados" and "Jamaica" subgroups, inside the "Carribean" group
- 3 hosts (host1, host2, host3) inside the "Barbados" subgroup
- 1 hosts (host4) inside the "Jamaica" subgroup


What does the syntax look like for each format?

Trevor "Red Hat Evangelist" Chandler
Labels (1)
4 Replies
Ad_astra
Flight Engineer Flight Engineer
Flight Engineer
  • 294 Views

Hi there

Good question. My answer as follows:

For the YAML formatted inventory:

---
Barbados:
  hosts:
    host1
    host2
    host3

Jamaica:
  hosts:
    host4

Carribean:
  children:
    Barbados:
    Jamaica:

For the INI formatted inventory:

[Barbados]
host1
host2
host3
[Jamaica]
host4
[Carribean:children]
Barbados
Jamaica

I use the INI format for day to day tasks as that is what I am more familiar with!

Thanks 

Trevor
Commander Commander
Commander
  • 293 Views

Ad_astra, thanks for getting things kicked off with your respsonse!

 

Trevor "Red Hat Evangelist" Chandler
Chetan_Tiwary_
Community Manager
Community Manager
  • 141 Views

@Trevor 

---
all:
  children:
    caribbean:
      children:
        barbados:
          hosts:
            host1:
            host2:
            host3:
        jamaica:
          hosts:
            host4:

 

[caribbean:children]
barbados
jamaica

[barbados]
host1
host2
host3

[jamaica]
host4
Trevor
Commander Commander
Commander
  • 34 Views

Chetan, you make it look so easy - so simple!!!

Thank you!!!!

Trevor "Red Hat Evangelist" Chandler
Join the discussion
You must log in to join this conversation.