634bf0357e
Change-Id: I5316d359c2c334c588b048d877410273782a90f1 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
207 lines
5.3 KiB
YAML
207 lines
5.3 KiB
YAML
---
|
|
- name: Install Metricsbeat
|
|
hosts: all
|
|
become: true
|
|
vars:
|
|
haproxy_ssl: false
|
|
|
|
environment: "{{ deployment_environment_variables | default({}) }}"
|
|
|
|
vars_files:
|
|
- vars/variables.yml
|
|
|
|
pre_tasks:
|
|
- include_tasks: common_task_data_node_hosts.yml
|
|
tags:
|
|
- always
|
|
|
|
tasks:
|
|
- include_tasks: common_task_install_elk_repo.yml
|
|
|
|
- name: Ensure Metricsbeat is installed
|
|
apt:
|
|
name: metricbeat
|
|
state: "{{ elk_package_state | default('present') }}"
|
|
update_cache: true
|
|
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/sites-available
|
|
register: apache2
|
|
|
|
- name: Check for ceph
|
|
stat:
|
|
path: /etc/ceph
|
|
register: ceph
|
|
|
|
# gather ceph stats from localhost
|
|
# except when a list of mons is provided
|
|
- name: Set ceph stats hosts
|
|
set_fact:
|
|
ceph_stats_hosts: |-
|
|
{% set ceph_stats = [] %}
|
|
{% if (ceph_mons is defined) and (ceph_mons | length > 0) %}
|
|
{% for mon in ceph_mons %}
|
|
{% set _ = ceph_stats.insert(loop.index, (mon + ":5000")) %}
|
|
{% endfor %}
|
|
{% else %}
|
|
{% set ceph_stats = [ ansible_hostname + ":5000" ] %}
|
|
{% endif %}
|
|
{{ ceph_stats }}
|
|
|
|
- name: Check for etcd
|
|
stat:
|
|
path: /etc/etcd
|
|
register: etcd
|
|
|
|
- name: Check for docker
|
|
stat:
|
|
path: /var/run/docker.sock
|
|
register: docker
|
|
|
|
- name: Check for haproxy
|
|
stat:
|
|
path: /etc/haproxy
|
|
register: haproxy
|
|
|
|
- name: Check for httpd
|
|
stat:
|
|
path: /etc/httpd
|
|
register: httpd
|
|
|
|
- name: Check for kvm
|
|
stat:
|
|
path: /var/run/libvirt/libvirt-sock
|
|
register: kvm
|
|
|
|
- name: Check for memcached
|
|
stat:
|
|
path: /etc/memcached.conf
|
|
register: memcached
|
|
|
|
- name: Check for mysql
|
|
stat:
|
|
path: /var/lib/mysql
|
|
register: mysql
|
|
|
|
- name: Check for nginx
|
|
stat:
|
|
path: /etc/nginx/nginx.conf
|
|
register: nginx
|
|
|
|
- name: Check for rabbitmq
|
|
stat:
|
|
path: /var/lib/rabbitmq
|
|
register: rabbitmq
|
|
|
|
- name: Check for uwsgi
|
|
stat:
|
|
path: /etc/uwsgi
|
|
register: uwsgi
|
|
|
|
- name: Check for uwsgi stats sockets
|
|
find:
|
|
paths: /tmp
|
|
file_type: any
|
|
patterns: '*uwsgi-stats.sock'
|
|
register: uwsgi_find_sockets
|
|
|
|
- name: Set discovery facts
|
|
set_fact:
|
|
apache_enabled: "{{ (apache2.stat.exists | bool) or (httpd.stat.exists | bool) }}"
|
|
|
|
# enable ceph on: cinder volume hosts when we have a list of ceph mons
|
|
# otherwise: all hosts which have /etc/ceph
|
|
ceph_enabled: |-
|
|
{% set ceph_detect = false %}
|
|
{% if (ceph_mons is defined) and (ceph_mons | length > 0) and (inventory_hostname in groups['cinder_volume']) %}
|
|
{% set ceph_detect = true %}
|
|
{% else %}
|
|
{% set ceph_detect = ceph.stat.exists | bool %}
|
|
{% endif %}
|
|
{{ ceph_detect }}
|
|
|
|
docker_enabled: "{{ docker.stat.exists | bool }}"
|
|
etcd_enabled: "{{ etcd.stat.exists | bool }}"
|
|
haproxy_enabled: "{{ haproxy.stat.exists | bool }}"
|
|
kvm_enabled: "{{ kvm.stat.exists | bool }}"
|
|
memcached_enabled: "{{ memcached.stat.exists | bool }}"
|
|
mysql_enabled: "{{ mysql.stat.exists | bool }}"
|
|
nginx_enabled: "{{ nginx.stat.exists | bool }}"
|
|
rabbitmq_enabled: "{{ rabbitmq.stat.exists | bool }}"
|
|
uwsgi_enabled: "{{ uwsgi.stat.exists | bool }}"
|
|
uwsgi_sockets: "{{ uwsgi_find_sockets }}"
|
|
|
|
# Apache 2 stats enablement
|
|
- name: Drop apache2 stats site config
|
|
template:
|
|
src: apache-status.conf.j2
|
|
dest: /etc/apache2/sites-available/apache-status.conf
|
|
when: apache_enabled
|
|
|
|
- name: Enable apache2 stats site
|
|
file:
|
|
src: /etc/apache2/sites-available/apache-status.conf
|
|
dest: /etc/apache2/sites-enabled/apache-status.conf
|
|
state: link
|
|
when: apache_enabled
|
|
|
|
- name: Ensure apache2 stats mode is enabled
|
|
apache2_module:
|
|
name: status
|
|
state: present
|
|
when: apache_enabled
|
|
|
|
- name: Reload apache2
|
|
service:
|
|
name: apache2
|
|
state: reloaded
|
|
when: apache_enabled
|
|
|
|
# NGINX stats enablement
|
|
- name: Drop nginx stats site config
|
|
template:
|
|
src: nginx-status.conf.j2
|
|
dest: /etc/nginx/sites-available/nginx-status.conf
|
|
when: nginx_enabled
|
|
|
|
- name: Enable nginx stats site
|
|
file:
|
|
src: /etc/nginx/sites-available/nginx-status.conf
|
|
dest: /etc/nginx/sites-enabled/nginx-status.conf
|
|
state: link
|
|
when: nginx_enabled
|
|
|
|
- name: Reload nginx
|
|
service:
|
|
name: nginx
|
|
state: reloaded
|
|
when: nginx_enabled
|
|
|
|
post_tasks:
|
|
- name: Drop metricbeat conf file
|
|
template:
|
|
src: templates/metricbeat.yml.j2
|
|
dest: /etc/metricbeat/metricbeat.yml
|
|
|
|
- name: Enable and restart metricbeat
|
|
systemd:
|
|
name: "metricbeat"
|
|
enabled: true
|
|
state: restarted
|
|
tags:
|
|
- beat-install
|
|
|
|
- import_playbook: setupMetricbeat.yml
|