2019-04-17 17:25:11 +00:00
|
|
|
---
|
|
|
|
- name: Make sure python3 is installed
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- python3
|
|
|
|
- python3-pip
|
|
|
|
|
|
|
|
- name: Install ElasticSearch python module
|
|
|
|
pip:
|
|
|
|
name: elasticsearch
|
|
|
|
executable: pip3
|
|
|
|
|
|
|
|
- name: Find out the name of ES load balancer
|
|
|
|
uri:
|
|
|
|
url: '{{ consul_query_url }}'
|
|
|
|
register: es_lbs
|
|
|
|
|
2020-02-19 10:51:09 +00:00
|
|
|
- name: Verify a load balancer was found
|
|
|
|
assert:
|
|
|
|
that: es_lbs.json | length > 0
|
|
|
|
quiet: true
|
|
|
|
fail_msg: 'No ElasticSearch LB found!'
|
|
|
|
|
2019-04-17 17:25:11 +00:00
|
|
|
- name: Install stat collecting script
|
|
|
|
copy:
|
|
|
|
src: collect.py
|
|
|
|
dest: '{{ nimbus_stats_script }}'
|
|
|
|
mode: 0755
|
|
|
|
register: nimbus_script
|
|
|
|
|
|
|
|
- name: Create www directory
|
|
|
|
file:
|
|
|
|
path: '{{ nimbus_stats_web_root }}'
|
|
|
|
state: directory
|
2020-02-19 10:51:09 +00:00
|
|
|
owner: www-data
|
2019-04-17 17:25:11 +00:00
|
|
|
group: www-data
|
2020-02-19 10:51:09 +00:00
|
|
|
recurse: true
|
2019-04-17 17:25:11 +00:00
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: Create nginx config
|
|
|
|
template:
|
|
|
|
src: proxy.conf.j2
|
|
|
|
dest: '/etc/nginx/sites-available/{{ nimbus_stats_domain | mandatory }}.conf'
|
|
|
|
notify:
|
|
|
|
- reload nginx
|
|
|
|
|
|
|
|
- name: Enable site
|
|
|
|
file:
|
|
|
|
src: '/etc/nginx/sites-available/{{ nimbus_stats_domain | mandatory }}.conf'
|
|
|
|
dest: '/etc/nginx/sites-enabled/{{ nimbus_stats_domain | mandatory }}.conf'
|
|
|
|
state: link
|
|
|
|
|
|
|
|
- name: Enable HTTPS port
|
|
|
|
iptables:
|
|
|
|
comment: 'HTTPS'
|
|
|
|
chain: INPUT
|
|
|
|
jump: ACCEPT
|
|
|
|
source: '0.0.0.0/0'
|
|
|
|
protocol: tcp
|
|
|
|
destination_port: 443
|
|
|
|
notify:
|
|
|
|
- Save iptables rules
|
|
|
|
|
2020-02-19 10:51:09 +00:00
|
|
|
- name: Set systemd timer
|
|
|
|
include_role: name=systemd-timer
|
|
|
|
vars:
|
|
|
|
systemd_timer_name: '{{ nimbus_stats_service_name }}'
|
|
|
|
systemd_timer_description: 'Generates stats for Nimbus cluster.'
|
|
|
|
systemd_timer_user: 'www-data'
|
|
|
|
systemd_timer_frequency: '*:0/5' # every 5 minutes
|
|
|
|
systemd_timer_timeout_sec: 120
|
|
|
|
systemd_timer_requires_extra: 'network.target'
|
|
|
|
systemd_timer_script_content: |
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
exec {{ nimbus_stats_script }} \
|
|
|
|
-H {{ es_lbs.json[0].ServiceAddress }} \
|
|
|
|
-o {{ nimbus_stats_json }}
|
|
|
|
|
|
|
|
- name: Run the script before Nginx configuration
|
|
|
|
systemd:
|
|
|
|
name: '{{ nimbus_stats_service_name }}'
|
|
|
|
state: 'started'
|