Add wrapper scripts to run plays and custom commands
This commit is contained in:
parent
c091a4f869
commit
cbdc7119fb
7
cmd.sh
Executable file
7
cmd.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
HOSTS="$1"
|
||||
CMD="$2"
|
||||
|
||||
ansible -u ansible -m shell -a "$CMD" \
|
||||
--become --ask-become-pass --ask-vault-pass "$HOSTS"
|
25
play.sh
Executable file
25
play.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
HOSTS="$1"
|
||||
|
||||
case $HOSTS in
|
||||
*app*)
|
||||
ROLES="['virt-common', 'docker', 'apps']" ;;
|
||||
*db*)
|
||||
ROLES="['virt-common', 'postgresql']" ;;
|
||||
*prx*|proxy*)
|
||||
ROLES="['virt-common', 'docker', 'proxy']" ;;
|
||||
*)
|
||||
ROLES="['virt-common']" ;;
|
||||
esac
|
||||
|
||||
export HOSTS
|
||||
export ROLES
|
||||
|
||||
PLAYBOOK="play-$(tr -dc A-Za-z < /dev/urandom | head -c 10).yml"
|
||||
envsubst < playbook_template.yml > "$PLAYBOOK"
|
||||
ansible-playbook "$PLAYBOOK" --ask-become-pass --ask-vault-pass
|
||||
STATUS=$?
|
||||
|
||||
rm -f "$PLAYBOOK"
|
||||
exit $STATUS
|
8
playbook_template.yml
Normal file
8
playbook_template.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
# vim: ft=yaml.ansible
|
||||
# code: language=ansible
|
||||
---
|
||||
- name: Run play
|
||||
hosts: ${TARGET_HOSTS}
|
||||
remote_user: ansible
|
||||
become: true
|
||||
roles: ${ROLES}
|
Loading…
Reference in a new issue