Simplify handler logic

This commit is contained in:
Alexander Gorelyshev
2025-12-26 21:58:02 +04:00
parent 99a34f4514
commit fac775cb9d
2 changed files with 5 additions and 16 deletions

View File

@@ -1,11 +1,7 @@
--- ---
- name: "Enable and restart the Promtail daemon"
- name: "Restart the Promtail daemon"
ansible.builtin.systemd: ansible.builtin.systemd:
name: promtail name: promtail
state: restarted state: restarted
enabled: true
- name: "Reload the Promtail daemon configuration"
ansible.builtin.systemd:
daemon_reload: true daemon_reload: true

View File

@@ -51,7 +51,6 @@
changed_when: false changed_when: false
- name: "Assert version correctness" - name: "Assert version correctness"
notify: "Restart the Promtail daemon"
ansible.builtin.assert: ansible.builtin.assert:
that: "promtail_version in promtail_version_check.stdout" that: "promtail_version in promtail_version_check.stdout"
success_msg: "Expected Promtail version available ({{ promtail_version }})" success_msg: "Expected Promtail version available ({{ promtail_version }})"
@@ -59,6 +58,7 @@
rescue: rescue:
- name: "Install Promtail if its not present" - name: "Install Promtail if its not present"
notify: "Enable and restart the Promtail daemon"
ansible.builtin.unarchive: ansible.builtin.unarchive:
src: "https://github.com/grafana/loki/releases/download/v\ src: "https://github.com/grafana/loki/releases/download/v\
{{ promtail_version }}/promtail-linux-amd64.zip" {{ promtail_version }}/promtail-linux-amd64.zip"
@@ -81,7 +81,7 @@
- name: "Template the systemd unit file" - name: "Template the systemd unit file"
notify: "Reload the Promtail daemon configuration" notify: "Enable and restart the Promtail daemon"
ansible.builtin.template: ansible.builtin.template:
src: promtail.service.j2 src: promtail.service.j2
dest: /etc/systemd/system/promtail.service dest: /etc/systemd/system/promtail.service
@@ -91,17 +91,10 @@
- name: "Template Promtail config file" - name: "Template Promtail config file"
notify: "Restart the Promtail daemon" notify: "Enable and restart the Promtail daemon"
ansible.builtin.template: ansible.builtin.template:
src: templates/promtail.yml.j2 src: templates/promtail.yml.j2
dest: /usr/local/bin/config-promtail.yml dest: /usr/local/bin/config-promtail.yml
owner: root owner: root
group: root group: root
mode: "0644" mode: "0644"
- name: "Enable and start Promtail daemon"
ansible.builtin.systemd:
name: promtail
state: started
enabled: true