summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevan Goodwin <dgoodwin@redhat.com>2016-05-31 11:56:13 -0300
committerDevan Goodwin <dgoodwin@redhat.com>2016-05-31 11:56:13 -0300
commit47c8c0b1df866b86b111e3e03b827011ec4c341c (patch)
tree704fa66f0c47ce5a8bad7f97047984edbff0f1aa
parentefb153693104976e86a91ebf6bf236448be5a84d (diff)
downloadopenshift-47c8c0b1df866b86b111e3e03b827011ec4c341c.tar.gz
openshift-47c8c0b1df866b86b111e3e03b827011ec4c341c.tar.bz2
openshift-47c8c0b1df866b86b111e3e03b827011ec4c341c.tar.xz
openshift-47c8c0b1df866b86b111e3e03b827011ec4c341c.zip
Break version calc out into a role, separate yaml for containerized/rpm.
-rw-r--r--roles/openshift_docker/meta/main.yml4
-rw-r--r--roles/openshift_docker/tasks/main.yml81
-rw-r--r--roles/openshift_version/meta/main.yml17
-rw-r--r--roles/openshift_version/tasks/main.yml29
-rw-r--r--roles/openshift_version/tasks/set_version_containerized.yml34
-rw-r--r--roles/openshift_version/tasks/set_version_rpm.yml23
6 files changed, 104 insertions, 84 deletions
diff --git a/roles/openshift_docker/meta/main.yml b/roles/openshift_docker/meta/main.yml
index d98f953ea..c1a6611d1 100644
--- a/roles/openshift_docker/meta/main.yml
+++ b/roles/openshift_docker/meta/main.yml
@@ -12,6 +12,4 @@ galaxy_info:
categories:
- cloud
dependencies:
-- role: openshift_repos
-- role: openshift_docker_facts
-- role: docker
+- role: openshift_version
diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml
index 00f761987..ed97d539c 100644
--- a/roles/openshift_docker/tasks/main.yml
+++ b/roles/openshift_docker/tasks/main.yml
@@ -1,82 +1 @@
---
-# It's important that we don't explicitly pull this image here. Otherwise we
-# could result in upgrading a preinstalled environment. We'll have to set
-# openshift_image_tag correctly for upgrades.
-
-# Determine openshift_version if none is set for this host, or if a generic "3.2"
-# is set, determine the more specific version number by either installing the latest
-# rpm, or pulling the v3.2 container and checking the resulting versions.
-
-- set_fact:
- 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:
-# 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: Install latest OpenShift rpm to check version
- 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
-
-- name: Reload facts to pick up version
- openshift_facts:
- when: not is_containerized | bool and openshift_version is not defined
-
-- set_fact:
- openshift_version: "{{ openshift.common.version }}"
- when: not is_containerized | bool and openshift_version is not defined
-
-
-# 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
- register: cli_image_version
- when: is_containerized | bool and openshift_version is not defined
-
-- debug: var=cli_image_version
-
-- 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: is_containerized | bool and openshift_version is not defined
-
-# If we got an openshift_version like "3.2", lookup the latest 3.2 container version
-# and use that value instead.
-- name: Lookup specific OpenShift version if generic release specified
- command: >
- docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version
- register: cli_image_version
- when: is_containerized | bool and openshift_version is defined and 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: is_containerized | bool and openshift_version is defined and openshift_version.split('.') | length == 2
-
-
-- debug: var=openshift_version
-
diff --git a/roles/openshift_version/meta/main.yml b/roles/openshift_version/meta/main.yml
new file mode 100644
index 000000000..d98f953ea
--- /dev/null
+++ b/roles/openshift_version/meta/main.yml
@@ -0,0 +1,17 @@
+---
+galaxy_info:
+ author: Jason DeTiberus
+ description: OpenShift Docker
+ company: Red Hat, Inc.
+ license: Apache License, Version 2.0
+ min_ansible_version: 1.9
+ platforms:
+ - name: EL
+ versions:
+ - 7
+ categories:
+ - cloud
+dependencies:
+- role: openshift_repos
+- role: openshift_docker_facts
+- role: docker
diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml
new file mode 100644
index 000000000..379809eda
--- /dev/null
+++ b/roles/openshift_version/tasks/main.yml
@@ -0,0 +1,29 @@
+---
+# 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 }}"
+
+- debug: var=openshift_version
+- debug: var=openshift_release
+- debug: var=openshift_pkg_version
+- debug: var=openshift_image_tag
+
+# Here we protect the version already installed unless something has already set
+# an openshift_version to configure.
+- 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: Set openshift_version for rpm installation
+ include: set_version_rpm.yml
+ when: not is_containerized and openshift_version is not defined
+
+- name: Set openshift_version for containerized installation
+ include: set_version_containerized.yml
+ when: is_containerized and openshift_version is not defined
+
+- debug: var=openshift_version
+
+
diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml
new file mode 100644
index 000000000..0da3484a9
--- /dev/null
+++ b/roles/openshift_version/tasks/set_version_containerized.yml
@@ -0,0 +1,34 @@
+---
+- name: Set containerized version to configure if openshift_image_tag specified
+ set_fact:
+ openshift_version: "{{ openshift_image_tag.split('v',1)[1] }}"
+ when: openshift_image_tag is 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
+
+- name: Lookup latest containerized version if no version specified
+ command: >
+ docker run --rm {{ openshift.common.cli_image }}:latest version
+ register: cli_image_version
+ when: openshift_version is not defined
+
+- debug: var=cli_image_version
+
+- 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 not defined
+
+# If we got an openshift_version like "3.2", lookup the latest 3.2 container version
+# and use that value instead.
+- name: Set precise containerized version to configure if openshift_release specified
+ 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
+
+- 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
diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml
new file mode 100644
index 000000000..ab8f4b22f
--- /dev/null
+++ b/roles/openshift_version/tasks/set_version_rpm.yml
@@ -0,0 +1,23 @@
+---
+# TODO: support openshift_release here?
+- name: Set rpm version to configure if 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: openshift_pkg_version is defined
+
+# We do not have as fine grained control over version to install presently with rpms,
+# we just assume the user has configured the correct repos and install the rpm requested.
+- name: Install latest rpm available in configured repos to check version
+ action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present"
+ when: openshift_version is not defined
+
+- name: Reload facts to pick up version
+ openshift_facts:
+ when: openshift_version is not defined
+
+- name: Set rpm version to configure to latest available in repos
+ set_fact:
+ openshift_version: "{{ openshift.common.version }}"
+ when: openshift_version is not defined