diff --git a/infra.ini b/infra.ini new file mode 100644 index 0000000..4bbc01b --- /dev/null +++ b/infra.ini @@ -0,0 +1,8 @@ +[control_infra] +sapt-labx-ctl01 + +[controlservers:children] +control_infra + +[infrastructure:children] +controlservers diff --git a/infra.yml b/infra.yml new file mode 100644 index 0000000..f2ee307 --- /dev/null +++ b/infra.yml @@ -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'] diff --git a/inventory.ini b/inventory.ini index 3313db7..e2769ac 100644 --- a/inventory.ini +++ b/inventory.ini @@ -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 diff --git a/site.yml b/site.yml index 248192a..61b52ca 100644 --- a/site.yml +++ b/site.yml @@ -3,7 +3,6 @@ --- - name: Run playbook hosts: all - remote_user: ansible become: true gather_facts: true tasks: diff --git a/tools/cmd.sh b/tools/cmd.sh index d8188b1..2218051 100755 --- a/tools/cmd.sh +++ b/tools/cmd.sh @@ -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\"" diff --git a/tools/reboot.sh b/tools/reboot.sh index 9cdb988..b995d35 100755 --- a/tools/reboot.sh +++ b/tools/reboot.sh @@ -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\""