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

fix: make sure when condition doesnt break maintenance_only #73

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

jon4hz
Copy link
Member

@jon4hz jon4hz commented Sep 23, 2024

Hi,

I found a few cases where the when condition overwrites the defaults provided by the yaml anchor.
This unfortunately breaks the maintenance_only behavior if you want to execute a single task only.

Also I'm curios why this inclusion / exclusion pattern is solved by when conditions. Couldn't we use tags for this?

@jon4hz jon4hz self-assigned this Sep 23, 2024
@jon4hz jon4hz requested a review from s3lph September 23, 2024 14:56
@s3lph
Copy link
Collaborator

s3lph commented Sep 24, 2024

Also I'm curios why this inclusion / exclusion pattern is solved by when conditions. Couldn't we use tags for this?

We want to be able to preserve the information about which tasks need to be excluded from which host, and tags can't be applied on a per-host basis. The only option we had seen was to use this not very pretty host vars based solution. Though I'm always open for improvement proposals.

Copy link
Collaborator

@s3lph s3lph left a comment

Choose a reason for hiding this comment

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

Good catch!

There's another one in the last task in roles/maintenance_31_nginx/tasks/main.yml. Would you mind fixing that one as well?

@jon4hz
Copy link
Member Author

jon4hz commented Sep 24, 2024

The only option we had seen was to use this not very pretty host vars based solution.

Maybe we could use some callback plugin magic that converts the hostvars to tags. This way we could still freely use when conditions without any drawbacks. But I didn't test if that actually works yet, so it's a bit of speculative. Not saying this is a much better solution. I just never saw this inclusion / exclusion pattern with variables but only with tags like https:/ansible-lockdown/RHEL9-CIS?tab=readme-ov-file#tags for example.

There's another one in the last task in roles/maintenance_31_nginx/tasks/main.yml. Would you mind fixing that one as well?

Sure, will do!

@jon4hz jon4hz requested a review from s3lph September 25, 2024 05:32
@jon4hz jon4hz merged commit 721d7aa into main Sep 25, 2024
2 checks passed
@jon4hz jon4hz deleted the fix-maintenance-only-pattern branch September 25, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants