Fix journalbeat installation for mixed environments

The previous code would terminate the play immediatley if any hosts
in the environment did not have a journal directory. This change runs
the journalbeat install role selectively on hosts that have the journal
directory, and skips hosts that do not.

In addition a legacy task to stop the play after uninstallation is removed,
this functionality is currently broken.

Change-Id: I412e3594c4b2292caafafb580bb4ede9ccfd3944
This commit is contained in:
Jonathan Rosser 2018-09-25 12:32:10 +01:00
parent af4e551c09
commit ac46b2be6a
2 changed files with 9 additions and 17 deletions

View File

@ -53,16 +53,19 @@
stat: stat:
path: /var/log/journal path: /var/log/journal
register: journal_dir register: journal_dir
tags:
- name: exit playbook - always
meta: end_play
when:
- not (journal_dir.stat.exists | bool) or
ansible_service_mgr != 'systemd'
roles: roles:
- role: elastic_journalbeat - role: elastic_journalbeat
when:
- journal_dir.stat.exists | bool
- ansible_service_mgr == 'systemd'
- role: elastic_rollup - role: elastic_rollup
when:
- journal_dir.stat.exists | bool
- ansible_service_mgr == 'systemd'
index_name: journalbeat index_name: journalbeat
tags: tags:

View File

@ -25,17 +25,6 @@
tags: tags:
- always - always
- name: Check for journal directory
stat:
path: /var/log/journal
register: journal_dir
- name: exit playbook after uninstall
meta: end_play
when:
- not (journal_dir.stat.exists | bool) or
ansible_service_mgr != 'systemd'
- name: Ensure beat is installed - name: Ensure beat is installed
package: package:
name: "{{ journalbeat_distro_packages }}" name: "{{ journalbeat_distro_packages }}"