Skip to content
Open
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 roles/elasticstack/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ elasticstack_security: true
elasticstack_variant: elastic
elasticstack_force_pip: false
elasticstack_manage_pip: false
elasticstack_encryption_key_size: 64

# for debugging only
elasticstack_no_log: true
21 changes: 18 additions & 3 deletions roles/kibana/tasks/kibana-security.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
---

- name: Ensure encryption key exists
ansible.builtin.stat:
path: "{{ elasticstack_ca_dir }}/encryption_key"
register: encryption_key_exists

- name: Ensure saved encryption key exists
ansible.builtin.stat:
path: "{{ elasticstack_ca_dir }}/savedobjects_encryption_key"
register: savedobjects_encryption_key_exists

- name: Ensure kibana certificate exists
ansible.builtin.stat:
path: "/etc/kibana/certs/{{ ansible_hostname }}-kibana.p12"
Expand Down Expand Up @@ -125,11 +135,14 @@
- name: Generate encryption key # noqa: risky-shell-pipe
ansible.builtin.shell: >
if test -n "$(ps -p $$ | grep bash)"; then set -o pipefail; fi;
openssl rand -base64 36 >
openssl rand -base64 {{ elasticstack_encryption_key_size }} >
{{ elasticstack_ca_dir }}/encryption_key
changed_when: false
args:
creates: "{{ elasticstack_ca_dir }}/encryption_key"
- debug:

Check failure on line 143 in roles/kibana/tasks/kibana-security.yml

View workflow job for this annotation

GitHub Actions / lint

fqcn[action-core]

Use FQCN for builtin module actions (debug).

Check failure on line 143 in roles/kibana/tasks/kibana-security.yml

View workflow job for this annotation

GitHub Actions / lint_full / lint

fqcn[action-core]

Use FQCN for builtin module actions (debug).
msg: "File exists..."
when: encryption_key_exists.stat.exits

- name: Fetch encryption key
ansible.builtin.command: cat {{ elasticstack_ca_dir }}/encryption_key
Expand All @@ -139,12 +152,14 @@
- name: Generate saved objects encryption key # noqa: risky-shell-pipe
ansible.builtin.shell: >
if test -n "$(ps -p $$ | grep bash)"; then set -o pipefail; fi;
openssl rand
-base64 36 >
openssl rand -base64 {{ elasticstack_encryption_key_size }} >
{{ elasticstack_ca_dir }}/savedobjects_encryption_key
changed_when: false
args:
creates: "{{ elasticstack_ca_dir }}/savedobjects_encryption_key"
- debug:

Check failure on line 160 in roles/kibana/tasks/kibana-security.yml

View workflow job for this annotation

GitHub Actions / lint

fqcn[action-core]

Use FQCN for builtin module actions (debug).

Check failure on line 160 in roles/kibana/tasks/kibana-security.yml

View workflow job for this annotation

GitHub Actions / lint_full / lint

fqcn[action-core]

Use FQCN for builtin module actions (debug).
msg: "File exists..."
when: savedobjects_encryption_key_exists.stat.exits

- name: Fetch saved objects encryption key
ansible.builtin.command: cat {{ elasticstack_ca_dir }}/savedobjects_encryption_key
Expand Down
Loading