]> git.phdru.name Git - ansible.git/commitdiff
Feat(run-roles): Run a list of roles separated by comma
authorOleg Broytman <phd@phdru.name>
Tue, 3 Sep 2019 00:32:22 +0000 (03:32 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 3 Sep 2019 00:33:31 +0000 (03:33 +0300)
playbooks/debian/add-apache-vhost
playbooks/debian/add-dns-domain
playbooks/run-role [deleted file]
playbooks/run-role.yml [deleted file]
playbooks/run-roles [new file with mode: 0755]
playbooks/run-roles.yml [new file with mode: 0644]

index 0d2c502c1cbb522962699aa535e99395a2c99db1..750f3fcb915b7d044d0217dd833089abc724e1ea 100755 (executable)
@@ -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
index 30a1c137fbf6ebb04d65dc3912afd64fe04748cc..f4d2f4a550dc90228f9ff0dadbb86e98bb7077ba 100755 (executable)
@@ -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 (executable)
index 3c31ce0..0000000
+++ /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 (file)
index bf25886..0000000
+++ /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 (executable)
index 0000000..4251ac1
--- /dev/null
@@ -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 (file)
index 0000000..bd46c18
--- /dev/null
@@ -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 }}