Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kibana web default tls #261

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.cache
*.swp
__pycache__*
__pycache__*
2 changes: 1 addition & 1 deletion roles/kibana/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kibana_config_backup: true
kibana_manage_yaml: true

kibana_security: true
kibana_tls: false
kibana_tls: true
kibana_tls_cert: /etc/kibana/certs/cert.pem
kibana_tls_key: /etc/kibana/certs/key.pem
kibana_tls_key_passphrase: PleaseChangeMe
Expand Down
4 changes: 4 additions & 0 deletions roles/kibana/tasks/kibana-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,7 @@
- certificates
- renew_ca
- renew_kibana_cert

- name: Create default web certificate
ansible.builtin.include_tasks: kibana-web-cert.yml
when: kibana_tls | bool
37 changes: 37 additions & 0 deletions roles/kibana/tasks/kibana-web-cert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---

- name: Check if TLS certificate exists
ansible.builtin.stat:
path: "{{ kibana_tls_cert }}"
register: cert_stat

- name: Check if TLS key exists
ansible.builtin.stat:
path: "{{ kibana_tls_key }}"
register: key_stat

- name: Generate default OpenSSL Kibana TLS key
ansible.builtin.command:
cmd: openssl genpkey -algorithm RSA -out {{ kibana_tls_key }}
when: not key_stat.stat.exists
changed_when: not key_stat.stat.exists

- name: Generate default OpenSSL Kibana TLS certificate
ansible.builtin.command:
cmd: openssl req -x509 -key {{ kibana_tls_key }} -out {{ kibana_tls_cert }} -days 3650 -nodes -subj "/CN={{ ansible_fqdn }}"
when: not cert_stat.stat.exists
changed_when: not cert_stat.stat.exists

- name: Set proper permissions for Kibana TLS certificate
ansible.builtin.file:
path: "{{ kibana_tls_cert }}"
mode: '0644'
owner: kibana
group: kibana

- name: Set proper permissions for Kibana TLS key
ansible.builtin.file:
path: "{{ kibana_tls_key }}"
mode: '0600'
owner: kibana
group: kibana