Make redhat_subscription parameters optional

Using default(omit), parameters not part of environment won't be sent to
the module, so fully ignored.
Indeed, username/password/state/autosubscribe are all optional.

Change-Id: I3a81cdaccd2d90a43dec95d21b26d9ea503ed313
This commit is contained in:
Emilien Macchi 2017-12-15 12:00:27 -08:00
parent 99c534dc3d
commit 4c77ba509d
3 changed files with 9 additions and 8 deletions

View File

@ -14,8 +14,8 @@ Role Variables
| Name | Default Value | Description |
|-------------------|---------------------|----------------------|
| `rhn_username` | `{{ lookup('env', 'RHN_USERNAME') }}` | Red Hat Portal username. |
| `rhn_password` | `{{ lookup('env', 'RHN_PASSWORD') }}` | Red Hat Portal password. |
| `rhn_username` | No default | Red Hat Portal username. |
| `rhn_password` | No default | Red Hat Portal password. |
| `rhsub_state` | `enable` | Whether to enable or disable a Red Hat subscription. |
| `rhsub_autosubscribe` | `yes` | Whether or not to autosubscibe to available repositories. |
| `rhsub_repos` | `[undefined]` | If defined, the list of repositories to enable or disable. See `defaults/main.yml` for examples. |

View File

@ -1,5 +1,6 @@
rhn_username: "{{ lookup('env', 'RHN_USERNAME') }}"
rhn_password: "{{ lookup('env', 'RHN_PASSWORD') }}"
# These parameters aren't required, so no default is provided:
# rhn_username: joe
# rhn_password: secrete
rhsub_state: present # present or absent
rhsub_autosubscribe: True

View File

@ -17,10 +17,10 @@
- name: Manage Red Hat subscription
redhat_subscription:
username: "{{ rhn_username }}"
password: "{{ rhn_password }}"
state: "{{ rhsub_state }}"
autosubscribe: "{{ rhsub_autosubscribe }}"
username: "{{ rhn_username|default(omit) }}"
password: "{{ rhn_password|default(omit) }}"
state: "{{ rhsub_state|default(omit) }}"
autosubscribe: "{{ rhsub_autosubscribe|default(omit) }}"
tags:
- rhsub
- rhsub_register