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

Conversation

MaxBed4d
Copy link
Contributor

No description provided.

@Alex-Welsh
Copy link
Contributor

Could you add a description to the PR saying what the problem is you're trying to solve?

@MaxBed4d MaxBed4d changed the title add checksum to prevent re-encryption Prevent double encryption Nov 7, 2024
@MaxBed4d MaxBed4d marked this pull request as ready for review November 7, 2024 16:47
@MaxBed4d MaxBed4d requested a review from a team as a code owner November 7, 2024 16:47
@MaxBed4d MaxBed4d requested a review from MoteHue November 7, 2024 16:48
@Alex-Welsh
Copy link
Contributor

For the record, I would approve this change but I had a hand in writing it. Can someone else approve it? Perhaps @MoteHue

Copy link
Contributor

@MoteHue MoteHue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will successfully template and encrypt wazuh-secrets.yml the first time.
But I'm seeing the second time I run it, ansible tries and fails to interpret the file:

(kayobe) ubuntu@mattc-skc-aio:~/src/kayobe-config$ kayobe playbook run etc/kayobe/ansible/wazuh-secrets.yml 
[WARNING]:  * Failed to parse /home/ubuntu/venvs/kayobe/share/kayobe/ansible/inventory/hosts with yaml plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)  Syntax Error while loading YAML.   found unknown escape character  The error appears to be in
'/home/ubuntu/src/kayobe-config/etc/kayobe/environments/ci-aio/wazuh-secrets.yml': line 10, column 20, but may be elsewhere in the file depending on the exact syntax problem.
[WARNING]:  * Failed to parse /home/ubuntu/venvs/kayobe/share/kayobe/ansible/inventory/hosts with ini plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)  Syntax Error while loading YAML.   found unknown escape character  The error appears to be in
'/home/ubuntu/src/kayobe-config/etc/kayobe/environments/ci-aio/wazuh-secrets.yml': line 10, column 20, but may be elsewhere in the file depending on the exact syntax problem.
ERROR! Completely failed to parse inventory source /home/ubuntu/venvs/kayobe/share/kayobe/ansible/inventory/hosts
Kayobe playbook(s) etc/kayobe/ansible/wazuh-secrets.yml exited 1

@MaxBed4d
Copy link
Contributor Author

So this will successfully template and encrypt wazuh-secrets.yml the first time. But I'm seeing the second time I run it, ansible tries and fails to interpret the file:

(kayobe) ubuntu@mattc-skc-aio:~/src/kayobe-config$ kayobe playbook run etc/kayobe/ansible/wazuh-secrets.yml 
[WARNING]:  * Failed to parse /home/ubuntu/venvs/kayobe/share/kayobe/ansible/inventory/hosts with yaml plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)  Syntax Error while loading YAML.   found unknown escape character  The error appears to be in
'/home/ubuntu/src/kayobe-config/etc/kayobe/environments/ci-aio/wazuh-secrets.yml': line 10, column 20, but may be elsewhere in the file depending on the exact syntax problem.
[WARNING]:  * Failed to parse /home/ubuntu/venvs/kayobe/share/kayobe/ansible/inventory/hosts with ini plugin: We were unable to read either as JSON nor YAML, these are the errors we got from each: JSON: Expecting value: line 1 column 1 (char 0)  Syntax Error while loading YAML.   found unknown escape character  The error appears to be in
'/home/ubuntu/src/kayobe-config/etc/kayobe/environments/ci-aio/wazuh-secrets.yml': line 10, column 20, but may be elsewhere in the file depending on the exact syntax problem.
ERROR! Completely failed to parse inventory source /home/ubuntu/venvs/kayobe/share/kayobe/ansible/inventory/hosts
Kayobe playbook(s) etc/kayobe/ansible/wazuh-secrets.yml exited 1

@Alex-Welsh This may explain the previous formatting of the script.

@Alex-Welsh Alex-Welsh added bug Something isn't working antelope Targets the Antelope OpenStack release labels Nov 15, 2024
@MaxBed4d
Copy link
Contributor Author

MaxBed4d commented Nov 19, 2024

I couldn't get any errors when running any of the version of this code, and they seem to do the job, however, what has been added is a forced check to make sure that the wazuh_secrets.yml file is always encrypted, even if originally unencrypted.

Also note that the decryption of the file is necessary for checking whether the file is encrypted or not, could use a command line to determine this, but this would also require further steps and this way, we use the official Ansible vault pluggin.

@MaxBed4d MaxBed4d requested a review from MoteHue November 19, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
antelope Targets the Antelope OpenStack release bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants