--- - 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 - name: Verify a load balancer was found assert: that: es_lbs.json | length > 0 quiet: true fail_msg: 'No ElasticSearch LB found!' - 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 owner: www-data group: www-data recurse: true 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 - 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'