grafana-ansible-collection
grafana-ansible-collection copied to clipboard
alloy: Use service reload instead of restart
When you change the configuration of the alloy service, ansible role restarts the service. So all the nodes of the cluster are down, they are replaying the wal files. Can we reload it when the configuration is changed?
# roles/alloy/tasks/configure.yml#L19
- name: Deploy alloy configuration file
ansible.builtin.template:
src: config.alloy.j2
dest: "{{ config_dir }}/{{ config_file }}"
owner: "{{ service_user }}"
group: "{{ service_group }}"
mode: '0644'
notify: Reload alloy
become: true
# roles/alloy/handlers/main.yml#L7 Add new handler
- name: Check if alloy service is active
ansible.builtin.shell: systemctl is-active alloy
register: alloy_service_status
ignore_errors: true
listen: "Reload alloy"
- name: Restart alloy service if not active
ansible.builtin.service:
name: alloy
state: restarted
when: alloy_service_status.stdout != "active"
listen: "Reload alloy"
- name: Reload alloy service if active
ansible.builtin.service:
name: alloy
state: reloaded
when: alloy_service_status.stdout == "active"
listen: "Reload alloy"
- name: Check alloy is started properly
ansible.builtin.include_tasks: ga-started.yml
listen: "Reload alloy"
If it is convenient for you, we can create a pull request for the above changes. cc: @emre-23 @acciorg
Thanks @f9n Yeah that makes sense and yeah definitely put a PR
If you'd like to implement this, I believe it should be sufficient to update the template task to trigger a reload instead of a restart and create a new handler for the reload.