diff options
-rw-r--r-- | playbooks/common/openshift-cluster/config.yml | 2 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/initialize_openshift_version.yml | 32 | ||||
-rw-r--r-- | playbooks/common/openshift-master/config.yml | 86 | ||||
-rw-r--r-- | roles/openshift_cli/tasks/main.yml | 4 | ||||
-rw-r--r-- | roles/openshift_docker/tasks/main.yml | 29 |
5 files changed, 73 insertions, 80 deletions
diff --git a/playbooks/common/openshift-cluster/config.yml b/playbooks/common/openshift-cluster/config.yml index 903babc45..b2f09d58d 100644 --- a/playbooks/common/openshift-cluster/config.yml +++ b/playbooks/common/openshift-cluster/config.yml @@ -5,6 +5,8 @@ - include: validate_hostnames.yml +- include: initialize_openshift_version.yml + - name: Set oo_options hosts: oo_all_hosts tasks: diff --git a/playbooks/common/openshift-cluster/initialize_openshift_version.yml b/playbooks/common/openshift-cluster/initialize_openshift_version.yml new file mode 100644 index 000000000..85ad52b22 --- /dev/null +++ b/playbooks/common/openshift-cluster/initialize_openshift_version.yml @@ -0,0 +1,32 @@ +--- +# NOTE: requires openshift_facts be run +- name: Determine openshift_version to configure on first master + hosts: oo_first_master + roles: + # Using the CLI role here to install the CLI tool/wrapper, and set the + # openshift.common.version fact which other hosts can then reference. + - openshift_cli + pre_tasks: + - debug: var=openshift.common.version + - debug: var=openshift_version + post_tasks: + - debug: var=openshift.common.version + - debug: var=openshift_version + +# NOTE: We set this even on etcd hosts as they may also later run as masters, +# and we don't want to install wrong version of docker and have to downgrade +# later. +- name: Set openshift_version for all hosts + hosts: oo_all_hosts + tasks: + - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version + - debug: var=openshift.common.version + - debug: var=openshift_version + # TODO: Should we use the first master's "openshift_version" var instead of a fact? Could go to just openshift_docker role above, and skip CLI config this early. + - set_fact: + openshift_version: "{{ openshift.common.version if openshift.common.version is defined else hostvars[groups.oo_first_master.0].openshift.common.version.split('-')[0] }}" + when: inventory_hostname != groups.oo_first_master.0 + - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version + - debug: var=openshift.common.version + - debug: var=openshift_version + diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 1812ccd1f..c39af9c40 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -167,45 +167,10 @@ - debug: var=openshift.common - debug: var=openshift_image_tag - debug: var=openshift_release - - name: Determine version to configure if containerized and release specified - set_fact: - openshift_version: "{{ openshift_release }}" - when: openshift.common.is_containerized | bool and openshift_release is defined -# TODO: what should we do for rpm installs and openshift_release here? - - name: Determine container version to configure when openshift_image_tag specified - set_fact: - openshift_version: "{{ openshift_image_tag.split('v',1)[1] }}" - when: openshift.common.is_containerized | bool and openshift_image_tag is defined - - name: Determine rpm version to configure when openshift_pkg_version specified - set_fact: - # Expects a leading "-" in inventory, strip it off here, and ignore a trailing release, - # openshift_version should always just be "3.2" or "3.2.0.44" - openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" - when: not openshift.common.is_containerized | bool and openshift_pkg_version is defined - - name: Use openshift.common.version fact as version to configure if already installed - set_fact: - openshift_version: "{{ openshift.common.version }}" - when: openshift.common.version is defined - debug: var=openshift_version roles: - openshift_docker -# Re-use pre-existing version fact if present, if not use the first master's -# openshift_version calculated above. -- name: Determine openshift_version to configure on remaining masters - hosts: oo_masters_to_config[1:] - any_errors_fatal: true - tasks: - - set_fact: - openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift_version }}" - when: openshift.common.version is not defined - - set_fact: - openshift_version: "{{ openshift.common.version }}" - when: openshift.common.version is defined - - debug: var=openshift_version - post_tasks: - - fail: - - name: Determine if master certificates need to be generated hosts: oo_first_master:oo_masters_to_config tasks: @@ -387,54 +352,19 @@ with_items: openshift_master_named_certificates when: named_certs_specified | bool -- name: Configure first master instance - hosts: oo_first_master +- name: Configure masters + hosts: oo_masters_to_config any_errors_fatal: true serial: 1 vars: sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - openshift_master_ha: "{{ openshift.master.ha }}" - openshift_master_count: "{{ openshift.master.master_count }}" - openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}" - openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}" - openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" - openshift_no_proxy_internal_hostnames: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config'] - | union(groups['oo_masters_to_config']) - | union(groups['oo_etcd_to_config'] | default([]))) - | oo_collect('openshift.common.hostname') | default([]) | join (',') - }}" - when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and - openshift_generate_no_proxy_hosts | default(True) | bool }}" - pre_tasks: - - name: Ensure certificate directory exists - file: - path: "{{ openshift.common.config_base }}/master" - state: directory - when: master_certs_missing | bool and 'oo_first_master' not in group_names - - name: Unarchive the tarball on the master - unarchive: - src: "{{ sync_tmpdir }}/{{ master_cert_subdir }}.tgz" - dest: "{{ master_cert_config_dir }}" - when: master_certs_missing | bool and 'oo_first_master' not in group_names - - debug: var=openshift_version - roles: - - openshift_master - - role: nickhammond.logrotate - - role: nuage_master - when: openshift.common.use_nuage | bool - post_tasks: - - name: Create group for deployment type - group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }} - changed_when: False -# TODO: This is a copy paste of the oo_first_master, how do we reconcile the code but change openshift_version? -- name: Configure remaining master instances - hosts: oo_masters_to_config[1:] - any_errors_fatal: true - serial: 1 - vars: - sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - openshift_version: "{{ oo_first_master.openshift.common.version.split('-')[0] }}" + # Do not pass a version if this is first master. (openshift_docker will sort it out) + # For subsequent masters we pass either pre-existing version for the master (if already installed), + # otherwise the first master version. + openshift_version: "{{ openshift.common.version if openshift.common.version is defined else oo_first_master.openshift.common.version.split('-')[0] }}" + when: inventory_hostname != groups.oo_first_master.0 + openshift_master_ha: "{{ openshift.master.ha }}" openshift_master_count: "{{ openshift.master.master_count }}" openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}" diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml index 8679407dc..fe6672a47 100644 --- a/roles/openshift_cli/tasks/main.yml +++ b/roles/openshift_cli/tasks/main.yml @@ -29,3 +29,7 @@ - /usr/local/bin/oc - /usr/local/bin/kubectl when: openshift.common.is_containerized | bool + +- name: Reload facts to pick up installed OpenShift version + openshift_facts: + diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index c7b8f504a..c2ba63a1d 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -11,9 +11,24 @@ is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" - debug: var=openshift_version +- debug: var=openshift_release +- debug: var=openshift_pkg_version +- debug: var=openshift_image_tag # RPM openshift_version setup: -- debug: msg="{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }}" +# TODO: support openshift_release here: +- name: Determine rpm version to configure when openshift_pkg_version specified + set_fact: + # Expects a leading "-" in inventory, strip it off here, and ignore a trailing release, + # openshift_version should always just be "3.2" or "3.2.0.44" + openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" + when: not is_containerized | bool and openshift_pkg_version is defined and openshift_version is not defined + +- name: Use openshift.common.version fact as version to configure if already installed + set_fact: + openshift_version: "{{ openshift.common.version }}" + when: openshift.common.version is defined and openshift_version is not defined + - name: Lookup latest OpenShift rpm version if none specified action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not is_containerized | bool and openshift_version is not defined @@ -26,9 +41,18 @@ openshift_version: "{{ openshift.common.version }}" when: not is_containerized | bool and openshift_version is not defined -# TODO: What to do if openshift_version = 3.2 for rpm based installs? # Containerized openshift_version setup: +- name: Determine version to configure if containerized and release specified + set_fact: + openshift_version: "{{ openshift_release }}" + when: is_containerized | bool and openshift_release is defined and openshift_version is not defined + +- name: Determine container version to configure when openshift_image_tag specified + set_fact: + openshift_version: "{{ openshift_image_tag.split('v',1)[1] }}" + when: is_containerized | bool and openshift_image_tag is defined and openshift_version is not defined + - name: Lookup latest containerized OpenShift version if none specified command: > docker run --rm {{ openshift.common.cli_image }}:latest version @@ -53,5 +77,6 @@ openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2][1:] | join('-') if openshift.common.deployment_type == 'origin' else cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" when: is_containerized | bool and openshift_version is defined and openshift_version.split('.') | length == 2 + - debug: var=openshift_version |