diff options
author | Tomas Sedovic <tomas@sedovic.cz> | 2017-12-01 12:14:20 +0100 |
---|---|---|
committer | Tomas Sedovic <tomas@sedovic.cz> | 2017-12-01 12:18:19 +0100 |
commit | 9562adf37d853dd03531fde7b14e249736e10d88 (patch) | |
tree | 742c3d3896ac0d857f800b31253388408da271b0 /roles/rhel_subscribe | |
parent | fdf3edec3f880d21e19e2007065be3ed0ed59a13 (diff) | |
download | openshift-9562adf37d853dd03531fde7b14e249736e10d88.tar.gz openshift-9562adf37d853dd03531fde7b14e249736e10d88.tar.bz2 openshift-9562adf37d853dd03531fde7b14e249736e10d88.tar.xz openshift-9562adf37d853dd03531fde7b14e249736e10d88.zip |
Remove reading shell environment in rhel_subscribe
The rhel_subscribe role used to read the shell environment variables for
its input with a broken fallback to Ansible variables.
This updates the role to only use Ansible vars. If the user wants to do
an env lookup, they can do so when calling the role.
Diffstat (limited to 'roles/rhel_subscribe')
-rw-r--r-- | roles/rhel_subscribe/README.md | 29 | ||||
-rw-r--r-- | roles/rhel_subscribe/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/rhel_subscribe/tasks/enterprise.yml | 9 | ||||
-rw-r--r-- | roles/rhel_subscribe/tasks/main.yml | 28 |
4 files changed, 43 insertions, 25 deletions
diff --git a/roles/rhel_subscribe/README.md b/roles/rhel_subscribe/README.md new file mode 100644 index 000000000..8b3e1fe60 --- /dev/null +++ b/roles/rhel_subscribe/README.md @@ -0,0 +1,29 @@ +RHEL Subscribe +============== + +Subscribes the RHEL servers and add the OpenShift enterprise repos. + +Role variables +-------------- + +### `rhsub_user` + +Username for the subscription-manager. + +### `rhsub_pass` + +Password for the subscription-manager. + +### `rhsub_pool` + +Name of the pool to attach (optional). + +### `rhsub_server` + +Custom hostname for the Satellite server (optional). + +### `ose_version` + +Version for the OpenShift Enterprise repositories. + +Example: `3.6` diff --git a/roles/rhel_subscribe/defaults/main.yml b/roles/rhel_subscribe/defaults/main.yml new file mode 100644 index 000000000..6035a5f00 --- /dev/null +++ b/roles/rhel_subscribe/defaults/main.yml @@ -0,0 +1,2 @@ +rhsub_pool: 'Red Hat OpenShift Container Platform, Premium*' +ose_version: '3.6' diff --git a/roles/rhel_subscribe/tasks/enterprise.yml b/roles/rhel_subscribe/tasks/enterprise.yml index fa74c9953..55e535d61 100644 --- a/roles/rhel_subscribe/tasks/enterprise.yml +++ b/roles/rhel_subscribe/tasks/enterprise.yml @@ -2,18 +2,11 @@ - name: Disable all repositories command: subscription-manager repos --disable="*" -- set_fact: - default_ose_version: '3.6' - when: deployment_type == 'openshift-enterprise' - -- set_fact: - ose_version: "{{ lookup('env', 'ose_version') | default(default_ose_version, True) }}" - - fail: msg: "{{ ose_version }} is not a valid version for {{ deployment_type }} deployment type" when: - deployment_type == 'openshift-enterprise' - - ose_version not in ['3.1', '3.2', '3.3', '3.4', '3.5', '3.6'] ) + - ose_version not in ['3.1', '3.2', '3.3', '3.4', '3.5', '3.6'] - name: Enable RHEL repositories command: subscription-manager repos \ diff --git a/roles/rhel_subscribe/tasks/main.yml b/roles/rhel_subscribe/tasks/main.yml index b06f51908..2ac3afb70 100644 --- a/roles/rhel_subscribe/tasks/main.yml +++ b/roles/rhel_subscribe/tasks/main.yml @@ -3,23 +3,17 @@ # to make it able to attach to a pool # to make it able to enable repositories -- set_fact: - rhel_subscription_pool: "{{ lookup('env', 'rhel_subscription_pool') | default(rhsub_pool | default('Red Hat OpenShift Container Platform, Premium*')) }}" - rhel_subscription_user: "{{ lookup('env', 'rhel_subscription_user') | default(rhsub_user | default(omit, True)) }}" - rhel_subscription_pass: "{{ lookup('env', 'rhel_subscription_pass') | default(rhsub_pass | default(omit, True)) }}" - rhel_subscription_server: "{{ lookup('env', 'rhel_subscription_server') | default(rhsub_server | default(omit, True)) }}" - - fail: msg: "This role is only supported for Red Hat hosts" when: ansible_distribution != 'RedHat' - fail: - msg: Either rhsub_user or the rhel_subscription_user env variable are required for this role. - when: rhel_subscription_user is not defined + msg: The rhsub_user variable is required for this role. + when: rhsub_user is not defined or not rhsub_user - fail: - msg: Either rhsub_pass or the rhel_subscription_pass env variable are required for this role. - when: rhel_subscription_pass is not defined + msg: The rhsub_pass variable is required for this role. + when: rhsub_pass is not defined or not rhsub_pass - name: Detecting Atomic Host Operating System stat: @@ -27,10 +21,10 @@ register: ostree_booted - name: Satellite preparation - command: "rpm -Uvh http://{{ rhel_subscription_server }}/pub/katello-ca-consumer-latest.noarch.rpm" + command: "rpm -Uvh http://{{ rhsub_server }}/pub/katello-ca-consumer-latest.noarch.rpm" args: creates: /etc/rhsm/ca/katello-server-ca.pem - when: rhel_subscription_server is defined and rhel_subscription_server + when: rhsub_server is defined and rhsub_server - name: Install Red Hat Subscription manager yum: @@ -39,26 +33,26 @@ - name: RedHat subscriptions redhat_subscription: - username: "{{ rhel_subscription_user }}" - password: "{{ rhel_subscription_pass }}" + username: "{{ rhsub_user }}" + password: "{{ rhsub_pass }}" register: rh_subscription until: rh_subscription | succeeded - name: Retrieve the OpenShift Pool ID - command: subscription-manager list --available --matches="{{ rhel_subscription_pool }}" --pool-only + command: subscription-manager list --available --matches="{{ rhsub_pool }}" --pool-only register: openshift_pool_id until: openshift_pool_id | succeeded changed_when: False - name: Determine if OpenShift Pool Already Attached - command: subscription-manager list --consumed --matches="{{ rhel_subscription_pool }}" --pool-only + command: subscription-manager list --consumed --matches="{{ rhsub_pool }}" --pool-only register: openshift_pool_attached until: openshift_pool_attached | succeeded changed_when: False when: openshift_pool_id.stdout == '' - fail: - msg: "Unable to find pool matching {{ rhel_subscription_pool }} in available or consumed pools" + msg: "Unable to find pool matching {{ rhsub_pool }} in available or consumed pools" when: openshift_pool_id.stdout == '' and openshift_pool_attached is defined and openshift_pool_attached.stdout == '' - name: Attach to OpenShift Pool |