diff options
author | Michael Gugino <mgugino@redhat.com> | 2017-12-14 15:54:45 -0500 |
---|---|---|
committer | Michael Gugino <mgugino@redhat.com> | 2017-12-14 16:34:00 -0500 |
commit | fe801cb7fbf983ef397257117da30ce4ccc938b4 (patch) | |
tree | c6e9dabf625f5e2f17ef2fab516839638f4d4957 | |
parent | 22794be6953a6896bbb550e3bb3c82caf202c8e2 (diff) | |
download | openshift-fe801cb7fbf983ef397257117da30ce4ccc938b4.tar.gz openshift-fe801cb7fbf983ef397257117da30ce4ccc938b4.tar.bz2 openshift-fe801cb7fbf983ef397257117da30ce4ccc938b4.tar.xz openshift-fe801cb7fbf983ef397257117da30ce4ccc938b4.zip |
Move repo and subscribe to prerequisites
This commit refactors some steps in rhel subscribe and
moves repos.yml from init/main to prerequisites.
-rw-r--r-- | playbooks/byo/rhel_subscribe.yml | 3 | ||||
-rw-r--r-- | playbooks/init/main.yml | 2 | ||||
-rw-r--r-- | playbooks/init/repos.yml | 4 | ||||
-rw-r--r-- | playbooks/prerequisites.yml | 2 | ||||
-rw-r--r-- | roles/openshift_repos/tasks/main.yaml | 4 | ||||
-rw-r--r-- | roles/rhel_subscribe/tasks/main.yml | 55 | ||||
-rw-r--r-- | roles/rhel_subscribe/tasks/satellite.yml | 2 |
7 files changed, 20 insertions, 52 deletions
diff --git a/playbooks/byo/rhel_subscribe.yml b/playbooks/byo/rhel_subscribe.yml index 5a877809a..3cb11a457 100644 --- a/playbooks/byo/rhel_subscribe.yml +++ b/playbooks/byo/rhel_subscribe.yml @@ -8,6 +8,7 @@ when: - deployment_type == 'openshift-enterprise' - ansible_distribution == "RedHat" - - lookup('env', 'rhel_skip_subscription') | default(rhsub_skip, True) | default('no', True) | lower in ['no', 'false'] + - rhsub_user | default(False) + - rhsub_pass | default(False) - role: openshift_repos - role: os_update_latest diff --git a/playbooks/init/main.yml b/playbooks/init/main.yml index b2b972a7d..06e8ba504 100644 --- a/playbooks/init/main.yml +++ b/playbooks/init/main.yml @@ -23,8 +23,6 @@ - import_playbook: validate_hostnames.yml when: not (skip_validate_hostnames | default(False)) -- import_playbook: repos.yml - - import_playbook: version.yml when: not (skip_verison | default(False)) diff --git a/playbooks/init/repos.yml b/playbooks/init/repos.yml index 4967b8f13..048b09e60 100644 --- a/playbooks/init/repos.yml +++ b/playbooks/init/repos.yml @@ -9,8 +9,8 @@ when: - ansible_distribution == 'RedHat' - deployment_type == 'openshift-enterprise' - - (rhel_subscription_user or rhsub_user) is defined - - (rhel_subscription_password or rhsub_pass) is defined + - rhsub_user | default(False) + - rhsub_pass | default(False) - name: initialize openshift repos include_role: name: openshift_repos diff --git a/playbooks/prerequisites.yml b/playbooks/prerequisites.yml index 7b7868cfe..5ba62a6d6 100644 --- a/playbooks/prerequisites.yml +++ b/playbooks/prerequisites.yml @@ -3,6 +3,8 @@ vars: skip_verison: True +- import_playbook: init/repos.yml + # This is required for container runtime for crio, only needs to run once. - name: Configure os_firewall hosts: oo_masters_to_config:oo_etcd_to_config:oo_lb_to_config:oo_nfs_to_config:oo_nodes_to_config diff --git a/roles/openshift_repos/tasks/main.yaml b/roles/openshift_repos/tasks/main.yaml index 83954eaf8..3a6667863 100644 --- a/roles/openshift_repos/tasks/main.yaml +++ b/roles/openshift_repos/tasks/main.yaml @@ -41,8 +41,8 @@ when: - ansible_distribution == 'RedHat' - deployment_type == 'openshift-enterprise' - - (rhel_subscription_user or rhsub_user) is defined - - (rhel_subscription_password or rhsub_pass) is defined + - rhsub_user is defined + - rhsub_password is defined - include_tasks: centos_repos.yml when: diff --git a/roles/rhel_subscribe/tasks/main.yml b/roles/rhel_subscribe/tasks/main.yml index 74ee8bbfe..6337cd644 100644 --- a/roles/rhel_subscribe/tasks/main.yml +++ b/roles/rhel_subscribe/tasks/main.yml @@ -1,22 +1,8 @@ --- -- set_fact: - rhel_subscription_pass: "{{ lookup('env', 'rhel_subscription_pass') | default(rhsub_pass | default(omit, True)) }}" - 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_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: The rhel_subscription_user variable is required for this role. - when: rhel_subscription_user is not defined or not rhsub_user is not defined - -- fail: - msg: The rhel_subscription_pass variable is required for this role. - when: rhel_subscription_pass is not defined or not rhsub_pass is not defined - - name: Install Red Hat Subscription manager yum: name: subscription-manager @@ -25,21 +11,18 @@ until: result | success - name: Is host already registered? - command: bash -c "subscription-manager version" + command: "subscription-manager version" register: rh_subscribed - changed_when: "'not registered' in rh_subscribed.stdout" - ignore_errors: yes + changed_when: False - name: Register host redhat_subscription: - username: "{{ rhel_subscription_user }}" - password: "{{ rhel_subscription_pass }}" + username: "{{ rhsub_user }}" + password: "{{ rhsub_pass }}" register: rh_subscription until: rh_subscription | succeeded when: - "'not registered' in rh_subscribed.stdout" - - rhel_subscription_user is defined - - rhel_subscription_pass is defined - fail: msg: 'Unable to register host with Red Hat Subscription Manager' @@ -48,34 +31,18 @@ - rh_subscription.failed - name: Determine if OpenShift Pool Already Attached - command: bash -c "subscription-manager list --consumed --pool-only --matches '*OpenShift*' | grep {{ rhel_subscription_pool }}" + command: "subscription-manager list --consumed --pool-only --matches '*OpenShift*'" register: openshift_pool_attached - changed_when: rhel_subscription_pool not in openshift_pool_attached.stdout - failed_when: openshift_pool_attached.rc == 2 + changed_when: False ignore_errors: yes -- name: Retrieve the OpenShift Pool ID - command: bash -c "subscription-manager list --available --pool-only --matches '*OpenShift*' | grep {{ rhel_subscription_pool }}" - register: openshift_pool_retrieve - changed_when: rhel_subscription_pool in openshift_pool_retrieve.stdout - when: rhel_subscription_pool not in openshift_pool_attached.stdout - ignore_errors: yes - -- fail: - msg: "Unable to find pool matching {{ rhel_subscription_pool }} in available pools" - when: - - rhel_subscription_pool not in openshift_pool_attached.stdout - - rhel_subscription_pool not in openshift_pool_retrieve.stdout - - name: Attach to OpenShift Pool - command: bash -c "subscription-manager attach --pool {{ rhel_subscription_pool }}" + command: "subscription-manager attach --pool {{ rhsub_pool }}" register: openshift_pool_attached changed_when: "'Successfully attached a subscription' in openshift_pool_attached.stdout" - when: rhel_subscription_pool not in openshift_pool_attached.stdout + when: rhsub_pool not in openshift_pool_attached.stdout -- include_role: - role: rhel_subscribe - tasks_from: satellite +- include_tasks: satellite.yml when: - - (rhel_subscription_server or rhsub_server) is defined - - (rhel_subscription_server or rhsub_server) + - rhsub_server is defined + - rhsub_server diff --git a/roles/rhel_subscribe/tasks/satellite.yml b/roles/rhel_subscribe/tasks/satellite.yml index b2b2a621d..dadbe3487 100644 --- a/roles/rhel_subscribe/tasks/satellite.yml +++ b/roles/rhel_subscribe/tasks/satellite.yml @@ -1,5 +1,5 @@ --- - 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 |