Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions molecule/beats_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
collections:
- netways.elasticstack
vars:
elasticstack_ci: true
elasticstack_full_stack: false
elasticsearch_jna_workaround: true
elasticsearch_disable_systemcallfilterchecks: true
Expand Down
1 change: 1 addition & 0 deletions molecule/beats_extended/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
collections:
- netways.elasticstack
vars:
elasticstack_ci: true
beats_filebeat_log_inputs:
messages:
name: messages
Expand Down
1 change: 1 addition & 0 deletions molecule/elasticsearch_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions molecule/elasticsearch_roles_calculation/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
1 change: 1 addition & 0 deletions molecule/elasticstack_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- netways.elasticstack
hosts: all
vars:
elasticstack_ci: true
elasticsearch_jna_workaround: true
elasticsearch_disable_systemcallfilterchecks: true
elasticsearch_monitoring_enabled: false
Expand Down
1 change: 1 addition & 0 deletions molecule/kibana_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions molecule/logstash_pinned_version/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
collections:
- netways.elasticstack
vars:
elasticstack_ci: true
logstash_manage_logging: true
logstash_logging_console: false
logstash_logging_slow_file: false
Expand Down
1 change: 1 addition & 0 deletions molecule/logstash_pipelines/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
collections:
- netways.elasticstack
vars:
elasticstack_ci: true
logstash_enable: true
logstash_pipelines:
- name: syslog
Expand Down
1 change: 1 addition & 0 deletions molecule/plugins/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- netways.elasticstack
hosts: all
vars:
elasticstack_ci: true
elasticstack_full_stack: false
elasticsearch_jna_workaround: true
elasticsearch_disable_systemcallfilterchecks: true
Expand Down
1 change: 1 addition & 0 deletions molecule/repos_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
1 change: 1 addition & 0 deletions molecule/repos_oss/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
2 changes: 1 addition & 1 deletion roles/beats/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion roles/elasticsearch/tasks/elasticsearch-security.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---

- name: Ensure ca exists

Check warning on line 3 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_collection / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_ca_exists)

Check warning on line 3 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_ca_exists)

Check warning on line 3 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_ca_exists)
ansible.builtin.stat:
path: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12"
register: elasticstack_ca_exists
when: inventory_hostname == elasticstack_ca_host

- name: Get CA informations

Check warning on line 9 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_collection / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_ca_infos)

Check warning on line 9 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_ca_infos)

Check warning on line 9 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_ca_infos)
cert_info:
path: "{{ elasticstack_ca_dir }}/elastic-stack-ca.p12"
passphrase: "{{ elasticstack_ca_pass | default(omit, true) }}"
register: elasticstack_ca_infos
when: inventory_hostname == elasticstack_ca_host and elasticstack_ca_exists.stat.exists | bool

- name: Set the ca expiration date in days

Check warning on line 16 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_collection / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (set_fact: elasticstack_ca_expiration_days)

Check warning on line 16 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (set_fact: elasticstack_ca_expiration_days)

Check warning on line 16 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (set_fact: elasticstack_ca_expiration_days)
ansible.builtin.set_fact:
elasticstack_ca_expiration_days: "{{ ((elasticstack_ca_infos.not_valid_after | to_datetime()) - (ansible_date_time.date | to_datetime('%Y-%m-%d'))).days }}"
when: inventory_hostname == elasticstack_ca_host and elasticstack_ca_infos.skipped is not defined

- name: Set ca will expire soon to true

Check warning on line 21 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_collection / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (set_fact: elasticstack_ca_will_expire_soon)

Check warning on line 21 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (set_fact: elasticstack_ca_will_expire_soon)

Check warning on line 21 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (set_fact: elasticstack_ca_will_expire_soon)
ansible.builtin.set_fact:
elasticstack_ca_will_expire_soon: true
when: >
Expand Down Expand Up @@ -58,7 +58,7 @@
register: elasticsearch_check_ca_path

- name: Move the ca directory on elasticsearch ca host
ansible.builtin.copy:

Check warning on line 61 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / security_scan

[INFO] Risky File Permissions

Some modules could end up creating new files on disk with permissions that might be too open or unpredictable
src: "{{ elasticstack_ca_dir }}"
dest: "{{ elasticstack_ca_dir }}_{{ ansible_date_time.iso8601_micro }}"
mode: preserve
Expand All @@ -80,7 +80,7 @@
become: false

- name: Move temporary ca file on Ansible controller
ansible.builtin.copy:

Check warning on line 83 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / security_scan

[INFO] Risky File Permissions

Some modules could end up creating new files on disk with permissions that might be too open or unpredictable
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt_{{ ansible_date_time.iso8601_micro }}"
mode: preserve
Expand Down Expand Up @@ -165,7 +165,7 @@
register: elasticsearch_check_cert_file

- name: Move cert file on elasticstack_ca_host
ansible.builtin.copy:

Check warning on line 168 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / security_scan

[INFO] Risky File Permissions

Some modules could end up creating new files on disk with permissions that might be too open or unpredictable
src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12"
dest: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}.p12_{{ ansible_date_time.iso8601_micro }}"
mode: preserve
Expand Down Expand Up @@ -193,7 +193,7 @@
register: elasticsearch_check_temporary_cert

- name: Move temporary cert on Ansible controller
ansible.builtin.copy:

Check warning on line 196 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / security_scan

[INFO] Risky File Permissions

Some modules could end up creating new files on disk with permissions that might be too open or unpredictable
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}.p12"
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}.p12_{{ ansible_date_time.iso8601_micro }}"
mode: preserve
Expand Down Expand Up @@ -433,7 +433,7 @@
retries: 5
delay: 10

- name: Fetch Elastic password # noqa: risky-shell-pipe

Check warning on line 436 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_collection / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_password)

Check warning on line 436 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_password)

Check warning on line 436 in roles/elasticsearch/tasks/elasticsearch-security.yml

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

var-naming[no-role-prefix]

Variables names from within roles should use elasticsearch_ as a prefix. (register: elasticstack_password)
ansible.builtin.shell: >
if test -n "$(ps -p $$ | grep bash)"; then set -o pipefail; fi;
grep "PASSWORD elastic" {{ elasticstack_initial_passwords }} |
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -268,7 +268,7 @@
- name: Check for cluster status without security
ansible.builtin.uri:
# kics-scan ignore-line
url: "http://{{ elasticsearch_api_host }}:{{ elasticstack_elasticsearch_http_port }}/_cluster/health?pretty"

Check warning on line 271 in roles/elasticsearch/tasks/main.yml

View workflow job for this annotation

GitHub Actions / security_scan

[MEDIUM] Communication Over HTTP

Using HTTP URLs (without encryption) could lead to security vulnerabilities and risks
register: elasticsearch_cluster_status
ignore_errors: "{{ ansible_check_mode }}"
until: elasticsearch_cluster_status.json.status == "green"
Expand Down
1 change: 1 addition & 0 deletions roles/elasticstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

<!-- ANSIBLE DOCSMITH MAIN END -->
3 changes: 3 additions & 0 deletions roles/elasticstack/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions roles/elasticstack/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion roles/kibana/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion roles/logstash/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading