summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Pretorius <jesse.pretorius@rackspace.co.uk>2018-06-13 16:21:56 +0100
committerJesse Pretorius <jesse.pretorius@rackspace.co.uk>2018-06-13 16:23:03 +0100
commit311bc085036e1a0559d9815d464cafb046ab6482 (patch)
tree6791784285381c7fed7b5e1362a8a5466b3967d7
parentc85793ed2162e357eaf99058b2a2162ba30cb26b (diff)
Use realpath filter instead of the stat/dir dance
We can make the deployment more efficient if we use the realpath filter, instead of first checking for the directory and then implementing the changes in a follow-up task. This is more readable, simpler and faster to execute. Change-Id: Iaa6c1873330370ae62cd29e7d4c211c7211b703d
Notes
Notes (review): Code-Review+2: Kevin Carter (cloudnull) <kevin@cloudnull.com> Code-Review+2: Mohammed Naser <mnaser@vexxhost.com> Workflow+1: Mohammed Naser <mnaser@vexxhost.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 14 Jun 2018 01:24:43 +0000 Reviewed-on: https://review.openstack.org/575145 Project: openstack/openstack-ansible-haproxy_server Branch: refs/heads/master
-rw-r--r--tasks/haproxy_pre_install.yml27
1 files changed, 2 insertions, 25 deletions
diff --git a/tasks/haproxy_pre_install.yml b/tasks/haproxy_pre_install.yml
index 5319279..5d6f252 100644
--- a/tasks/haproxy_pre_install.yml
+++ b/tasks/haproxy_pre_install.yml
@@ -43,36 +43,13 @@
43 tags: 43 tags:
44 - haproxy-user 44 - haproxy-user
45 45
46- name: Stat haproxy log dir
47 stat:
48 path: "/var/log/haproxy"
49 register: log_dir
50 tags:
51 - haproxy-dirs
52 - haproxy-logs
53
54- name: Create haproxy log dir 46- name: Create haproxy log dir
55 file: 47 file:
56 path: "/var/log/haproxy" 48 path: "{{ '/var/log/haproxy' | realpath }}"
57 state: "{{ (log_dir.stat.islnk is defined and log_dir.stat.islnk) | ternary('link', 'directory') }}"
58 src: "{{ (log_dir.stat.islnk is defined and log_dir.stat.islnk) | ternary(log_dir.stat.lnk_source, omit) }}"
59 owner: haproxy
60 group: adm
61 mode: "0755"
62 tags:
63 - haproxy-dirs
64 - haproxy-logs
65
66- name: Change ownership of haproxy log dir link source
67 file:
68 path: "{{ log_dir.stat.lnk_source }}"
69 state: directory 49 state: directory
70 owner: haproxy 50 owner: haproxy
71 group: adm 51 group: adm
72 recurse: yes 52 mode: "0755"
73 when:
74 - log_dir.stat.islnk is defined
75 - log_dir.stat.islnk
76 tags: 53 tags:
77 - haproxy-dirs 54 - haproxy-dirs
78 - haproxy-logs 55 - haproxy-logs