-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,57 @@ | ||
--- | ||
- name: "Set redis service for {{ item.redis_instance_name }}" | ||
template: | ||
src: redis.service.j2 | ||
dest: "{{ redis_systemd_directory }}/{{ item.redis_instance_name }}.service" | ||
mode: '0644' | ||
owner: root | ||
group: root | ||
when: "ansible_service_mgr == 'systemd'" | ||
notify: | ||
- Daemon reload | ||
|
||
- name: Flush handlers | ||
meta: flush_handlers | ||
|
||
- name: "Create redis config directory for {{ item.redis_instance_name }}" | ||
file: | ||
path: "{{ redis_config_directory }}" | ||
state: directory | ||
mode: '0700' | ||
owner: "{{ redis_user_name }}" | ||
group: "{{ redis_group_name }}" | ||
setype: redis_conf_t | ||
when: redis_config_directory != "/etc" | ||
|
||
- name: "Set service name {{ item.redis_instance_name }}" | ||
set_fact: | ||
service_name: "{{ item.redis_instance_name }}.service" | ||
|
||
- name: "Set redis config for {{ item.redis_instance_name }}" | ||
template: | ||
src: redis.conf.j2 | ||
dest: "{{ redis_config_directory }}/{{ item.redis_instance_name }}.conf" | ||
owner: "{{ redis_user_name }}" | ||
group: "{{ redis_group_name }}" | ||
mode: '0660' | ||
setype: redis_conf_t | ||
notify: Restart redis | ||
|
||
- name: "Start redis service {{ item.redis_instance_name }}" | ||
systemd: | ||
state: started | ||
name: "{{ service_name }}" | ||
enabled: yes | ||
|
||
- name: Flush handlers | ||
meta: flush_handlers | ||
--- | ||
- name: "Set redis service" | ||
template: | ||
src: redis.service.j2 | ||
dest: "{{ redis_systemd_directory }}/{{ item.redis_instance_name }}.service" | ||
mode: '0644' | ||
owner: root | ||
group: root | ||
when: "ansible_service_mgr == 'systemd'" | ||
loop: "{{ redis_configurations | default([]) }}" | ||
loop_control: | ||
label: "{{ item.redis_instance_name }}" | ||
notify: Daemon reload | ||
|
||
- name: Flush handlers | ||
meta: flush_handlers | ||
|
||
- name: "Create redis config directory" | ||
file: | ||
path: "{{ redis_config_directory }}" | ||
state: directory | ||
mode: '0700' | ||
owner: "{{ redis_user_name }}" | ||
group: "{{ redis_group_name }}" | ||
setype: redis_conf_t | ||
when: redis_config_directory != "/etc" | ||
|
||
- name: "Set redis config" | ||
template: | ||
src: redis.conf.j2 | ||
dest: "{{ redis_config_directory }}/{{ item.redis_instance_name }}.conf" | ||
owner: "{{ redis_user_name }}" | ||
group: "{{ redis_group_name }}" | ||
mode: '0660' | ||
setype: redis_conf_t | ||
register: redis_config | ||
loop: "{{ redis_configurations | default([]) }}" | ||
loop_control: | ||
label: "{{ item.redis_instance_name }}" | ||
|
||
- name: "Restart redis service(s) if config changed" | ||
systemd: | ||
state: restarted | ||
name: "{{ item.redis_instance_name }}" | ||
when: redis_config.changed | ||
loop: "{{ redis_configurations | default([]) }}" | ||
loop_control: | ||
label: "{{ item.redis_instance_name }}" | ||
|
||
- name: "Start and enable redis service(s)" | ||
systemd: | ||
state: started | ||
name: "{{ item.redis_instance_name }}" | ||
enabled: yes | ||
loop: "{{ redis_configurations | default([]) }}" | ||
loop_control: | ||
label: "{{ item.redis_instance_name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters