Skip to content

Commit

Permalink
fix: correctly set release using new behavior of rhsm_release
Browse files Browse the repository at this point in the history
The way the new version of rhsm_release works is this:

- if the `release` parameter is present, set the release to the given
  value.
- If there is no `release` parameter, unset the release.

If the user does not set `rhc_release`, or if the user sets it to `omit`
then it will be `null`, and calling the rhsm_release module will be
skipped.
See ansible-collections/community.general#6401
for details.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Jun 6, 2023
1 parent d3c8a70 commit bd50e92
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tasks/subscription-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
and not 'keys' in rhc_auth.activation_keys | d({})) else omit }}"
release: "{{ rhc_release
if (rhc_state | d('present') != 'absent'
and rhc_release != __rhc_state_absent)
and rhc_release != __rhc_state_absent
and not rhc_release is none
and rhc_release != omit)
else omit }}"
server_proxy_hostname: "{% if rhc_proxy == __rhc_state_absent -%}
{{ __rhc_empty_string }}
Expand Down Expand Up @@ -93,21 +95,15 @@
when:
- rhc_state | d("present") in ["present", "reconnect"]
block:
- name: Set the release
- name: Set or unset the release
community.general.rhsm_release:
release: "{{ rhc_release }}"
release: "{{ rhc_release if rhc_release != __rhc_state_absent
else omit }}"
when:
- rhc_state | d("present") == "present"
- __rhc_subman_identity.rc == 0
- rhc_release != __rhc_state_absent

- name: Unset the release
community.general.rhsm_release:
release: null
when:
- rhc_state | d("present") == "present"
- __rhc_subman_identity.rc == 0
- rhc_release == __rhc_state_absent
- not rhc_release is none
- rhc_release != omit

- name: Configure repositories
community.general.rhsm_repository:
Expand Down

0 comments on commit bd50e92

Please sign in to comment.