From 24866347622248c8711b66d40cdf719e9b69524e Mon Sep 17 00:00:00 2001 From: rcordier Date: Wed, 22 May 2024 13:18:44 -0400 Subject: [PATCH] change: inventory to the best practices --- inventories/common.yml | 7 +++++++ inventories/fake/hosts.yml | 26 +++++++++++++++----------- inventories/lab/hosts.yml | 24 +++++++++++++----------- 3 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 inventories/common.yml diff --git a/inventories/common.yml b/inventories/common.yml new file mode 100644 index 0000000..7cea89f --- /dev/null +++ b/inventories/common.yml @@ -0,0 +1,7 @@ +all: + children: + env: + roles: + children: + role_web: + role_db: diff --git a/inventories/fake/hosts.yml b/inventories/fake/hosts.yml index 8fddb28..6281413 100644 --- a/inventories/fake/hosts.yml +++ b/inventories/fake/hosts.yml @@ -1,20 +1,24 @@ -env_fake: - vars: - ansible_host: localhost - ansible_connection: local - - hosts: - local: - +env: children: - web: + env_fake: + vars: + ansible_host: localhost + ansible_connection: local + hosts: + local: + fake-client1-web1: + fake-client1-web2: + fake-client1-db: + +roles: + children: + role_web: hosts: fake-client1-web1: - #ansible_port: 2222 fake-client1-web2: vars: ansible_user: root - db: + role_db: hosts: fake-client1-db: #vars: diff --git a/inventories/lab/hosts.yml b/inventories/lab/hosts.yml index f6ad9f4..fbcbbd5 100644 --- a/inventories/lab/hosts.yml +++ b/inventories/lab/hosts.yml @@ -1,18 +1,20 @@ --- -env_lab: - hosts: - rocky-1: - ansible_host: 192.168.122.129 - rocky-2: - ansible_host: 192.168.122.19 - vars: - ansible_user: cloud-user -all: +env: children: - web: + env_lab: hosts: rocky-1: - db: + ansible_host: 192.168.122.129 + rocky-2: + ansible_host: 192.168.122.19 + vars: + ansible_user: cloud-user +roles: + children: + role_web: + hosts: + rocky-1: + role_db: hosts: rocky-2: vars: