From 9904f73f30163375638fd30e44239e2159770666 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Sun, 25 Mar 2018 15:55:51 +0200
Subject: [PATCH] ansible-playbooks/general#72 Always use import_tasks or
 include_tasks instead of just include

---
 tasks/main.yml      | 12 ++++++------
 tasks/proxypool.yml | 35 ++++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/tasks/main.yml b/tasks/main.yml
index e3f33e2..0f0cf61 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -7,8 +7,8 @@
 
 - block:
 
-  - include: install.yml
-  - include: configure.yml
+  - import_tasks: install.yml
+  - import_tasks: configure.yml
     tags: 'Config'
 
   when: '"haproxy" not in excluded_roles'
@@ -16,20 +16,20 @@
 - block:
 
   - name: "Install Certs"
-    include: '../../letsencrypt/tasks/cert.yml'
+    include_tasks: '../../letsencrypt/tasks/cert.yml'
     with_items: '{{ proxy_certificates|default([]) }}'
     loop_control:
       loop_var: domain
     when: domain.letsencrypt|default(false) and domain.active|default(true)
 
   - name: "Renew Existing Cert"
-    include: '../../letsencrypt/tasks/renew.yml'
+    import_tasks: '../../letsencrypt/tasks/renew.yml'
 
   - name: "Build HaProxy Certs"
-    include: 'buildcerts.yml'
+    import_tasks: 'buildcerts.yml'
 
   tags: 'Certs'
   when: 'proxy_active and "letsencrypt" not in excluded_roles'
 
-- include_tasks: 'proxypool.yml'
+- import_tasks: 'proxypool.yml'
   tags: 'Certs'
diff --git a/tasks/proxypool.yml b/tasks/proxypool.yml
index 4db3c9d..387e4c1 100644
--- a/tasks/proxypool.yml
+++ b/tasks/proxypool.yml
@@ -1,23 +1,24 @@
 ---
 # file: roles/haproxy/tasks/proxypool.yml
 
-- name: "Set directory permissions to current user"
-  file:
-    path: '/etc/letsencrypt'
-    owner: '{{ ansible_env.SUDO_USER }}'
-    recurse: yes
-  tags: 'Certs'
-  when: 'proxy_active is defined and proxy_active and "letsencrypt" not in excluded_roles'
+- block:
 
-- name: "Pull Certs from active Proxy"
-  include: 'pullcerts.yml'
-  tags: 'Certs'
-  when: 'proxy_active is defined and not proxy_active and "letsencrypt" not in excluded_roles'
+  - name: "Set directory permissions to current user"
+    file:
+      path: '/etc/letsencrypt'
+      owner: '{{ ansible_env.SUDO_USER }}'
+      recurse: yes
+    when: 'proxy_active is defined and proxy_active and "letsencrypt" not in excluded_roles'
+
+  - name: "Pull Certs from active Proxy"
+    import_tasks: 'pullcerts.yml'
+    when: 'proxy_active is defined and not proxy_active and "letsencrypt" not in excluded_roles'
+
+  - name: "Set directory permissions to root"
+    file:
+      path: '/etc/letsencrypt'
+      owner: 'root'
+      recurse: yes
+    when: 'proxy_active is defined and proxy_active and "letsencrypt" not in excluded_roles'
 
-- name: "Set directory permissions to root"
-  file:
-    path: '/etc/letsencrypt'
-    owner: 'root'
-    recurse: yes
   tags: 'Certs'
-  when: 'proxy_active is defined and proxy_active and "letsencrypt" not in excluded_roles'
-- 
GitLab