Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Make sure the right beat service gets restarted
Browse files Browse the repository at this point in the history
When running more than one role at once, make sure all of the right notifies
get triggered, not just the one for the last beat role run.
  • Loading branch information
nyetwurk committed Jul 30, 2019
1 parent 4dc1812 commit 0a9c4e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# handlers file for beats

- name: restart beat
- name: restart {{ beat }}
service: name={{ beat }} state=restarted enabled=yes
when: start_service and restart_on_change and not beats_started.changed
6 changes: 3 additions & 3 deletions tasks/beats-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#Copy the default file
- name: Copy Default File for Instance
template: src=beat.j2 dest={{instance_default_file}} mode=0644 force=yes owner=root group=root
notify: restart beat
notify: restart {{ beat }}

#Copy templated config file
- name: Copy Configuration File
- name: Copy Configuration File for {{ beat }}
template: src=beat.yml.j2 dest={{conf_file}} mode=0644 force=yes owner=root group=root
notify: restart beat
notify: restart {{ beat }}
8 changes: 4 additions & 4 deletions tasks/beats-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apt: name=apt-transport-https state=present cache_valid_time=86400
when: use_repository
register: beat_install
notify: restart beat
notify: restart {{beat}}

- name: Debian - Ensure python-urllib3, python-openssl, python-pyasn1 & python-pip are installed
apt:
Expand All @@ -19,7 +19,7 @@
when: use_repository and ansible_distribution_release == "trusty"

- name: Debian - Add Beats repository key
apt_key:
apt_key:
url: "{{ repo_key }}"
state: present
when: use_repository
Expand All @@ -35,7 +35,7 @@
- name: Debian - Ensure {{beat}} is installed
apt: name={{beat}}{% if beats_version is defined and beats_version != "" %}={{ beats_version }}{% endif %} state=present cache_valid_time=86400
when: use_repository
notify: restart beat
potify: restart {{beat}}

- name: Debian - hold {{beat}} version
command: apt-mark hold {{beat}}
Expand All @@ -54,4 +54,4 @@
- name: Debian - Ensure {{beat}} is installed from downloaded package
apt: deb=/tmp/{{beat}}_{{ beats_version }}_{{os_arch}}.deb
when: not use_repository
notify: restart beat
notify: restart {{beat}}
4 changes: 2 additions & 2 deletions tasks/beats-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- name: RedHat - Ensure {{beat}} is installed
yum: name={{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} state=present update_cache=yes
when: use_repository
notify: restart beat
notify: restart {{beat}}

- name: RedHat - lock {{beat}} version
shell: yum versionlock add {{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %}
Expand All @@ -28,4 +28,4 @@
- name: RedHat - Install {{beat}} from url
yum: name={% if custom_package_url is defined %}{{ custom_package_url }}{% else %}{{ beats_package_url }}/{{beat}}-{{ beats_version }}-{{ansible_architecture}}.rpm{% endif %} state=present
when: not use_repository
notify: restart beat
notify: restart {{beat}}

0 comments on commit 0a9c4e4

Please sign in to comment.