Outils pour utilisateurs

Outils du site


tech:notes_ansible-inventory

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
tech:notes_ansible-inventory [2025/03/24 15:06] – créée - modification externe 127.0.0.1tech:notes_ansible-inventory [2025/11/20 14:55] (Version actuelle) Jean-Baptiste
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 {{tag>Brouillon Ansible CA}} {{tag>Brouillon Ansible CA}}
  
-Notes Ansible Inventory+Notes Ansible Inventory
  
  
Ligne 7: Ligne 8:
 * [[ansible_inventory_script_-_inventaire_dynamique_3|Ansible inventaire script - inventaire dynamique vers statique - Conversion JSON YAML INI]] * [[ansible_inventory_script_-_inventaire_dynamique_3|Ansible inventaire script - inventaire dynamique vers statique - Conversion JSON YAML INI]]
 * https://blog.stephane-robert.info/post/ansible-inventaire-static-precedence-tips/ * https://blog.stephane-robert.info/post/ansible-inventaire-static-precedence-tips/
 +
 +Script pour gérer un inventaire - openstack-ansible :
 +* openstack-ansible/scripts/inventory-manage.py
 +* https://superuser.openinfra.org/articles/complex-openstack-inventory-a-nightmare/
 +* https://docs.openstack.org/openstack-ansible/latest/reference/inventory/manage-inventory.html
  
  
  
 Linter un fichier inventaire  Linter un fichier inventaire 
-<code>+~~~
 ansible-lint inventory1.yml ansible-lint inventory1.yml
  
Ligne 17: Ligne 23:
  
 ansible-inventory -i inventory1.yml -y --list > inventory2.yml ansible-inventory -i inventory1.yml -y --list > inventory2.yml
-</code>+~~~
  
 Print all variables for all hosts from the command line Print all variables for all hosts from the command line
-<code bash>+~~~bash
 ansible -i inventory/local -m debug -a "var=hostvars" all ansible -i inventory/local -m debug -a "var=hostvars" all
-</code>+~~~
  
 Afficher les variables pour tous les hosts Afficher les variables pour tous les hosts
-<code bash>+~~~bash
 ansible-inventory -i inventory.yml --graph --vars ansible-inventory -i inventory.yml --graph --vars
-</code>+~~~
  
 Afficher les variables pour un host particulier Afficher les variables pour un host particulier
-<code bash>+~~~bash
 # En YAML # En YAML
 ansible-inventory -i inventory.yml -y --host server1 ansible-inventory -i inventory.yml -y --host server1
Ligne 36: Ligne 42:
 # En JSON # En JSON
 ansible-inventory -i inventory.yml --host server1 ansible-inventory -i inventory.yml --host server1
-</code>+~~~
  
-== Plugin+## Plugin
  
-<code ->+~~~
 $ ansible-doc -t inventory -l $ ansible-doc -t inventory -l
 advanced_host_list                  Parses a 'host list' with ranges advanced_host_list                  Parses a 'host list' with ranges
Ligne 65: Ligne 71:
 toml                                Uses a specific TOML file as an inventory source toml                                Uses a specific TOML file as an inventory source
 yaml                                Uses a specific YAML file as an inventory source yaml                                Uses a specific YAML file as an inventory source
-</code>+~~~
  
  
  
-== Playbook+## Playbook
  
 Limiter l'inventaire en faisant une intersection Limiter l'inventaire en faisant une intersection
-<code yaml>+~~~yaml
  hosts: "type_host:&{{ PLOP_LIMIT | default('all') }}"  hosts: "type_host:&{{ PLOP_LIMIT | default('all') }}"
-</code>+~~~
  
-=== Inventaire dynamique passé en extra-vars+### Inventaire dynamique passé en extra-vars
  
-<code yaml play_roles_temp_inventory.yaml> +''play_roles_temp_inventory.yaml'' 
----+~~~yaml
 #! /usr/bin/ansible-playbook #! /usr/bin/ansible-playbook
 +
 +---
  
 - hosts: localhost - hosts: localhost
Ligne 108: Ligne 116:
         loop_var: role_name         loop_var: role_name
       when: play_roles is defined       when: play_roles is defined
-</code> +~~~ 
-== Tower+ 
 +## Tower
  
 Voir https://docs.ansible.com/ansible-tower/latest/html/administration/tipsandtricks.html#using-the-tower-cli-tool Voir https://docs.ansible.com/ansible-tower/latest/html/administration/tipsandtricks.html#using-the-tower-cli-tool
  
-<code bash>+~~~bash
 awx-manage inventory_import --source=inventory/ \ awx-manage inventory_import --source=inventory/ \
   --inventory-name="My Tower Inventory"   --inventory-name="My Tower Inventory"
Ligne 122: Ligne 131:
  
 mkdir -p inventory-directory/group_vars mkdir -p inventory-directory/group_vars
-</code>+~~~
  
 Voir ''[[Ansible AWX - Tower Cli|awx import]]'' Voir ''[[Ansible AWX - Tower Cli|awx import]]''
  
  
-== Autres+## Autres
  
 inventory_hostname et ansible_hostname  inventory_hostname et ansible_hostname 
tech/notes_ansible-inventory.1742825205.txt.gz · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki