From: Oleg Broytman Date: Tue, 3 Sep 2019 00:32:22 +0000 (+0300) Subject: Feat(run-roles): Run a list of roles separated by comma X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=e041bacf66ba35783e080ae8cfd0c2ef946b9289;p=ansible.git Feat(run-roles): Run a list of roles separated by comma --- diff --git a/playbooks/debian/add-apache-vhost b/playbooks/debian/add-apache-vhost index 0d2c502..750f3fc 100755 --- a/playbooks/debian/add-apache-vhost +++ b/playbooks/debian/add-apache-vhost @@ -10,5 +10,5 @@ shift cd "`dirname \"$0\"`" && ANSIBLE_ROLES_PATH=debian/roles:roles \ - exec ../run-role add-apache-vhost "$@" \ + exec ../run-roles add-apache-vhost "$@" \ -e virtual_host="$vhost" -e gather_facts=true diff --git a/playbooks/debian/add-dns-domain b/playbooks/debian/add-dns-domain index 30a1c13..f4d2f4a 100755 --- a/playbooks/debian/add-dns-domain +++ b/playbooks/debian/add-dns-domain @@ -10,5 +10,5 @@ shift cd "`dirname \"$0\"`" && ANSIBLE_ROLES_PATH=debian/roles:roles \ - exec ../run-role add-dns-domain "$@" \ + exec ../run-roles add-dns-domain "$@" \ -e domain="$domain" -e gather_facts=true diff --git a/playbooks/run-role b/playbooks/run-role deleted file mode 100755 index 3c31ce0..0000000 --- a/playbooks/run-role +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -if [ -z "$1" ]; then - echo "Usage: $0 role [...params...]" >&2 - exit 1 -fi - -role="$1" -shift - -cd "`dirname \"$0\"`" && -exec ansible-playbook run-role.yml "$@" -e role="$role" diff --git a/playbooks/run-role.yml b/playbooks/run-role.yml deleted file mode 100644 index bf25886..0000000 --- a/playbooks/run-role.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: "Run role {{ role }}" - hosts: "{{ hosts | default('all') }}" - gather_facts: "{{ gather_facts | default('false') }}" - roles: - - "{{ role }}" diff --git a/playbooks/run-roles b/playbooks/run-roles new file mode 100755 index 0000000..4251ac1 --- /dev/null +++ b/playbooks/run-roles @@ -0,0 +1,12 @@ +#! /bin/sh + +if [ -z "$1" ]; then + echo "Usage: $0 role1[,role2,...] [...params...]" >&2 + exit 1 +fi + +roles="$1" +shift + +cd "`dirname \"$0\"`" && +exec ansible-playbook run-roles.yml "$@" -e roles="$roles" diff --git a/playbooks/run-roles.yml b/playbooks/run-roles.yml new file mode 100644 index 0000000..bd46c18 --- /dev/null +++ b/playbooks/run-roles.yml @@ -0,0 +1,9 @@ +- name: "Run roles {{ roles }}" + hosts: "{{ hosts | default('all') }}" + gather_facts: "{{ gather_facts | default('false') }}" + tasks: + - include_role: + name: "{{ role }}" + loop: "{{ roles.split(',') }}" + loop_control: + loop_var: role # to avoid collision with {{ item }}