summaryrefslogtreecommitdiffstats
path: root/roles/openshift_docker/tasks/main.yml
blob: c7b8f504af34adb9d08f76000e635b5731ae0048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
# 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

# RPM openshift_version setup:
- debug: msg="{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }}"
- 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

- 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

# TODO: What to do if openshift_version = 3.2 for rpm based installs?

# Containerized openshift_version setup:
- 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