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
31 changes: 31 additions & 0 deletions roles/beats/tasks/auditbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
string ) if (elasticstack_version is defined and elasticstack_version | length > 0)) |
replace(' ', '')
}}
tags:
- auditbeat
- name

- name: Install Auditbeat - rpm - full stack
ansible.builtin.package:
Expand All @@ -21,6 +24,9 @@
when:
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool
tags:
- auditbeat
- rpm

- name: Install Auditbeat - rpm - standalone
ansible.builtin.package:
Expand All @@ -30,6 +36,10 @@
when:
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool
tags:
- auditbeat
- standalone
- rpm

- name: Install Auditbeat - deb
ansible.builtin.package:
Expand All @@ -38,6 +48,9 @@
- Restart Auditbeat
when:
- ansible_os_family == "Debian"
tags:
- auditbeat
- deb

# KICS complains about "latest" package but this is a dedicated update task

Expand All @@ -55,11 +68,15 @@
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- elasticstack_full_stack | bool
tags:
- auditbeat
- fullstack
- rpm

- name: Install Auditbeat latest version - rpm - standalone
ansible.builtin.package:
name: auditbeat
state: latest

Check warning on line 79 in roles/beats/tasks/auditbeat.yml

View workflow job for this annotation

GitHub Actions / kics

[LOW] Unpinned Package Version

Setting state to latest performs an update and installs additional packages possibly resulting in performance degradation or loss of service
notify:
- Restart Auditbeat
when:
Expand All @@ -67,17 +84,25 @@
- elasticstack_version == "latest"
- ansible_os_family == "RedHat"
- not elasticstack_full_stack | bool
tags:
- auditbeat
- latest
- rpm

- name: Install Auditbeat latest version - deb
ansible.builtin.package:
name: auditbeat
state: latest

Check warning on line 95 in roles/beats/tasks/auditbeat.yml

View workflow job for this annotation

GitHub Actions / kics

[LOW] Unpinned Package Version

Setting state to latest performs an update and installs additional packages possibly resulting in performance degradation or loss of service
notify:
- Restart Auditbeat
when:
- elasticstack_version is defined
- elasticstack_version == "latest"
- ansible_os_family == "Debian"
tags:
- auditbeat
- latest
- deb

- name: Configure Auditbeat
ansible.builtin.template:
Expand Down Expand Up @@ -105,10 +130,16 @@
when:
- beats_auditbeat_setup | bool
- beats_auditbeat_output == "elasticsearch"
tags:
- auditbeat
- setup

- name: Start Auditbeat
ansible.builtin.service:
name: auditbeat
state: started
enabled: true
when: beats_auditbeat_enable | bool
tags:
- auditbeat
- start
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
1 change: 1 addition & 0 deletions roles/kibana/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ kibana_cert_validity_period: 1095
kibana_cert_will_expire_soon: false
kibana_sniff_on_start: false
kibana_sniff_on_connection_fault: false
kibana_custom_default_index: 979390d0-3def-11ea-ad1f-5b09c073c7d3

kibana_freshstart:
changed: false
16 changes: 16 additions & 0 deletions roles/kibana/tasks/kibana-default-index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

- name: Set Custom Default Index
ansible.builtin.uri:
url: 'http://{{ ansible_default_ipv4.address }}:5601/api/kibana/settings'

Check warning on line 5 in roles/kibana/tasks/kibana-default-index.yml

View workflow job for this annotation

GitHub Actions / kics

[MEDIUM] Communication Over HTTP

Using HTTP URLs (without encryption) could lead to security vulnerabilities and risks

Check warning

Code scanning / KICS

Communication Over HTTP Warning

ansible.builtin.uri.url is accessed via the HTTP protocol'
method: POST
body:
changes:
defaultIndex: '{{ kibana_custom_default_index }}'
body_format: json
headers:
kbn-version: 8.19.11
Content-Type: application/json
register: result
- ansible.builtin.debug:
msg: "setting new custom Index to {{ kibana_custom_default_index }}"
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"
- ansible.builtin.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"
- ansible.builtin.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