Add pretasks to exit quick when needed

The journalbeat playbook uses conditionals to know when to deploy the
journalbeat collector. This change makes it so the playbook simply exits
when the journal is not found or the environment being deployed is not
using systemd. This change will result in faster deployments in mixed
environments as the role will no longer need to iterate over its
conditional.

Change-Id: I581b61902723f54237623036566a83c9be79210e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2019-01-03 09:05:32 -06:00
parent 5586d8a80f
commit b1232aead5
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
1 changed files with 20 additions and 6 deletions

View File

@ -56,11 +56,14 @@
tags:
- always
- name: Halt this playbook if no journal is found
meta: end_play
when:
- not (journal_dir.stat.exists | bool) or
(ansible_service_mgr != 'systemd')
roles:
- role: elastic_journalbeat
when:
- journal_dir.stat.exists | bool
- ansible_service_mgr == 'systemd'
tags:
- beat-install
@ -76,11 +79,22 @@
environment: "{{ deployment_environment_variables | default({}) }}"
pre_tasks:
- name: Check for journal directory
stat:
path: /var/log/journal
register: journal_dir
tags:
- always
- name: Halt this playbook if no journal is found
meta: end_play
when:
- not (journal_dir.stat.exists | bool) or
(ansible_service_mgr != 'systemd')
roles:
- role: elastic_rollup
when:
- journal_dir.stat.exists | bool
- ansible_service_mgr == 'systemd'
index_name: journalbeat
tags: