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

YAML Syntax - Inventory Format

Jump to solution

Here I am again, with another one of those migraine queries.

Here's the syntax that I need help with piecing together:

Inventory: amh[1:2] Hosts info: amh1.d1.com IP: 172.17.1.1 MAC: 00:11:22:33:44:55 amh2.d1.com IP: 172.17.1.2 MAC: 00:11:22:33:44:66


It's given to me just like that - on a single line. Which line does each piece of
information get placed on?  What does the indention of each line look like?

The YAML syntax for the inventory is supposed to accommodate the following
command:

                ansible anh2 -m ping -o

where the target host -  "anh2" in this case - will be reached.

I need help with the actual formatting of the YAML code.  Whatever you provide
to me, that's exactly how I'm going to enter it into the file!!!

 

Still haven't found that bottle of Excedrin

 

 

Trevor "Red Hat Evangelist" Chandler
Labels (3)
2 Solutions

Accepted Solutions
Chetan_Tiwary_
Community Manager
Community Manager
  • 184 Views

@Trevor  here it is curated especially for you in the kitchen :

Inventory: amh[1:2] Hosts info: amh1.d1.com IP: 172.17.1.1 MAC: 00:11:22:33:44:55 amh2.d1.com IP: 172.17.1.2 MAC: 00:11:22:33:44:66   

this means amh1 and amh2 is the servers in the inventory and then you have hosts info with host name, IP and MAC . You can use ansible_host  key and then mac_address :

---
all:
  hosts:
    amh1:
      ansible_host: 172.17.1.1
      mac_address: "00:11:22:33:44:55"
    amh2:
      ansible_host: 172.17.1.2
      mac_address: "00:11:22:33:44:66"

https://docs.ansible.com/ansible/latest/network/getting_started/first_inventory.html 

View solution in original post

Chetan_Tiwary_
Community Manager
Community Manager
  • 179 Views

@Trevor here I tried to execute this in the lab as well : 

Chetan_Tiwary__0-1757356416334.pngChetan_Tiwary__1-1757356428394.png

 

View solution in original post

3 Replies
Chetan_Tiwary_
Community Manager
Community Manager
  • 185 Views

@Trevor  here it is curated especially for you in the kitchen :

Inventory: amh[1:2] Hosts info: amh1.d1.com IP: 172.17.1.1 MAC: 00:11:22:33:44:55 amh2.d1.com IP: 172.17.1.2 MAC: 00:11:22:33:44:66   

this means amh1 and amh2 is the servers in the inventory and then you have hosts info with host name, IP and MAC . You can use ansible_host  key and then mac_address :

---
all:
  hosts:
    amh1:
      ansible_host: 172.17.1.1
      mac_address: "00:11:22:33:44:55"
    amh2:
      ansible_host: 172.17.1.2
      mac_address: "00:11:22:33:44:66"

https://docs.ansible.com/ansible/latest/network/getting_started/first_inventory.html 

Chetan_Tiwary_
Community Manager
Community Manager
  • 180 Views

@Trevor here I tried to execute this in the lab as well : 

Chetan_Tiwary__0-1757356416334.pngChetan_Tiwary__1-1757356428394.png

 

Trevor
Commander Commander
Commander
  • 160 Views

It doesn't get anymore authentic than actual results!!!

Thanks Chetan!!!

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