Improve role idempotency
Add a 'creates' argument to the task installing HATop so that the task is skipped if it's already installed. Remove 'changed_when' from slurp tasks. Break the 'Test for log directory or link' shell task into a couple tasks which use the stat and file module. Remove 'changed_when' from slurp tasks. Also enable the idempotence test for the gate. Partial-Bug: 1640144 Change-Id: Id7fe24c9c1ae416abab69d4f42b65c9594805e10
This commit is contained in:
parent
32415ab81c
commit
49da8afb89
@ -34,6 +34,6 @@
|
||||
|
||||
- name: Install HATop
|
||||
command: "install -m 755 bin/hatop /usr/local/bin"
|
||||
changed_when: false
|
||||
args:
|
||||
chdir: "/opt/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}"
|
||||
creates: "/usr/local/bin/hatop"
|
||||
|
@ -43,17 +43,10 @@
|
||||
tags:
|
||||
- haproxy-user
|
||||
|
||||
- name: Test for log directory or link
|
||||
shell: |
|
||||
if [ -h "/var/log/haproxy" ]; then
|
||||
chown -h haproxy:adm "/var/log/haproxy"
|
||||
chown -R haproxy:adm "$(readlink /var/log/haproxy)"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
- name: Stat haproxy log dir
|
||||
stat:
|
||||
path: "/var/log/haproxy"
|
||||
register: log_dir
|
||||
failed_when: false
|
||||
changed_when: log_dir.rc != 0
|
||||
tags:
|
||||
- haproxy-dirs
|
||||
- haproxy-logs
|
||||
@ -61,9 +54,25 @@
|
||||
- name: Create haproxy log dir
|
||||
file:
|
||||
path: "/var/log/haproxy"
|
||||
state: directory
|
||||
state: "{{ (log_dir.stat.islnk is defined and log_dir.stat.islnk) | ternary('link', 'directory') }}"
|
||||
src: "{{ (log_dir.stat.islnk is defined and log_dir.stat.islnk) | ternary(log_dir.stat.lnk_source, omit) }}"
|
||||
owner: haproxy
|
||||
group: adm
|
||||
mode: "0755"
|
||||
when: log_dir | changed
|
||||
tags:
|
||||
- haproxy-dirs
|
||||
- haproxy-logs
|
||||
|
||||
- name: Change ownership of haproxy log dir link source
|
||||
file:
|
||||
path: "{{ log_dir.stat.lnk_source }}"
|
||||
state: directory
|
||||
owner: haproxy
|
||||
group: adm
|
||||
recurse: yes
|
||||
when:
|
||||
- log_dir.stat.islnk is defined
|
||||
- log_dir.stat.islnk
|
||||
tags:
|
||||
- haproxy-dirs
|
||||
- haproxy-logs
|
||||
|
@ -17,13 +17,11 @@
|
||||
slurp:
|
||||
src: "{{ haproxy_ssl_cert }}"
|
||||
register: _haproxy_ssl_cert
|
||||
changed_when: false
|
||||
|
||||
- name: Store ssl key
|
||||
slurp:
|
||||
src: "{{ haproxy_ssl_key }}"
|
||||
register: _haproxy_ssl_key
|
||||
changed_when: false
|
||||
|
||||
- name: Register a fact for the cert and key
|
||||
set_fact:
|
||||
|
Loading…
Reference in New Issue
Block a user