From b1232aead5c7b33e01275bca6cddbb044f615dbe Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 3 Jan 2019 09:05:32 -0600 Subject: [PATCH] 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 --- elk_metrics_6x/installJournalbeat.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/elk_metrics_6x/installJournalbeat.yml b/elk_metrics_6x/installJournalbeat.yml index cc379729..71574c5c 100644 --- a/elk_metrics_6x/installJournalbeat.yml +++ b/elk_metrics_6x/installJournalbeat.yml @@ -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: