Browse Source

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
changes/45/575145/1
Jesse Pretorius 1 year ago
parent
commit
311bc08503
1 changed files with 2 additions and 25 deletions
  1. 2
    25
      tasks/haproxy_pre_install.yml

+ 2
- 25
tasks/haproxy_pre_install.yml View File

@@ -43,36 +43,13 @@
43 43
   tags:
44 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 46
 - name: Create haproxy log dir
55 47
   file:
56
-    path: "/var/log/haproxy"
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 }}"
48
+    path: "{{ '/var/log/haproxy' | realpath }}"
69 49
     state: directory
70 50
     owner: haproxy
71 51
     group: adm
72
-    recurse: yes
73
-  when:
74
-    - log_dir.stat.islnk is defined
75
-    - log_dir.stat.islnk
52
+    mode: "0755"
76 53
   tags:
77 54
     - haproxy-dirs
78 55
     - haproxy-logs

Loading…
Cancel
Save