--- # Determine the openshift_version to configure if none has been specified or set previously. - set_fact: is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" # Block attempts to install origin without specifying some kind of version information. # This is because the latest tags for origin are usually alpha builds, which should not # be used by default. Users must indicate what they want. - fail: msg: "Must specify openshift_release or openshift_image_tag in inventory to install origin. (suggestion: add openshift_release=\"1.2\" to inventory)" when: - is_containerized | bool - openshift.common.deployment_type == 'origin' - openshift_release is not defined - openshift_image_tag is not defined # Normalize some values that we need in a certain format that might be confusing: - set_fact: openshift_release: "{{ openshift_release[1:] }}" when: - openshift_release is defined - openshift_release[0] == 'v' - set_fact: openshift_release: "{{ openshift_release | string }}" when: openshift_release is defined # Verify that the image tag is in a valid format - block: # Verifies that when the deployment type is origin the version: # - starts with a v # - Has 3 integers seperated by dots # It also allows for optional trailing data which: # - must start with a dash # - may contain numbers, letters, dashes and dots. - assert: that: - "{{ openshift_image_tag|match('(^v?\\d+\\.\\d+\\.\\d+(-[\\w\\-\\.]*)?$)') }}" msg: "openshift_image_tag must be in the format v#.#.#[-optional.#]. Examples: v1.2.3, v3.5.1-alpha.1" when: openshift.common.deployment_type == 'origin' # Verifies that when the deployment type is openshift-enterprise the version: # - starts with a v # - Has at least 2 integers seperated by dots # It also allows for optional trailing data which: # - must start with a dash # - may contain numbers - assert: that: - "{{ openshift_image_tag|match('(^v\\d+\\.\\d+[\\.\\d+]*(-\\d+)?$)') }}" msg: "openshift_image_tag must be in the format v#.#[.#[.#]]. Examples: v1.2, v3.4.1, v3.5.1.3, v1.2-1, v1.2.3-4" when: openshift.common.deployment_type == 'openshift-enterprise' when: - openshift_image_tag is defined - openshift_image_tag != "latest" # Add a v to the start of the openshift_image_tag if one was not provided - set_fact: openshift_image_tag: "{{ 'v' + openshift_image_tag }}" when: - openshift_image_tag is defined - openshift_image_tag[0] != 'v' - openshift_image_tag != 'latest' - set_fact: openshift_pkg_version: "{{ '-' + openshift_pkg_version }}" when: - openshift_pkg_version is defined - openshift_pkg_version[0] != '-' # Make sure we copy this to a fact if given a var: - set_fact: openshift_version: "{{ openshift_version | string }}" when: openshift_version is defined # Protect the installed version by default unless explicitly told not to, or given an # openshift_version already. - 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 - openshift_version is not defined - openshift_protect_installed_version | bool - name: Set openshift_version for rpm installation include: set_version_rpm.yml when: not is_containerized | bool - name: Set openshift_version for containerized installation include: set_version_containerized.yml when: is_containerized | bool # Warn if the user has provided an openshift_image_tag but is not doing a containerized install # NOTE: This will need to be modified/removed for future container + rpm installations work. - name: Warn if openshift_image_tag is defined when not doing a containerized install debug: msg: > openshift_image_tag is used for containerized installs. If you are trying to specify an image for a non-container install see oreg_url. when: - not is_containerized | bool - openshift_image_tag is defined # At this point we know openshift_version is set appropriately. Now we set # openshift_image_tag and openshift_pkg_version, so all roles can always assume # each of this variables *will* be set correctly and can use them per their # intended purpose. - block: - debug: msg: "openshift_image_tag was not defined. Falling back to v{{ openshift_version }}" - set_fact: openshift_image_tag: v{{ openshift_version }} when: openshift_image_tag is not defined - block: - debug: msg: "openshift_pkg_version was not defined. Falling back to -{{ openshift_version }}" - set_fact: openshift_pkg_version: -{{ openshift_version }} when: openshift_pkg_version is not defined - fail: msg: openshift_version role was unable to set openshift_version when: openshift_version is not defined - fail: msg: openshift_version role was unable to set openshift_image_tag when: openshift_image_tag is not defined - fail: msg: openshift_version role was unable to set openshift_pkg_version when: openshift_pkg_version is not defined - fail: msg: "No OpenShift version available, please ensure your systems are fully registered and have access to appropriate yum repositories." when: - not is_containerized | bool - openshift_version == '0.0' # We can't map an openshift_release to full rpm version like we can with containers, make sure # the rpm version we looked up matches the release requested and error out if not. - fail: msg: "Detected OpenShift version {{ openshift_version }} does not match requested openshift_release {{ openshift_release }}. You may need to adjust your yum repositories, inventory, or run the appropriate OpenShift upgrade playbook." when: - not is_containerized | bool - openshift_release is defined - not openshift_version.startswith(openshift_release) | bool # The end result of these three variables is quite important so make sure they are displayed and logged: - debug: var=openshift_release - debug: var=openshift_image_tag - debug: var=openshift_pkg_version