Add option block to ensure apache2 is enabled correctly

The apache2 monitoring process requires a couple interactions to deploy
successfully. This change will ensure that if the apache2 monitoring
fails, in any way, it does not block the deployment.

Change-Id: Ibe35197a1c65f4abe9e4870c07ee15f37f9a58ab
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-08-29 15:39:08 -05:00
parent 111fda8d87
commit 1c56b7f034
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
4 changed files with 41 additions and 27 deletions

View File

@ -249,7 +249,7 @@ filebeat.modules:
#------------------------------- Osquery Module ------------------------------
- module: osquery
result:
enabled: {{ osquery_enabled | bool }}
enabled: {{ osquery_enabled | bool }}
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
@ -258,8 +258,7 @@ filebeat.modules:
# If true, all fields created by this module are prefixed with
# `osquery.result`. Set to false to copy the fields in the root
# of the document. The default is true.
# NOTE(cloudull): This option is commented out because it is broken
#var.use_namespace: true
var.use_namespace: true
#----------------------------- PostgreSQL Module -----------------------------
#- module: postgresql

View File

@ -17,7 +17,7 @@ temp_dir: /var/lib/logstash/tmp
logstash_pipelines: "{{lookup('template', 'logstash-pipelines.yml.j2') }}"
# Set processor cores fact
q_storage: "{{ (ansible_processor_count | int) * (ansible_processor_threads_per_core | int) * 2 }}"
q_storage: 1
# Set logstash facts
logstash_queue_size: "{{ ((((q_storage | int) >= 2) | ternary(q_storage, 2) | int) * 1024) // ((logstash_pipelines | from_yaml) | length) }}"

View File

@ -157,33 +157,45 @@
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
block:
- name: Drop apache2 stats site config
template:
src: apache-status.conf.j2
dest: /etc/apache2/sites-available/apache-status.conf
- 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: Enable apache2 stats site
file:
src: /etc/apache2/sites-available/apache-status.conf
dest: /etc/apache2/sites-enabled/apache-status.conf
state: link
- name: Ensure apache2 stats mode is enabled
apache2_module:
name: status
state: present
register: apache_status_mod
when: apache_enabled
- name: Ensure apache2 stats mode is enabled
apache2_module:
name: status
state: present
register: apache_status_mod
- name: Reload apache2
service:
name: apache2
state: reloaded
- name: Reload apache2
service:
name: apache2
state: reloaded
when:
- apache_status_mod is changed
rescue:
- name: Apache2 monitoring not enabled
debug:
msg: >-
The apache2 module was not enabled because of an error within the
enablement process. Check the host to ensure apache2 is really
available and resolve the noted errors before continuing.
- name: Disable apache2 check
set_fact:
apache_enabled: false
when:
- apache_enabled
- apache_status_mod is changed
- apache_enabled | bool
# NGINX stats enablement
- name: Drop nginx stats site config

View File

@ -5,6 +5,9 @@ q_mem: "{{ (ansible_memtotal_mb | int) // 3 }}"
# Option to define half memory
h_mem: "{{ (ansible_memtotal_mb | int) // 2 }}"
# Option to set persistent queue storage in gigabytes
q_storage: "{{ (ansible_processor_count | int) * (ansible_processor_threads_per_core | int) * 2 }}"
apm_port: 8200
elastic_port: 9200
elastic_hap_port: 9201