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
2 changes: 1 addition & 1 deletion molecule/elasticstack_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- name: Enable Elastic installation on RHEL 9
ansible.builtin.set_fact:
elasticstack_rpm_workaround: true
when: ansible_facts.os_family == 'RedHat' and ansible_facts.distribution_major_version >= "9"
when: ansible_facts.os_family == 'RedHat' and ansible_facts.distribution_major_version | int >= 9
- name: Include Elastic Repos
ansible.builtin.include_role:
name: oddly.elasticstack.repos
Expand Down
2 changes: 2 additions & 0 deletions roles/beats/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ beats_tls_key: "{{ beats_ca_dir }}/{{ inventory_hostname }}-beats.key"
beats_tls_cert: "{{ beats_ca_dir }}/{{ inventory_hostname }}-beats.crt"
# @var beats_tls_cacert:description: Path to the CA certificate for TLS verification
beats_tls_cacert: "{{ beats_ca_dir }}/ca.crt"
# @var beats_ssl_verification_mode:description: SSL verification mode for Beats output to Elasticsearch (full, certificate, none)
beats_ssl_verification_mode: certificate
# @var beats_tls_key_passphrase:description: Passphrase for the Beat TLS private key
beats_tls_key_passphrase: BeatsChangeMe

Expand Down
2 changes: 1 addition & 1 deletion roles/beats/templates/auditbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ output.elasticsearch:
username: "elastic"
password: "{{ beats_writer_password.stdout }}"
ssl.enabled: true
ssl.verification_mode: none
ssl.verification_mode: {{ beats_ssl_verification_mode }}
ssl.certificate_authorities: ["/etc/beats/certs/ca.crt"]
{% else %}
{% if elasticstack_full_stack | bool %}
Expand Down
2 changes: 1 addition & 1 deletion roles/beats/templates/filebeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ output.elasticsearch:
username: "elastic"
password: "{{ beats_writer_password.stdout }}"
ssl.enabled: true
ssl.verification_mode: none
ssl.verification_mode: {{ beats_ssl_verification_mode }}
ssl.certificate_authorities: ["/etc/beats/certs/ca.crt"]
{% else %}
{% if elasticstack_full_stack | bool %}
Expand Down
2 changes: 1 addition & 1 deletion roles/beats/templates/metricbeat.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ output.elasticsearch:
username: "elastic"
password: "{{ beats_writer_password.stdout }}"
ssl.enabled: true
ssl.verification_mode: none
ssl.verification_mode: {{ beats_ssl_verification_mode }}
ssl.certificate_authorities: ["/etc/beats/certs/ca.crt"]
{% else %}
{% if elasticstack_full_stack | bool %}
Expand Down
2 changes: 2 additions & 0 deletions roles/elasticsearch/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ elasticsearch_logging_json_file: true
elasticsearch_logging_slowlog: true
# @var elasticsearch_logging_deprecation:description: Enable deprecation log appender
elasticsearch_logging_deprecation: true
# @var elasticsearch_logging_audit:description: Enable security audit log appender. Only meaningful when elasticsearch_security is true
elasticsearch_logging_audit: true

# @var elasticsearch_security:description: Enable Elasticsearch security features (TLS, authentication, RBAC)
elasticsearch_security: true
Expand Down
7 changes: 6 additions & 1 deletion roles/elasticsearch/tasks/elasticsearch-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@

# Extract CA chain from the already-deployed transport cert on the node.
# Uses copy+content for idempotency (only writes when content changes).
- name: Read CA chain from PEM bundle (transport cert)

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

View workflow job for this annotation

GitHub Actions / lint

var-naming[no-role-prefix]

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

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

View workflow job for this annotation

GitHub Actions / lint_full / lint

var-naming[no-role-prefix]

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

Check warning on line 269 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: _extracted_ca_chain)
ansible.builtin.shell:
cmd: >-
awk '/-----BEGIN CERTIFICATE-----/{n++} n>1'
Expand Down Expand Up @@ -300,7 +300,7 @@

# -- Remove stale auto-generated P12 files from a previous elasticsearch_ca deployment --

- name: Find stale auto-generated P12 certificate files

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

View workflow job for this annotation

GitHub Actions / lint

var-naming[no-role-prefix]

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

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

View workflow job for this annotation

GitHub Actions / lint_full / lint

var-naming[no-role-prefix]

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

Check warning on line 303 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: _stale_p12_files)
ansible.builtin.find:
paths: /etc/elasticsearch/certs
patterns: "*.p12"
Expand Down Expand Up @@ -366,7 +366,7 @@
# The CA backup removes the entire elasticstack_ca_dir, which also
# contains Kibana encryption key files. If those are regenerated,
# Kibana can't decrypt its existing saved objects and enters 503.
- name: Check for Kibana encryption keys before CA backup

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

View workflow job for this annotation

GitHub Actions / lint

var-naming[no-role-prefix]

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

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

View workflow job for this annotation

GitHub Actions / lint_full / lint

var-naming[no-role-prefix]

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

Check warning on line 369 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: _kibana_enckeys_before_backup)
ansible.builtin.stat:
path: "{{ elasticstack_ca_dir }}/{{ item }}"
loop:
Expand Down Expand Up @@ -784,14 +784,19 @@
ansible.builtin.set_fact:
elasticsearch_cluster_set_up: true

- name: Create initial passwords

Check warning on line 787 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: _setup_passwords_result)
ansible.builtin.shell: >
set -o pipefail;
/usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto -b >
{{ elasticstack_initial_passwords }}
{{ elasticstack_initial_passwords }}.tmp &&
mv {{ elasticstack_initial_passwords }}.tmp {{ elasticstack_initial_passwords }}
args:
executable: /bin/bash
creates: "{{ elasticstack_initial_passwords }}"
register: _setup_passwords_result
until: _setup_passwords_result.rc | default(1) == 0
retries: 10
delay: 15
when: inventory_hostname == elasticstack_ca_host
no_log: "{{ elasticstack_no_log }}"

Expand Down
1 change: 1 addition & 0 deletions roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@

- name: Construct exact name of Elasticsearch package
ansible.builtin.set_fact:
elasticsearch_package: >-

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

View workflow job for this annotation

GitHub Actions / lint_elasticsearch / lint

jinja[spacing]

Jinja2 spacing could be improved: {{ 'elasticsearch' + ((elasticstack_versionseparator + elasticstack_version | string ) if (elasticstack_version is defined and elasticstack_version | length > 0 and elasticstack_version != 'latest') else '') | replace(' ', '') }} -> {{ 'elasticsearch' + ((elasticstack_versionseparator + elasticstack_version | string) if (elasticstack_version is defined and elasticstack_version | length > 0 and elasticstack_version != 'latest') else '') | replace(' ', '') }}
{{
'elasticsearch' +
((elasticstack_versionseparator +
Expand Down Expand Up @@ -208,6 +208,7 @@
- "hostvars[item].inventory_hostname == inventory_hostname"
- elasticstack_version is defined
- elasticstack_version != 'latest'
- ansible_facts.packages['elasticsearch'] is defined
- ansible_facts.packages['elasticsearch'][0].version is defined
- elasticstack_password.stdout is defined
- elasticstack_version is version( ansible_facts.packages['elasticsearch'][0].version, '>')
Expand Down Expand Up @@ -251,7 +252,7 @@

# Pre-detect external cert state so the template renders consistently
# across first and subsequent runs (idempotency).
- name: Detect existing external CA for template rendering

Check warning on line 255 in roles/elasticsearch/tasks/main.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: _existing_ca_cert)
ansible.builtin.stat:
path: /etc/elasticsearch/certs/ca.crt
register: _existing_ca_cert
Expand Down
2 changes: 2 additions & 0 deletions roles/elasticsearch/templates/log4j2.properties.j2
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ logger.index_indexing_slowlog.additivity = false
{% endif %}

######## Audit Log ############################################################
{% if elasticsearch_logging_audit | bool and elasticsearch_security | bool %}

appender.audit_rolling.type = RollingFile
appender.audit_rolling.name = audit_rolling
Expand Down Expand Up @@ -203,3 +204,4 @@ logger.samlxml_decrypt.name = org.opensaml.xmlsec.encryption.support.Decrypter
logger.samlxml_decrypt.level = fatal
logger.saml2_decrypt.name = org.opensaml.saml.saml2.encryption.Decrypter
logger.saml2_decrypt.level = fatal
{% endif %}
1 change: 1 addition & 0 deletions roles/logstash/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
- not ansible_check_mode
- not logstash_config_autoreload
- logstash_enable | bool
- not logstash_freshstart.changed | bool
10 changes: 0 additions & 10 deletions roles/logstash/templates/90-output.conf.j2
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{% if logstash_ident | default(true) | bool %}
filter {
mutate {
add_field => {
"{{ logstash_ident_field_name | default('[logstash][instance]') }}" => "{{ ansible_facts.hostname }}"
}
}
}

{% endif %}
output {
{% if logstash_output_elasticsearch | default(true) | bool %}
elasticsearch {
Expand Down
2 changes: 1 addition & 1 deletion roles/repos/tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- name: Workaround for EL > 8
when:
- ansible_facts.distribution_major_version >= "9"
- ansible_facts.distribution_major_version | int >= 9
block:

- name: Show a warning
Expand Down
Loading