From 7964f4cad2e8dd7f0c6548a4dcc27ee8cddc330b Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Tue, 8 Mar 2016 10:52:40 +0100
Subject: [PATCH] Allow to exclude roles from plays with --exclude-roles
 command line parameter

---
 tasks/install.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++
 tasks/main.yml    | 57 ++++-------------------------------------------
 2 files changed, 59 insertions(+), 53 deletions(-)
 create mode 100644 tasks/install.yml

diff --git a/tasks/install.yml b/tasks/install.yml
new file mode 100644
index 0000000..0508904
--- /dev/null
+++ b/tasks/install.yml
@@ -0,0 +1,55 @@
+---
+# file: roles/haproxy/tasks/install.yml
+#
+# Output logs and errs into temp files:
+# echo "show errors" | sudo socat unix-connect:/run/haproxy/admin.sock stdio >> /tmp/myhapshowerrs.out 2> /tmp/myhapshowerrs.err
+
+# TODO: Configure HaProxy together with Varnish
+# http://blog.haproxy.com/2015/05/06/haproxys-load-balancing-algorithm-for-static-content-delivery-with-varnish/
+# http://blog.haproxy.com/2012/08/25/haproxy-varnish-and-the-single-hostname-website/
+
+# TODO: What's new in Version 1.6
+# http://blog.haproxy.com/2015/10/14/whats-new-in-haproxy-1-6/
+
+- name: "Proxy | Add Apt Repositories"
+  apt_repository:
+    repo='{{ item }}'
+    state=present
+  with_items:
+    - "ppa:vbernat/haproxy-1.6"
+
+- name: "Proxy | Install some packages"
+  apt:
+    pkg='{{ item }}'
+    state=installed
+  with_items:
+    - haproxy
+    - hatop
+    - socat
+    - php5
+    - php5-mysql
+
+- name: "Proxy | create directories"
+  file:
+    dest='{{ item }}'
+    state=directory
+    mode='755'
+  with_items:
+    - /etc/haproxy/certs
+    - /etc/haproxy/update
+
+- name: "Proxy | Install hatop shortcut"
+  copy:
+    src='usr_local_bin_hatop'
+    dest='/usr/local/bin/hatop'
+    owner='root'
+    group='root'
+    mode='755'
+
+- name: "Proxy | Install log rotator"
+  copy:
+    src='etc_logrotate_d_haproxy'
+    dest='/etc/logrotate.d/haproxy'
+    owner='root'
+    group='root'
+    mode='644'
diff --git a/tasks/main.yml b/tasks/main.yml
index 1921d0c..8a9ad40 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,57 +1,8 @@
 ---
 # file: roles/haproxy/tasks/main.yml
-#
-# Output logs and errs into temp files:
-# echo "show errors" | sudo socat unix-connect:/run/haproxy/admin.sock stdio >> /tmp/myhapshowerrs.out 2> /tmp/myhapshowerrs.err
 
-# TODO: Configure HaProxy together with Varnish
-# http://blog.haproxy.com/2015/05/06/haproxys-load-balancing-algorithm-for-static-content-delivery-with-varnish/
-# http://blog.haproxy.com/2012/08/25/haproxy-varnish-and-the-single-hostname-website/
+- block:
+  - include: install.yml
+  - include: configure.yml
 
-# TODO: What's new in Version 1.6
-# http://blog.haproxy.com/2015/10/14/whats-new-in-haproxy-1-6/
-
-- name: "Proxy | Add Apt Repositories"
-  apt_repository:
-    repo='{{ item }}'
-    state=present
-  with_items:
-    - "ppa:vbernat/haproxy-1.6"
-
-- name: "Proxy | Install some packages"
-  apt:
-    pkg='{{ item }}'
-    state=installed
-  with_items:
-    - haproxy
-    - hatop
-    - socat
-    - php5
-    - php5-mysql
-
-- name: "Proxy | create directories"
-  file:
-    dest='{{ item }}'
-    state=directory
-    mode='755'
-  with_items:
-    - /etc/haproxy/certs
-    - /etc/haproxy/update
-
-- name: "Proxy | Install hatop shortcut"
-  copy:
-    src='usr_local_bin_hatop'
-    dest='/usr/local/bin/hatop'
-    owner='root'
-    group='root'
-    mode='755'
-
-- name: "Proxy | Install log rotator"
-  copy:
-    src='etc_logrotate_d_haproxy'
-    dest='/etc/logrotate.d/haproxy'
-    owner='root'
-    group='root'
-    mode='644'
-
-- include: configure.yml
+  when: '"haproxy" not in excluded_roles'
-- 
GitLab