Skip to content

Commit

Permalink
Fix configure tasks loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tbumke committed Nov 2, 2024
1 parent bf7b0ec commit 7bd0a3f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 53 deletions.
5 changes: 0 additions & 5 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@
- name: Daemon reload
systemd:
daemon_reload: yes

- name: Restart redis
systemd:
state: restarted
name: "{{ service_name }}"
104 changes: 57 additions & 47 deletions tasks/configure.yml
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
---

Check failure on line 1 in tasks/configure.yml

View workflow job for this annotation

GitHub Actions / lint_full

1:4 [new-lines] wrong new line character: expected \n
- 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 }}"
1 change: 0 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
apply:
tags: redis_configuration
tags: redis_configuration
loop: "{{ redis_configurations | default([]) }}"

- name: Build a cluster
import_tasks: cluster.yml
Expand Down

0 comments on commit 7bd0a3f

Please sign in to comment.