From 30674233228212609f525dd7bee0d43b5c446d3c Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Mon, 13 Mar 2017 12:15:00 -0400 Subject: cleanup: when in openshift_version tasks are multiline --- roles/openshift_version/tasks/main.yml | 40 ++++++++++++++++++---- .../tasks/set_version_containerized.yml | 21 +++++++++--- roles/openshift_version/tasks/set_version_rpm.yml | 4 ++- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 35953b744..d13ed4599 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -9,16 +9,36 @@ # 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 and openshift.common.deployment_type == 'origin' and openshift_release is not defined and openshift_image_tag is not defined + 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 + +# 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 and openshift_image_tag[0] != 'v' and openshift_image_tag != 'latest' + 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 and openshift_pkg_version[0] != '-' + when: + - openshift_pkg_version is defined + - openshift_pkg_version[0] != '-' # Make sure we copy this to a fact if given a var: - set_fact: @@ -30,7 +50,10 @@ - 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 and openshift_protect_installed_version | bool + 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 @@ -67,13 +90,18 @@ - 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 and openshift_version == '0.0' + 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 and openshift_release is defined and not openshift_version.startswith(openshift_release) | bool + 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 diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index cd0f20ae9..0ec4c49d6 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -4,12 +4,16 @@ # Expects a leading "v" in inventory, strip it off here unless # openshift_image_tag=latest openshift_version: "{{ openshift_image_tag[1:].split('-')[0] if openshift_image_tag != 'latest' else openshift_image_tag }}" - when: openshift_image_tag is defined and openshift_version is not defined + when: + - openshift_image_tag is defined + - openshift_version is not defined - name: Set containerized version to configure if openshift_release specified set_fact: openshift_version: "{{ openshift_release }}" - when: openshift_release is defined and openshift_version is not defined + when: + - openshift_release is defined + - openshift_version is not defined - name: Lookup latest containerized version if no version specified command: > @@ -20,7 +24,10 @@ # Origin latest = pre-release version (i.e. v1.3.0-alpha.1-321-gb095e3a) - set_fact: openshift_version: "{{ (cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-'))[1:] }}" - when: openshift_version is not defined and openshift.common.deployment_type == 'origin' and cli_image_version.stdout_lines[0].split('-') | length > 1 + when: + - openshift_version is not defined + - openshift.common.deployment_type == 'origin' + - cli_image_version.stdout_lines[0].split('-') | length > 1 - set_fact: openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" @@ -32,11 +39,15 @@ command: > docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version register: cli_image_version - when: openshift_version is defined and openshift_version.split('.') | length == 2 + when: + - openshift_version is defined + - openshift_version.split('.') | length == 2 - set_fact: 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: openshift_version is defined and openshift_version.split('.') | length == 2 + when: + - openshift_version is defined + - openshift_version.split('.') | length == 2 # We finally have the specific version. Now we clean up any strange # dangly +c0mm1t-offset tags in the version. See also, diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index 0c2ef4bb7..c7604af1a 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -3,7 +3,9 @@ set_fact: # Expects a leading "-" in inventory, strip it off here, and remove trailing release, openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" - when: openshift_pkg_version is defined and openshift_version is not defined + when: + - openshift_pkg_version is defined + - openshift_version is not defined # if {{ openshift.common.service_type}}-excluder is enabled, # the repoquery for {{ openshift.common.service_type}} will not work. -- cgit v1.2.3 From 3aa41e54b072dde8597db7fd0fc997dfc2002cf1 Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Mon, 13 Mar 2017 12:17:43 -0400 Subject: Add openshift_version fact fallback debug messages --- roles/openshift_version/tasks/main.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index d13ed4599..4de36ad1b 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -68,12 +68,22 @@ # each of this variables *will* be set correctly and can use them per their # intended purpose. -- set_fact: - openshift_image_tag: v{{ openshift_version }} +- 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 -- set_fact: - openshift_pkg_version: -{{ openshift_version }} +- 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: -- cgit v1.2.3 From e9c87e2c135f54862905d4677ebf97551bfa1a6e Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Mon, 13 Mar 2017 14:08:13 -0400 Subject: Verify openshift_image_tag is valid during openshift_version main - origin examples: v1.2.3, v1.2.3-alpha, v1.2.3-beta.1, v1.5.0-rc.0 - openshift-enterprise examples: v3.5, v3.5.3, v3.5.3.4, v3.5.3.4-1 --- roles/openshift_version/tasks/main.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 4de36ad1b..ef1783244 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -26,6 +26,37 @@ 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 }}" -- cgit v1.2.3 From 20d205de5b62ea400dfe738ea3fd5ade3fac5ef0 Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Mon, 13 Mar 2017 15:34:59 -0400 Subject: Warn if openshift_image_tag is defined by hand for package installs --- roles/openshift_version/tasks/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index ef1783244..9780fd746 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -94,6 +94,18 @@ 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 -- cgit v1.2.3 From 356d0a7fe75675afae157cf18ab89f70e31ba2de Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Mon, 13 Mar 2017 15:37:55 -0400 Subject: openshift_version now requires prepended version formats - openshift_image_tag must start with a v unless it's set to latest - openshift_pkg_version must start with a - --- roles/openshift_version/tasks/main.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 9780fd746..4603c5e54 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -57,20 +57,6 @@ - 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 }}" -- cgit v1.2.3 From 53f7a846fc43b7a62986d16c84939e7da22d530c Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Wed, 15 Mar 2017 09:57:26 -0400 Subject: doc: Remove atomic-openshift deployment type --- DEPLOYMENT_TYPES.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/DEPLOYMENT_TYPES.md b/DEPLOYMENT_TYPES.md index 668d14fc0..42ac5635a 100644 --- a/DEPLOYMENT_TYPES.md +++ b/DEPLOYMENT_TYPES.md @@ -1,18 +1,17 @@ #Deployment Types -This module supports OpenShift Origin, OpenShift Enterprise, and Atomic -Enterprise Platform. Each deployment type sets various defaults used throughout -your environment. +This module supports OpenShift Origin and OpenShift Enterprise Each deployment +type sets various defaults used throughout your environment. The table below outlines the defaults per `deployment_type`. -| deployment_type | origin | enterprise (< 3.1) | atomic-enterprise | openshift-enterprise (>= 3.1) | -|-----------------------------------------------------------------|------------------------------------------|----------------------------------------|----------------------------------|----------------------------------| -| **openshift.common.service_type** (also used for package names) | origin | openshift | atomic-openshift | | -| **openshift.common.config_base** | /etc/origin | /etc/openshift | /etc/origin | /etc/origin | -| **openshift.common.data_dir** | /var/lib/origin | /var/lib/openshift | /var/lib/origin | /var/lib/origin | -| **openshift.master.registry_url openshift.node.registry_url** | openshift/origin-${component}:${version} | openshift3/ose-${component}:${version} | aos3/aos-${component}:${version} | aos3/aos-${component}:${version} | -| **Image Streams** | centos | rhel + xpaas | N/A | rhel | +| deployment_type | origin | enterprise (< 3.1) | openshift-enterprise (>= 3.1) | +|-----------------------------------------------------------------|------------------------------------------|----------------------------------------|----------------------------------| +| **openshift.common.service_type** (also used for package names) | origin | openshift | | +| **openshift.common.config_base** | /etc/origin | /etc/openshift | /etc/origin | +| **openshift.common.data_dir** | /var/lib/origin | /var/lib/openshift | /var/lib/origin | +| **openshift.master.registry_url openshift.node.registry_url** | openshift/origin-${component}:${version} | openshift3/ose-${component}:${version} | aos3/aos-${component}:${version} | +| **Image Streams** | centos | rhel + xpaas | rhel | **NOTE** `enterprise` deployment type is used for OpenShift Enterprise version -- cgit v1.2.3 From 1664a447b184b33ff0da4f07501dd706fea9e450 Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Thu, 16 Mar 2017 10:52:51 -0400 Subject: Add names to openshift_image_tag asserts --- roles/openshift_version/tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 4603c5e54..c3d001bb4 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -35,7 +35,8 @@ # It also allows for optional trailing data which: # - must start with a dash # - may contain numbers, letters, dashes and dots. - - assert: + - name: Verify Origin openshift_image_tag is valid + 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" @@ -47,7 +48,8 @@ # It also allows for optional trailing data which: # - must start with a dash # - may contain numbers - - assert: + - name: Verify Enterprise openshift_image_tag is valid + 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" -- cgit v1.2.3