d98fec1a54
* install osquery * add filebeat integration Change-Id: Ia93595482512460ebdd287cf091cb5fe51b00de4
167 lines
6.1 KiB
YAML
167 lines
6.1 KiB
YAML
---
|
|
- name: Install Filebeat
|
|
hosts: hosts
|
|
become: true
|
|
vars:
|
|
haproxy_ssl: false
|
|
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
pre_tasks:
|
|
- include_tasks: common_task_data_node_hosts.yml
|
|
tags:
|
|
- always
|
|
|
|
tasks:
|
|
- include_tasks: common_task_install_elk_repo.yml
|
|
|
|
- name: Ensure Filebeat is installed
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
update_cache: true
|
|
with_items:
|
|
- filebeat
|
|
register: _apt_task
|
|
until: _apt_task is success
|
|
retries: 3
|
|
delay: 2
|
|
tags:
|
|
- package_install
|
|
|
|
- name: exit playbook after uninstall
|
|
meta: end_play
|
|
when:
|
|
- elk_package_state | default('present') == 'absent'
|
|
|
|
- name: Check for apache
|
|
stat:
|
|
path: /etc/apache2
|
|
register: apache2
|
|
|
|
- name: Check for auditd
|
|
stat:
|
|
path: /etc/audit
|
|
register: audit
|
|
|
|
- name: Check for ceph
|
|
stat:
|
|
path: /var/log/ceph
|
|
register: ceph
|
|
|
|
- name: Check for cinder
|
|
stat:
|
|
path: /var/log/cinder
|
|
register: cinder
|
|
|
|
- name: Check for glance
|
|
stat:
|
|
path: /var/log/glance
|
|
register: glance
|
|
|
|
- name: Check for heat
|
|
stat:
|
|
path: /var/log/heat
|
|
register: heat
|
|
|
|
- name: Check for horizon
|
|
stat:
|
|
path: /var/log/horizon
|
|
register: horizon
|
|
|
|
- name: Check for httpd
|
|
stat:
|
|
path: /var/log/httpd
|
|
register: httpd
|
|
|
|
- name: Check for keystone
|
|
stat:
|
|
path: /var/log/keystone
|
|
register: keystone
|
|
|
|
- name: Check for mysql
|
|
stat:
|
|
path: /var/lib/mysql
|
|
register: mysql
|
|
|
|
- name: Check for neutron
|
|
stat:
|
|
path: /var/log/neutron
|
|
register: neutron
|
|
|
|
- name: Check for nginx
|
|
stat:
|
|
path: /var/log/nginx
|
|
register: nginx
|
|
|
|
- name: Check for nova
|
|
stat:
|
|
path: /var/log/nova
|
|
register: nova
|
|
|
|
- name: Check for octavia
|
|
stat:
|
|
path: /var/log/octavia
|
|
register: octavia
|
|
|
|
- name: Check for swift
|
|
stat:
|
|
path: /var/log/swift
|
|
register: swift
|
|
|
|
- name: Check for rabbitmq
|
|
stat:
|
|
path: /var/lib/rabbitmq
|
|
register: rabbitmq
|
|
|
|
- name: Check for designate
|
|
stat:
|
|
path: /var/log/designate
|
|
register: designate
|
|
|
|
- name: Check for osquery
|
|
stat:
|
|
path: /var/log/osquery/osqueryd.results.log
|
|
register: osquery
|
|
|
|
- name: Set discovery facts
|
|
set_fact:
|
|
apache_enabled: "{{ (apache2.stat.exists | bool) or (httpd.stat.exists | bool) }}"
|
|
nginx_enabled: "{{ nginx.stat.exists | bool }}"
|
|
auditd_enabled: "{{ audit.stat.exists | bool }}"
|
|
mysql_enabled: "{{ (mysql.stat.exists | bool) or (inventory_hostname in groups['galera_all'] | default([])) }}"
|
|
ceph_enabled: "{{ (ceph.stat.exists | bool) or (inventory_hostname in groups['ceph_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*ceph.*') | list | length) > 0) }}"
|
|
cinder_enabled: "{{ (cinder.stat.exists | bool) or (inventory_hostname in groups['cinder_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*cinder.*') | list | length) > 0) }}"
|
|
glance_enabled: "{{ (glance.stat.exists | bool) or (inventory_hostname in groups['glance_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*glance.*') | list | length) > 0) }}"
|
|
heat_enabled: "{{ (heat.stat.exists | bool) or (inventory_hostname in groups['heat_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*heat.*') | list | length) > 0) }}"
|
|
horizon_enabled: "{{ (horizon.stat.exists | bool) or (inventory_hostname in groups['horizon_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*horizon.*') | list | length) > 0) }}"
|
|
keystone_enabled: "{{ (keystone.stat.exists | bool) or (inventory_hostname in groups['keystone_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*keystone.*') | list | length) > 0) }}"
|
|
neutron_enabled: "{{ (neutron.stat.exists | bool) or (inventory_hostname in groups['neutron_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*neutron.*') | list | length) > 0) }}"
|
|
nova_enabled: "{{ (nova.stat.exists | bool) or (inventory_hostname in groups['nova_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*nova.*') | list | length) > 0) }}"
|
|
octavia_enabled: "{{ (octavia.stat.exists | bool) or (inventory_hostname in groups['octavia_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*octavia.*') | list | length) > 0) }}"
|
|
swift_enabled: "{{ (swift.stat.exists | bool) or (inventory_hostname in groups['swift_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*swift.*') | list | length) > 0) }}"
|
|
rabbitmq_enabled: "{{ (rabbitmq.stat.exists | bool) or (inventory_hostname in groups['rabbitmq_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*rabbit.*') | list | length) > 0) }}"
|
|
designate_enabled: "{{ (designate.stat.exists | bool) or (inventory_hostname in groups['designate_all'] | default([])) or (((groups[inventory_hostname + '-host_containers'] | default([])) | select('match', '.*designate.*') | list | length) > 0) }}"
|
|
osquery_enabled: "{{ osquery.stat.exists | bool }}"
|
|
|
|
|
|
post_tasks:
|
|
- name: Drop Filebeat conf file
|
|
template:
|
|
src: templates/filebeat.yml.j2
|
|
dest: /etc/filebeat/filebeat.yml
|
|
|
|
- name: Enable and restart Filebeat
|
|
systemd:
|
|
name: "filebeat"
|
|
enabled: true
|
|
state: restarted
|
|
|
|
tags:
|
|
- beat-install
|
|
|
|
- import_playbook: setupFilebeat.yml
|