From 1c56b7f0344b1dab9261cfbc538f70b8a7952387 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Wed, 29 Aug 2018 15:39:08 -0500 Subject: [PATCH] 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 --- .../templates/filebeat.yml.j2 | 5 +- .../roles/elastic_logstash/defaults/main.yml | 2 +- .../roles/elastic_metricbeat/tasks/main.yml | 58 +++++++++++-------- elk_metrics_6x/vars/variables.yml | 3 + 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/elk_metrics_6x/roles/elastic_filebeat/templates/filebeat.yml.j2 b/elk_metrics_6x/roles/elastic_filebeat/templates/filebeat.yml.j2 index 9844a6cf..1f074368 100644 --- a/elk_metrics_6x/roles/elastic_filebeat/templates/filebeat.yml.j2 +++ b/elk_metrics_6x/roles/elastic_filebeat/templates/filebeat.yml.j2 @@ -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 diff --git a/elk_metrics_6x/roles/elastic_logstash/defaults/main.yml b/elk_metrics_6x/roles/elastic_logstash/defaults/main.yml index ad8db767..48806712 100644 --- a/elk_metrics_6x/roles/elastic_logstash/defaults/main.yml +++ b/elk_metrics_6x/roles/elastic_logstash/defaults/main.yml @@ -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) }}" diff --git a/elk_metrics_6x/roles/elastic_metricbeat/tasks/main.yml b/elk_metrics_6x/roles/elastic_metricbeat/tasks/main.yml index e8675ec5..f0e6d267 100644 --- a/elk_metrics_6x/roles/elastic_metricbeat/tasks/main.yml +++ b/elk_metrics_6x/roles/elastic_metricbeat/tasks/main.yml @@ -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 diff --git a/elk_metrics_6x/vars/variables.yml b/elk_metrics_6x/vars/variables.yml index d2449a68..193dcab3 100644 --- a/elk_metrics_6x/vars/variables.yml +++ b/elk_metrics_6x/vars/variables.yml @@ -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