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

os_images visibility fix #38

Closed
wants to merge 2 commits into from
Closed

os_images visibility fix #38

wants to merge 2 commits into from

Conversation

grzegorzkoper
Copy link
Contributor

@grzegorzkoper grzegorzkoper commented Apr 24, 2024

Correcting visibility variable logic, to account for edge case when is_public is defined but we want to override it with os_images_visibility.

Based on discussions here:
stackhpc/ansible-role-os-images#77 (comment)
It looks like the intention was to support deprecated is_public along with visibility and still have the ability to override with role defined os_images_visibility.

This PR handles that.

Fixes : #37

@grzegorzkoper grzegorzkoper requested a review from a team as a code owner April 24, 2024 09:52
@grzegorzkoper grzegorzkoper changed the title Visibility fix os_images visibility fix Apr 24, 2024
@@ -115,7 +115,7 @@
ramdisk: "{{ item.2.id if is_baremetal else omit }}"
vars:
is_baremetal: "{{ item.0.elements is defined and 'baremetal' in item.0.elements }}"
visibility: "{{ item.0.visibility | default(item.0.is_public | ternary('public', 'private') if item.0.is_public is defined else os_images_visibility) }}"
visibility: "{{ os_images_visibility | default(item.0.visibility | default(item.0.is_public | default(true) | ternary('public', 'private', true))) }}"
Copy link
Member

@bbezak bbezak Apr 24, 2024

Choose a reason for hiding this comment

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

base on role defaults -

os_images_visibility: "{{ 'public' if os_images_public | bool else 'private' }}"

it will be public even if item's visibility/is_public would be private

Copy link
Member

@bbezak bbezak left a comment

Choose a reason for hiding this comment

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

@markgoddard
Copy link

Correcting visibility variable logic, to account for edge case when is_public is defined but we want to override it with os_images_visibility.

IMO is_public should override os_images_visibility, since it has been specified on a per-image basis, whereas os_images_visibility is global. If you don't want is_public to be used, remove it from the image definition.

@@ -32,7 +32,7 @@
filename: "{{ os_images_cache }}/{{ item.name }}/{{ item.name }}.vmlinuz"
with_items: "{{ os_images_list | list }}"
vars:
visibility: "{{ item.visibility | default(item.is_public | ternary('public', 'private') if item.is_public is defined else os_images_visibility) }}"
visibility: "{{ os_images_visibility | default(item.0.visibility | default(item.0.is_public | default(true) | ternary('public', 'private', true))) }}"

Choose a reason for hiding this comment

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

per-item values should take precedence over global values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree
I've misunderstood the intent.
Since os_images_visibility is being set as role defaults it is not it's purpose to override per-item values.

Closing.

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.

os_image role ignores os_images_visibility variable when is_public is defined
3 participants