User Tools

Site Tools


ansible:ansible_inventory

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ansible:ansible_inventory [2023/09/04 14:17]
manu
ansible:ansible_inventory [2025/11/18 14:14] (current)
manu
Line 1: Line 1:
 ====== Ansible inventory ====== ====== Ansible inventory ======
  
-<​code>​+
 It is written in an INI or YAML format, lists host and groups. It is written in an INI or YAML format, lists host and groups.
 Can be static of dynamic. Can be static of dynamic.
  
-Example of Collection of groups Dev:children+Convert a ini file to 
 +  * JSON <​code>​ansible-inventory -i /​etc/​ansible/​hosts --list</​code>​ 
 +  * YAML : <​code>​ansible-inventory -i /​etc/​ansible/​hosts --list --yaml</​code>​
  
 +You can add **--vars** to add associated variable for each group/hosts
 +
 +Example of Collection of groups Dev:​children
 +<cli prompt='#'>​
 # cat /​etc/​ansible/​hosts # cat /​etc/​ansible/​hosts
 [managedClients] [managedClients]
Line 20: Line 26:
 RHEL_Dev RHEL_Dev
 AIX_Dev AIX_Dev
 +</​cli>​
  
 +<cli prompt='#'>​
 # ansible-inventory --graph # ansible-inventory --graph
 @all: @all:
Line 32: Line 40:
   |--@local:   |--@local:
   |  |--localhost   |  |--localhost
 +</​cli>​
  
 +<cli prompt='#'>​
 # cat /​etc/​ansible/​hosts # cat /​etc/​ansible/​hosts
 [managedClients] [managedClients]
Line 46: Line 56:
 RHEL_Dev RHEL_Dev
 AIX_Dev AIX_Dev
 +</​cli>​
  
 +<cli prompt='#'>​
 # ansible-inventory –list # ansible-inventory –list
 …. ….
Line 60: Line 72:
             }             }
 …. ….
-</code>+</cli>
  
  
ansible/ansible_inventory.1693829877.txt.gz · Last modified: 2023/09/04 14:17 by manu