Prepare for multiple inventories

This commit is contained in:
Sam A. 2024-01-30 20:55:48 +01:00
parent de4acaa6f2
commit 67e65e807e
Signed by: samsapti
GPG Key ID: CBBBE7371E81C4EA
6 changed files with 32 additions and 9 deletions

8
infra.ini Normal file
View File

@ -0,0 +1,8 @@
[control_infra]
sapt-labx-ctl01
[controlservers:children]
control_infra
[infrastructure:children]
controlservers

12
infra.yml Normal file
View File

@ -0,0 +1,12 @@
# vim: ft=yaml.ansible
# code: language=ansible
---
- name: Run playbook
hosts: all
become: true
gather_facts: true
tasks:
- name: Include role 'ctl-common'
ansible.builtin.include_role:
name: ctl-common
when: hostname in groups['controlservers']

View File

@ -22,9 +22,6 @@ sapt-labr-prx01
# [monitor_shrd]
# sapt-labr-mon01
# [control_infra]
# sapt-labx-ctl01
[production:children]
app_prod
db_prod
@ -61,6 +58,3 @@ proxy_shrd
production
staging
shared
# [infrastructure:children]
# control_infra

View File

@ -3,7 +3,6 @@
---
- name: Run playbook
hosts: all
remote_user: ansible
become: true
gather_facts: true
tasks:

View File

@ -1,6 +1,11 @@
#!/usr/bin/env bash
if [[ $1 == "-i" ]]; then
ARGS="-i $2"
shift 2
fi
HOSTS="$1"
CMD="$2"
ansible -b -u ansible -m shell -a "$CMD" "$HOSTS"
eval "ansible $ARGS -b -m shell -a \"$CMD\" \"$HOSTS\""

View File

@ -1,5 +1,10 @@
#!/usr/bin/env bash
if [[ $1 == "-i" ]]; then
ARGS="-i $2"
shift 2
fi
HOSTS="$1"
ansible -b -u ansible -m reboot "$HOSTS"
eval "ansible $ARGS -b -m reboot \"$HOSTS\""