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

Prevent double encryption #1176

Open
wants to merge 4 commits into
base: stackhpc/2023.1
Choose a base branch
from
Open
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions etc/kayobe/ansible/wazuh-secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,45 @@
path: "{{ wazuh_secrets_path | dirname }}"
state: directory

- name: Check whether wazuh-secrets.yml exists
stat:
path: "{{ wazuh_secrets_path }}"
register: waz_exist_result

- name: Decrypt wazuh-secrets to checksum
no_log: True
copy:
content: "{{ lookup('ansible.builtin.file', wazuh_secrets_path) | ansible.builtin.vault(ansible_vault_password) }}"
dest: "{{ wazuh_secrets_path }}"
decrypt: true
vars:
ansible_vault_password: "{{ lookup('ansible.builtin.env', 'KAYOBE_VAULT_PASSWORD') }}"
when: waz_exist_result.stat.exists

- name: Template new secrets
no_log: True
template:
src: wazuh-secrets.yml.j2
dest: "/tmp/wazuh-secrets.yml"
when: waz_exist_result.stat.exists

- name: Copy for checksum
no_log: True
copy:
content: "{{ lookup('ansible.builtin.file', '/tmp/wazuh-secrets.yml') }}"
dest: "{{ wazuh_secrets_path }}"
checksum: yes
when: waz_exist_result.stat.exists
MaxBed4d marked this conversation as resolved.
Show resolved Hide resolved

- name: Template new secrets
no_log: True
template:
src: wazuh-secrets.yml.j2
dest: "{{ wazuh_secrets_path }}"
when: not waz_exist_result.stat.exists

- name: In-place encrypt wazuh-secrets
no_log: True
copy:
content: "{{ lookup('ansible.builtin.file', wazuh_secrets_path) | ansible.builtin.vault(ansible_vault_password) }}"
dest: "{{ wazuh_secrets_path }}"
Expand Down