diff --git a/molecule/beats_default/converge.yml b/molecule/beats_default/converge.yml index 8164cd84..1d984bfd 100644 --- a/molecule/beats_default/converge.yml +++ b/molecule/beats_default/converge.yml @@ -8,6 +8,7 @@ collections: - netways.elasticstack vars: + elasticstack_ci: true elasticstack_full_stack: false elasticsearch_jna_workaround: true elasticsearch_disable_systemcallfilterchecks: true diff --git a/molecule/beats_extended/converge.yml b/molecule/beats_extended/converge.yml index fd020406..449fbc5d 100644 --- a/molecule/beats_extended/converge.yml +++ b/molecule/beats_extended/converge.yml @@ -8,6 +8,7 @@ collections: - netways.elasticstack vars: + elasticstack_ci: true beats_filebeat_log_inputs: messages: name: messages diff --git a/molecule/elasticsearch_default/converge.yml b/molecule/elasticsearch_default/converge.yml index fe22e907..7d4032fd 100644 --- a/molecule/elasticsearch_default/converge.yml +++ b/molecule/elasticsearch_default/converge.yml @@ -6,6 +6,7 @@ - netways.elasticstack hosts: all vars: + elasticstack_ci: true #elasticsearch_security: true # needed for tests of > 7 releases elasticstack_full_stack: false elasticsearch_jna_workaround: true diff --git a/molecule/elasticsearch_roles_calculation/converge.yml b/molecule/elasticsearch_roles_calculation/converge.yml index dd206828..09e7df16 100644 --- a/molecule/elasticsearch_roles_calculation/converge.yml +++ b/molecule/elasticsearch_roles_calculation/converge.yml @@ -6,6 +6,7 @@ - netways.elasticstack hosts: all vars: + elasticstack_ci: true elasticsearch_jna_workaround: true elasticsearch_disable_systemcallfilterchecks: true elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}" diff --git a/molecule/elasticstack_default/converge.yml b/molecule/elasticstack_default/converge.yml index 9cb0fa04..7f5320c0 100644 --- a/molecule/elasticstack_default/converge.yml +++ b/molecule/elasticstack_default/converge.yml @@ -10,6 +10,7 @@ - netways.elasticstack hosts: all vars: + elasticstack_ci: true elasticsearch_jna_workaround: true elasticsearch_disable_systemcallfilterchecks: true elasticsearch_monitoring_enabled: false diff --git a/molecule/kibana_default/converge.yml b/molecule/kibana_default/converge.yml index 4b0f6a1e..d4b72d86 100644 --- a/molecule/kibana_default/converge.yml +++ b/molecule/kibana_default/converge.yml @@ -6,6 +6,7 @@ - name: Converge hosts: all vars: + elasticstack_ci: true elasticstack_full_stack: false elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}" elasticstack_no_log: false diff --git a/molecule/logstash_pinned_version/converge.yml b/molecule/logstash_pinned_version/converge.yml index 4c129cfd..2eda5dff 100644 --- a/molecule/logstash_pinned_version/converge.yml +++ b/molecule/logstash_pinned_version/converge.yml @@ -8,6 +8,7 @@ collections: - netways.elasticstack vars: + elasticstack_ci: true logstash_manage_logging: true logstash_logging_console: false logstash_logging_slow_file: false diff --git a/molecule/logstash_pipelines/converge.yml b/molecule/logstash_pipelines/converge.yml index 4c2c8cce..68903454 100644 --- a/molecule/logstash_pipelines/converge.yml +++ b/molecule/logstash_pipelines/converge.yml @@ -9,6 +9,7 @@ collections: - netways.elasticstack vars: + elasticstack_ci: true logstash_enable: true logstash_pipelines: - name: syslog diff --git a/molecule/plugins/converge.yml b/molecule/plugins/converge.yml index 13946437..912f2e32 100644 --- a/molecule/plugins/converge.yml +++ b/molecule/plugins/converge.yml @@ -4,6 +4,7 @@ - netways.elasticstack hosts: all vars: + elasticstack_ci: true elasticstack_full_stack: false elasticsearch_jna_workaround: true elasticsearch_disable_systemcallfilterchecks: true diff --git a/molecule/repos_default/converge.yml b/molecule/repos_default/converge.yml index 76c90b70..4d9d0ddc 100644 --- a/molecule/repos_default/converge.yml +++ b/molecule/repos_default/converge.yml @@ -4,6 +4,7 @@ collections: - netways.elasticstack vars: + elasticstack_ci: true elasticstack_rpm_workaround: true elasticstack_full_stack: false elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}" diff --git a/molecule/repos_oss/converge.yml b/molecule/repos_oss/converge.yml index a3efb7ef..e3c1b259 100644 --- a/molecule/repos_oss/converge.yml +++ b/molecule/repos_oss/converge.yml @@ -6,6 +6,7 @@ collections: - netways.elasticstack vars: + elasticstack_ci: true elasticstack_variant: oss elasticstack_rpm_workaround: true elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}" diff --git a/roles/beats/tasks/main.yml b/roles/beats/tasks/main.yml index 7739e7e5..50059a91 100644 --- a/roles/beats/tasks/main.yml +++ b/roles/beats/tasks/main.yml @@ -82,4 +82,4 @@ ansible.builtin.command: > rm -rf /var/cache/* changed_when: false - when: ansible_virtualization_type == "container" or ansible_virtualization_type == "docker" + when: elasticstack_ci | bool diff --git a/roles/elasticsearch/tasks/elasticsearch-security.yml b/roles/elasticsearch/tasks/elasticsearch-security.yml index 64803020..84f90609 100644 --- a/roles/elasticsearch/tasks/elasticsearch-security.yml +++ b/roles/elasticsearch/tasks/elasticsearch-security.yml @@ -461,7 +461,7 @@ delay: 10 - name: Work around low ressources on CI/CD nodes - when: ansible_virtualization_type == "container" or ansible_virtualization_type == "docker" + when: elasticstack_ci | bool block: # Free up some space to let elsticsearch allocate replica in GitHub Action - name: Remove cache diff --git a/roles/elasticsearch/tasks/main.yml b/roles/elasticsearch/tasks/main.yml index 37652624..fc7ff632 100644 --- a/roles/elasticsearch/tasks/main.yml +++ b/roles/elasticsearch/tasks/main.yml @@ -239,7 +239,7 @@ ansible.builtin.command: > rm -rf /var/cache/* changed_when: false - when: ansible_virtualization_type == "container" or ansible_virtualization_type == "docker" + when: elasticstack_ci | bool - name: Import Tasks elasticsearch-security.yml ansible.builtin.import_tasks: elasticsearch-security.yml diff --git a/roles/elasticstack/README.md b/roles/elasticstack/README.md index 583772a4..4e3e417b 100644 --- a/roles/elasticstack/README.md +++ b/roles/elasticstack/README.md @@ -62,5 +62,6 @@ The role runs automatically the first time any component role is applied to a ho | `elasticstack_no_log` | `bool` | `true` | — | Hide the output of tasks that could reveal passwords. Set to false for debugging. | | `elasticstack_manage_pip` | `bool` | `false` | — | Install pip on the target host. | | `elasticstack_force_pip` | `bool` | `false` | — | Force installation of the required Python modules via pip (useful when the distribution packages are too old). See PEP 668. | +| `elasticstack_ci` | `bool` | `false` | — | Internal test flag. Set to true only by the collection's molecule scenarios to enable resource workarounds needed on constrained test runners (cache cleanup, relaxed Elasticsearch disk watermarks). Never set this on a real installation. | diff --git a/roles/elasticstack/defaults/main.yml b/roles/elasticstack/defaults/main.yml index 472bbff1..4aaf3291 100644 --- a/roles/elasticstack/defaults/main.yml +++ b/roles/elasticstack/defaults/main.yml @@ -29,3 +29,6 @@ elasticstack_manage_pip: false # for debugging only elasticstack_no_log: true + +# Internal test flag: set to true by the molecule scenarios only, never on real installations +elasticstack_ci: false diff --git a/roles/elasticstack/meta/argument_specs.yml b/roles/elasticstack/meta/argument_specs.yml index 7a0d06d0..02310e13 100644 --- a/roles/elasticstack/meta/argument_specs.yml +++ b/roles/elasticstack/meta/argument_specs.yml @@ -191,3 +191,13 @@ argument_specs: description: >- Force installation of the required Python modules via pip (useful when the distribution packages are too old). See PEP 668. + + # ----- Testing ----- + elasticstack_ci: + type: bool + default: false + description: >- + Internal test flag. Set to true only by the collection's molecule + scenarios to enable resource workarounds needed on constrained test + runners (cache cleanup, relaxed Elasticsearch disk watermarks). Never + set this on a real installation. diff --git a/roles/kibana/tasks/main.yml b/roles/kibana/tasks/main.yml index 3e78d61e..bdf90f9a 100644 --- a/roles/kibana/tasks/main.yml +++ b/roles/kibana/tasks/main.yml @@ -144,4 +144,4 @@ ansible.builtin.command: > rm -rf /var/cache/* changed_when: false - when: ansible_virtualization_type == "container" or ansible_virtualization_type == "docker" + when: elasticstack_ci | bool diff --git a/roles/logstash/tasks/main.yml b/roles/logstash/tasks/main.yml index d43dc730..dbf121a1 100644 --- a/roles/logstash/tasks/main.yml +++ b/roles/logstash/tasks/main.yml @@ -317,4 +317,4 @@ ansible.builtin.command: > rm -rf /var/cache/* changed_when: false - when: ansible_virtualization_type == "container" or ansible_virtualization_type == "docker" + when: elasticstack_ci | bool