From e85210c1b0a129be613625e68ada7fa4cbb17a9e Mon Sep 17 00:00:00 2001 From: rcordier Date: Wed, 22 May 2024 15:22:38 -0400 Subject: [PATCH] change: inventory to constructed --- inventories/{common.yml => 00-common.yml} | 0 inventories/fake/hosts.yml | 41 +++++++++++------------ inventories/lab/hosts.yml | 13 ++----- inventories/zz-constructed.yml | 13 +++++++ 4 files changed, 36 insertions(+), 31 deletions(-) rename inventories/{common.yml => 00-common.yml} (100%) create mode 100644 inventories/zz-constructed.yml diff --git a/inventories/common.yml b/inventories/00-common.yml similarity index 100% rename from inventories/common.yml rename to inventories/00-common.yml diff --git a/inventories/fake/hosts.yml b/inventories/fake/hosts.yml index 6281413..e947c73 100644 --- a/inventories/fake/hosts.yml +++ b/inventories/fake/hosts.yml @@ -1,26 +1,25 @@ -env: - children: - env_fake: - vars: - ansible_host: localhost - ansible_connection: local - hosts: - local: - fake-client1-web1: - fake-client1-web2: - fake-client1-db: +env_fake: + hosts: + local: + fake-client1-web1: + fake-client1-web2: + fake-client1-db: + vars: + ansible_host: localhost + ansible_connection: local + environment_name2: fake5 roles: children: role_web: - hosts: - fake-client1-web1: - fake-client1-web2: - vars: - ansible_user: root + hosts: + fake-client1-web1: + fake-client1-web2: + #vars: + # ansible_user: root role_db: - hosts: - fake-client1-db: - #vars: - # ansible_become: true - # ansible_become_pass: password + hosts: + fake-client1-db: + #vars: + # ansible_become: true + # ansible_become_pass: password diff --git a/inventories/lab/hosts.yml b/inventories/lab/hosts.yml index 77dec69..5eaf12a 100644 --- a/inventories/lab/hosts.yml +++ b/inventories/lab/hosts.yml @@ -2,16 +2,12 @@ env_lab: hosts: rocky-1: - ansible_host: 192.168.122.129 + #ansible_host: 192.168.122.129 rocky-2: - ansible_host: 192.168.122.19 + #ansible_host: 192.168.122.19 vars: ansible_user: cloud-user - -# Inject environment -env: - children: - env_lab: + environment_name2: lab5 # Inject roles roles: @@ -22,6 +18,3 @@ roles: role_db: hosts: rocky-2: - vars: - environment_name: lab - diff --git a/inventories/zz-constructed.yml b/inventories/zz-constructed.yml new file mode 100644 index 0000000..8518c54 --- /dev/null +++ b/inventories/zz-constructed.yml @@ -0,0 +1,13 @@ +# inventory.config file in YAML format +# Documentation: ansible-doc -t inventory ansible.builtin.constructed +# +# Reproduce AWX behavior for constructed inventories + +plugin: ansible.builtin.constructed +strict: False + +keyed_groups: + - prefix: env_ + key: environment_name + parent_group: env +