From c43903e5c5d262d6ab09452e053afcfa1f8d26a4 Mon Sep 17 00:00:00 2001 From: Duncan Martin Walker Date: Fri, 7 Feb 2020 14:18:45 +0000 Subject: [PATCH] Allow user override of beat install locations The installation locations of elastic beats are currently hardcoded using openstack-ansible groups and cannot readily be extended to include non-openstack hosts. This is particularly notable with auditbeat, packetbeat and filebeat, which directly use the OSA 'hosts' group, and metricbeat, which uses 'all'. This commit allows these choices to be overrided by defining groups named filebeat, metricbeat etc, with naming conventions as with the elk integration inventory. Using integration inventories, one can include the OSA groups within the override to extend the deployment. The defaults are unchanged, with the exception of Metricbeat, which is now by default deployed to the OSA groups 'hosts' and 'all_containers' instead of 'all'. Change-Id: Ie39fc10f5749c9636c890a0417fc532f77562144 --- elk_metrics_7x/installAuditbeat.yml | 2 +- elk_metrics_7x/installFilebeat.yml | 2 +- elk_metrics_7x/installHeartbeat.yml | 17 +++++++----- elk_metrics_7x/installJournalbeat.yml | 37 +++++++++++++++------------ elk_metrics_7x/installMetricbeat.yml | 5 ++-- elk_metrics_7x/installPacketbeat.yml | 2 +- 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/elk_metrics_7x/installAuditbeat.yml b/elk_metrics_7x/installAuditbeat.yml index 957ce0ae..022bd221 100644 --- a/elk_metrics_7x/installAuditbeat.yml +++ b/elk_metrics_7x/installAuditbeat.yml @@ -12,7 +12,7 @@ # limitations under the License. - name: Install Auditbeat - hosts: hosts + hosts: "{{ groups['auditbeat'] | default(groups['hosts']) }}" become: true vars: haproxy_ssl: false diff --git a/elk_metrics_7x/installFilebeat.yml b/elk_metrics_7x/installFilebeat.yml index d40fb154..842dc694 100644 --- a/elk_metrics_7x/installFilebeat.yml +++ b/elk_metrics_7x/installFilebeat.yml @@ -12,7 +12,7 @@ # limitations under the License. - name: Install Filebeat - hosts: hosts + hosts: "{{ groups['filebeat'] | default(groups['hosts']) }}" become: true vars: haproxy_ssl: false diff --git a/elk_metrics_7x/installHeartbeat.yml b/elk_metrics_7x/installHeartbeat.yml index d7228fa6..772b0ba5 100644 --- a/elk_metrics_7x/installHeartbeat.yml +++ b/elk_metrics_7x/installHeartbeat.yml @@ -16,17 +16,20 @@ gather_facts: false connection: local tasks: - - name: Add hosts to dynamic inventory group - group_by: - key: heatbeat_deployment_targets - parents: kibana - when: - - inventory_hostname in groups['kibana'][:3] + - name: Configure deployment group when Heartbeat group not specified + block: + - name: Add hosts to dynamic inventory group + group_by: + key: heartbeat_deployment_targets + parents: kibana + when: + - inventory_hostname in groups['kibana'][:3] + when: groups['heartbeat'] is not defined tags: - always - name: Install Heartbeat - hosts: heatbeat_deployment_targets + hosts: "{{ groups['heartbeat'] | default(groups['heartbeat_deployment_targets'] | default([])) }}" become: true vars: haproxy_ssl: false diff --git a/elk_metrics_7x/installJournalbeat.yml b/elk_metrics_7x/installJournalbeat.yml index 9d239795..d78e1da0 100644 --- a/elk_metrics_7x/installJournalbeat.yml +++ b/elk_metrics_7x/installJournalbeat.yml @@ -16,29 +16,32 @@ gather_facts: false connection: local tasks: - - name: Add hosts to dynamic inventory group - group_by: - key: journalbeat_deployment_containers - parents: all_journalbeat_deployments - when: - - openstack_release is defined and - openstack_release is version('18.0.0', 'lt') - - physical_host is defined and - physical_host != inventory_hostname + - name: Configure deployment group when Journalbeat group not specified + block: + - name: Add hosts to dynamic inventory group + group_by: + key: journalbeat_deployment_containers + parents: all_journalbeat_deployments + when: + - openstack_release is defined and + openstack_release is version('18.0.0', 'lt') + - physical_host is defined and + physical_host != inventory_hostname - - name: Add hosts to dynamic inventory group - group_by: - key: journalbeat_deployment_hosts - parents: all_journalbeat_deployments + - name: Add hosts to dynamic inventory group + group_by: + key: journalbeat_deployment_hosts + parents: all_journalbeat_deployments + when: + - physical_host is undefined or + physical_host == inventory_hostname when: - - physical_host is undefined or - physical_host == inventory_hostname - + - groups['journalbeat'] is not defined tags: - always - name: Install Journalbeat - hosts: all_journalbeat_deployments + hosts: "{{ groups['journalbeat'] | default(groups['all_journalbeat_deployments']) }}" become: true vars: haproxy_ssl: false diff --git a/elk_metrics_7x/installMetricbeat.yml b/elk_metrics_7x/installMetricbeat.yml index 66e2df43..4e9a3bac 100644 --- a/elk_metrics_7x/installMetricbeat.yml +++ b/elk_metrics_7x/installMetricbeat.yml @@ -11,8 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Install Metricsbeat - hosts: all +- name: Install Metricbeat + # The nested defaults are required as ansible doesn't short-circuit in its default filter + hosts: "{{ groups['metricbeat'] | default( (groups['hosts'] | default([])) + (groups['all_containers'] | default([]))) }}" become: true vars: haproxy_ssl: false diff --git a/elk_metrics_7x/installPacketbeat.yml b/elk_metrics_7x/installPacketbeat.yml index b83b2b7f..a8d32e08 100644 --- a/elk_metrics_7x/installPacketbeat.yml +++ b/elk_metrics_7x/installPacketbeat.yml @@ -12,7 +12,7 @@ # limitations under the License. - name: Install Packetbeat - hosts: hosts + hosts: "{{ groups['packetbeat'] | default(groups['hosts']) }}" become: true vars: haproxy_ssl: false