|
22 | 22 | service: name=sentinel_{{ redis_sentinel_port }} enabled=yes
|
23 | 23 | when: redis_as_service
|
24 | 24 |
|
25 |
| -- name: check if sentinel log file exists |
26 |
| - stat: path={{ redis_sentinel_logfile }} |
27 |
| - register: sentinel_logfile_stat |
| 25 | +# Check then create log dir to prevent aggressively overwriting permissions |
| 26 | +- name: check if sentinel log directory exists |
| 27 | + stat: path={{ redis_sentinel_logfile|dirname }} |
| 28 | + register: sentinel_logdir |
| 29 | + changed_when: false |
| 30 | + when: redis_sentinel_logfile != '""' |
28 | 31 |
|
29 |
| -- name: ensure sentinel pidfile directory exists and has correct owner |
30 |
| - file: path={{ redis_sentinel_pidfile|dirname }} |
| 32 | +- name: create sentinel log directory if it does not exist |
| 33 | + file: state=directory |
| 34 | + path={{ redis_sentinel_logfile|dirname }} |
31 | 35 | owner={{ redis_user }}
|
32 |
| - state=directory |
33 |
| - recurse=yes |
| 36 | + group={{ redis_group }} |
| 37 | + when: |
| 38 | + - redis_sentinel_logfile != '""' |
| 39 | + - not sentinel_logdir.stat.exists |
34 | 40 |
|
35 |
| -- name: ensure sentinel logfile directory exists and has correct owner |
36 |
| - file: path={{ redis_sentinel_logfile|dirname }} |
| 41 | +- name: touch the sentinel log file |
| 42 | + file: state=touch |
| 43 | + path={{ redis_sentinel_logfile }} |
37 | 44 | owner={{ redis_user }}
|
38 |
| - state=directory |
39 |
| - recurse=yes |
| 45 | + group={{ redis_group }} |
40 | 46 | when: redis_sentinel_logfile != '""'
|
41 | 47 |
|
42 |
| -- name: ensure that sentinel log file exists and is writable by redis |
43 |
| - file: path={{ redis_sentinel_logfile }} |
| 48 | +- name: check if sentinel pid directory exists |
| 49 | + stat: path={{ redis_sentinel_pidfile|dirname }} |
| 50 | + register: sentinel_piddir |
| 51 | + changed_when: false |
| 52 | + when: redis_sentinel_pidfile != '""' |
| 53 | + |
| 54 | +- name: create sentinel pid directory if it does not exist |
| 55 | + file: state=directory |
| 56 | + path={{ redis_sentinel_pidfile|dirname }} |
44 | 57 | owner={{ redis_user }}
|
45 |
| - group={{ redis_user }} |
46 |
| - mode=0600 |
47 |
| - state=touch |
48 |
| - when: sentinel_logfile_stat.stat.exists == False and redis_sentinel_logfile != '""' |
| 58 | + group={{ redis_group }} |
| 59 | + when: |
| 60 | + - redis_sentinel_pidfile != '""' |
| 61 | + - not sentinel_piddir.stat.exists |
49 | 62 |
|
50 | 63 | - name: create sentinel config file
|
51 | 64 | template: src=redis_sentinel.conf.j2
|
|
0 commit comments