From dcb7289d9cf28b155aebb3b4ab820db2033c1b35 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 20 May 2016 11:55:41 -0300 Subject: Debug output. --- roles/openshift_cli/tasks/main.yml | 6 ++++++ roles/openshift_docker/tasks/main.yml | 3 +++ roles/openshift_master/tasks/main.yml | 2 ++ 3 files changed, 11 insertions(+) diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml index bfa60e5b0..a2be95eac 100644 --- a/roles/openshift_cli/tasks/main.yml +++ b/roles/openshift_cli/tasks/main.yml @@ -1,4 +1,10 @@ --- +- debug: var=openshift_version +- debug: var=openshift_release +- debug: var=openshift_image_tag +- debug: var=openshift.common +- debug: var=openshift.docker + - name: Install clients action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-clients state=present" when: not openshift.common.is_containerized | bool diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index 9c5887f76..cff1c6bb4 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -8,6 +8,9 @@ # in non-upgrade scenarios: has_image_tag_fact: "{{ hostvars[inventory_hostname].openshift.docker.openshift_image_tag is defined }}" +- debug: var=openshift_image_tag +- debug: var=openshift_release + - name: Set version when containerized command: > docker run --rm {{ openshift.common.cli_image }} version diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 63a54a0d9..56ce0e396 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -23,6 +23,8 @@ msg: "Pacemaker based HA is not supported at this time when used with containerized installs" when: openshift_master_ha | bool and openshift_master_cluster_method == "pacemaker" and openshift.common.is_containerized | bool +- debug: var=openshift_version + - name: Install Master package action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool -- cgit v1.2.3 From c45562e0e03e03c82bfcf60d4b3f8b7793133301 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 20 May 2016 15:14:28 -0300 Subject: Set openshift_version in config playbooks for first master. Starting to remove openshift.docker.openshift_version fact usage. openshift_version should no longer contain a leading 'v' for containerized installs, just a version number. --- playbooks/common/openshift-master/config.yml | 72 +++++++++++++++++++++++- roles/openshift_cli/defaults/main.yml | 1 - roles/openshift_cli/tasks/main.yml | 5 +- roles/openshift_cli/templates/openshift.j2 | 4 +- roles/openshift_docker/tasks/main.yml | 2 + roles/openshift_facts/library/openshift_facts.py | 12 +--- roles/openshift_master/tasks/main.yml | 2 + 7 files changed, 79 insertions(+), 19 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 125aab0ae..17afbb48c 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -156,6 +156,29 @@ - master.etcd-ca.crt when: etcd_client_certs_missing is defined and etcd_client_certs_missing +# Must be run before generating master certs which involved openshift_cli role and needs +# to pull down the correct docker container: +- name: Determine openshift_version to install on first master + hosts: oo_first_master + any_errors_fatal: true + tasks: + - 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 + - name: Determine version to configure if containerized and 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 version to configure if already installed + set_fact: + openshift_version: "{{ openshift.common.version }}" + when: openshift.common.is_containerized | bool and openshift.common.version is defined + - debug: var=openshift_version + - name: Determine if master certificates need to be generated hosts: oo_first_master:oo_masters_to_config tasks: @@ -337,8 +360,50 @@ with_items: openshift_master_named_certificates when: named_certs_specified | bool -- name: Configure master instances - hosts: oo_masters_to_config +- name: Configure first master instances + hosts: oo_first_master + 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 (',') + }}" + openshift_version: "{{ g_openshift_version_requested }}" + 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: @@ -353,7 +418,8 @@ | 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_version: "{{ g_openshift_version_requested }}" + 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 diff --git a/roles/openshift_cli/defaults/main.yml b/roles/openshift_cli/defaults/main.yml index 7baa87ab8..ed97d539c 100644 --- a/roles/openshift_cli/defaults/main.yml +++ b/roles/openshift_cli/defaults/main.yml @@ -1,2 +1 @@ --- -openshift_version: "{{ openshift_image_tag | default(openshift.docker.openshift_image_tag | default('')) }}" diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml index a2be95eac..95711f95d 100644 --- a/roles/openshift_cli/tasks/main.yml +++ b/roles/openshift_cli/tasks/main.yml @@ -1,9 +1,6 @@ --- - debug: var=openshift_version -- debug: var=openshift_release -- debug: var=openshift_image_tag - debug: var=openshift.common -- debug: var=openshift.docker - name: Install clients action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-clients state=present" @@ -11,7 +8,7 @@ - name: Pull CLI Image command: > - docker pull {{ openshift.common.cli_image }}:{{ openshift_version }} + docker pull {{ openshift.common.cli_image }}:v{{ openshift_version }} when: openshift.common.is_containerized | bool - name: Create /usr/local/bin/openshift cli wrapper diff --git a/roles/openshift_cli/templates/openshift.j2 b/roles/openshift_cli/templates/openshift.j2 index 437e08aab..501796b0b 100644 --- a/roles/openshift_cli/templates/openshift.j2 +++ b/roles/openshift_cli/templates/openshift.j2 @@ -5,14 +5,14 @@ fi cmd=`basename $0` user=`id -u` group=`id -g` -image_tag={{ openshift_version }} +image_tag=v{{ openshift_version }} >&2 echo """ ================================================================================ ATTENTION: You are running ${cmd} via a wrapper around 'docker run {{ openshift.common.cli_image }}:${image_tag}'. This wrapper is intended only to be used to bootstrap an environment. Please install client tools on another host once you have granted cluster-admin -privileges to a user. +privileges to a user. {% if openshift.common.deployment_type in ['openshift-enterprise','atomic-enterprise'] %} See https://docs.openshift.com/enterprise/latest/cli_reference/get_started_cli.html {% else %} diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index cff1c6bb4..79efb193b 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -17,6 +17,8 @@ register: cli_image_version when: is_containerized | bool and openshift_image_tag is not defined and (upgrading | bool or not has_image_tag_fact | bool) +- debug: var=cli_image_version + # Use the pre-existing image tag from system facts if present, and we're not upgrading. # Ignores explicit openshift_image_tag if it's in the inventory, as this isn't an upgrade. - set_fact: diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index b13343776..6127948bf 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1133,15 +1133,9 @@ def get_openshift_version(facts): if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) - - # openshift_facts runs before openshift_docker_facts. However, it will be - # called again and set properly throughout the playbook run. This could be - # refactored to simply set the openshift.common.version in the - # openshift_docker_facts role but it would take reworking some assumptions - # on how get_openshift_version is called. - if 'is_containerized' in facts['common'] and safe_get_bool(facts['common']['is_containerized']): - if 'docker' in facts and 'openshift_version' in facts['docker']: - version = facts['docker']['openshift_version'] + elif os.path.isfile('/usr/local/bin/openshift'): + _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) + version = parse_openshift_version(output) return version diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 56ce0e396..0cbb49758 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -1,6 +1,8 @@ --- # TODO: add ability to configure certificates given either a local file to # point to or certificate contents, set in default cert locations. +- debug: var=openshift_version +- fail: # Authentication Variable Validation # TODO: validate the different identity provider kinds as well -- cgit v1.2.3 From 82a70f9cc1522d239212701ab6c9260cbf9dc8a7 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 20 May 2016 15:52:54 -0300 Subject: Remove now unnecessary pull and ver check in openshift_docker role. --- roles/openshift_docker/tasks/main.yml | 36 ----------------------------------- 1 file changed, 36 deletions(-) diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index 79efb193b..aaa472727 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -8,39 +8,3 @@ # in non-upgrade scenarios: has_image_tag_fact: "{{ hostvars[inventory_hostname].openshift.docker.openshift_image_tag is defined }}" -- debug: var=openshift_image_tag -- debug: var=openshift_release - -- name: Set version when containerized - command: > - docker run --rm {{ openshift.common.cli_image }} version - register: cli_image_version - when: is_containerized | bool and openshift_image_tag is not defined and (upgrading | bool or not has_image_tag_fact | bool) - -- debug: var=cli_image_version - -# Use the pre-existing image tag from system facts if present, and we're not upgrading. -# Ignores explicit openshift_image_tag if it's in the inventory, as this isn't an upgrade. -- set_fact: - l_image_tag: "{{ hostvars[inventory_hostname].openshift.docker.openshift_image_tag }}" - when: is_containerized | bool and not upgrading | bool and has_image_tag_fact | bool - -- set_fact: - l_image_tag: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-') if openshift.common.deployment_type == 'origin' else - cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0] }}" - when: is_containerized | bool and openshift_image_tag is not defined and (upgrading | bool or not has_image_tag_fact | bool) - -- set_fact: - l_image_tag: "{{ openshift_image_tag }}" - when: is_containerized | bool and openshift_image_tag is defined and (upgrading | bool or not has_image_tag_fact | bool) - -- name: Set post docker install facts - openshift_facts: - role: "{{ item.role }}" - local_facts: "{{ item.local_facts }}" - with_items: - - role: docker - local_facts: - openshift_image_tag: "{{ l_image_tag | default(None) }}" - openshift_version: "{{ l_image_tag.split('-')[0] | oo_image_tag_to_rpm_version if l_image_tag is defined else '' }}" - when: is_containerized | bool -- cgit v1.2.3 From 0c7433838c8c6409b8de907fcc946fc73fe90527 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 24 May 2016 09:46:33 -0300 Subject: Work towards determining openshift_version when unspecified. openshift_docker role was largely useless now, but also almost did what we needed. (deps ordering still needs to be changed) Remove defaulting of openshift_version. --- playbooks/common/openshift-master/config.yml | 6 +++--- roles/openshift_cli/tasks/main.yml | 1 + roles/openshift_common/defaults/main.yml | 1 - roles/openshift_docker/tasks/main.yml | 19 ++++++++++++++++--- roles/openshift_docker_facts/defaults/main.yml | 1 - roles/openshift_docker_facts/tasks/main.yml | 4 ++++ roles/openshift_facts/library/openshift_facts.py | 2 ++ roles/openshift_facts/tasks/main.yml | 1 + roles/openshift_master/defaults/main.yml | 2 +- roles/openshift_master/tasks/main.yml | 2 -- roles/openshift_master_ca/vars/main.yml | 1 - roles/openshift_node/defaults/main.yml | 1 - 12 files changed, 28 insertions(+), 13 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 17afbb48c..380875a30 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -175,8 +175,8 @@ when: openshift.common.is_containerized | bool and openshift_image_tag is defined - name: Determine version to configure if already installed set_fact: - openshift_version: "{{ openshift.common.version }}" - when: openshift.common.is_containerized | bool and openshift.common.version is defined + openshift_version: "{{ openshift.common.version_requested }}" + when: openshift.common.is_containerized | bool and openshift.common.version_requested is defined - debug: var=openshift_version - name: Determine if master certificates need to be generated @@ -376,7 +376,7 @@ | union(groups['oo_etcd_to_config'] | default([]))) | oo_collect('openshift.common.hostname') | default([]) | join (',') }}" - openshift_version: "{{ g_openshift_version_requested }}" + #openshift_version: "{{ g_openshift_version_requested }}" when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" pre_tasks: diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml index 95711f95d..8679407dc 100644 --- a/roles/openshift_cli/tasks/main.yml +++ b/roles/openshift_cli/tasks/main.yml @@ -6,6 +6,7 @@ action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-clients state=present" when: not openshift.common.is_containerized | bool +# TODO: handle no openshift_version set? - name: Pull CLI Image command: > docker pull {{ openshift.common.cli_image }}:v{{ openshift_version }} diff --git a/roles/openshift_common/defaults/main.yml b/roles/openshift_common/defaults/main.yml index e46af70c7..267c03605 100644 --- a/roles/openshift_common/defaults/main.yml +++ b/roles/openshift_common/defaults/main.yml @@ -1,4 +1,3 @@ --- openshift_cluster_id: 'default' openshift_debug_level: 2 -openshift_version: "{{ openshift_pkg_version | default('') }}" diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index aaa472727..2ab31de8b 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -4,7 +4,20 @@ # openshift_image_tag correctly for upgrades. - set_fact: is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" - # Does the host already have an image tag fact, used to determine if it's a new node - # in non-upgrade scenarios: - has_image_tag_fact: "{{ hostvars[inventory_hostname].openshift.docker.openshift_image_tag is defined }}" + +# If no openshift_version provided, figure out what to use: +# TODO: May want to move this to another role. +- name: Lookup latest 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 + +- debug: var=openshift_version diff --git a/roles/openshift_docker_facts/defaults/main.yml b/roles/openshift_docker_facts/defaults/main.yml index 7baa87ab8..ed97d539c 100644 --- a/roles/openshift_docker_facts/defaults/main.yml +++ b/roles/openshift_docker_facts/defaults/main.yml @@ -1,2 +1 @@ --- -openshift_version: "{{ openshift_image_tag | default(openshift.docker.openshift_image_tag | default('')) }}" diff --git a/roles/openshift_docker_facts/tasks/main.yml b/roles/openshift_docker_facts/tasks/main.yml index 43359dcb5..bc3637351 100644 --- a/roles/openshift_docker_facts/tasks/main.yml +++ b/roles/openshift_docker_facts/tasks/main.yml @@ -57,6 +57,8 @@ l_common_version: "{{ common_version.stdout | default('0.0', True) }}" when: not openshift.common.is_containerized | bool +- debug: var=l_common_version + - name: Set docker version to be installed set_fact: docker_version: "{{ '1.8.2' }}" @@ -68,3 +70,5 @@ docker_version: "{{ '1.9.1' }}" when: " ( l_common_version | version_compare('3.2','>') and openshift.common.service_type == 'atomic-openshift' ) or ( l_common_version | version_compare('1.2','>') and openshift.common.service_type == 'origin' )" + +- debug: var=docker_version diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 6127948bf..33596cd3e 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1134,6 +1134,8 @@ def get_openshift_version(facts): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) elif os.path.isfile('/usr/local/bin/openshift'): + # TODO: this should probably make sure the actual image is already present, this can take awhile if it has to pull + # and is falsely acting like openshift is already installed _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) version = parse_openshift_version(output) diff --git a/roles/openshift_facts/tasks/main.yml b/roles/openshift_facts/tasks/main.yml index ca1a9b1e4..c67f6b86a 100644 --- a/roles/openshift_facts/tasks/main.yml +++ b/roles/openshift_facts/tasks/main.yml @@ -41,3 +41,4 @@ no_proxy: "{{ openshift_no_proxy | default(None) }}" generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}" no_proxy_internal_hostnames: "{{ openshift_no_proxy_internal_hostnames | default(None) }}" + version_requested: "{{ openshift_version | default(None) }}" diff --git a/roles/openshift_master/defaults/main.yml b/roles/openshift_master/defaults/main.yml index dbd62c80f..14a1daf6c 100644 --- a/roles/openshift_master/defaults/main.yml +++ b/roles/openshift_master/defaults/main.yml @@ -1,4 +1,4 @@ --- openshift_node_ips: [] # TODO: update setting these values based on the facts -openshift_version: "{{ openshift_pkg_version | default(openshift_image_tag | default(openshift.docker.openshift_image_tag | default(''))) }}" +#openshift_version: "{{ openshift_pkg_version | default(openshift_image_tag | default(openshift.docker.openshift_image_tag | default(''))) }}" diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 0cbb49758..6870def5f 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -25,8 +25,6 @@ msg: "Pacemaker based HA is not supported at this time when used with containerized installs" when: openshift_master_ha | bool and openshift_master_cluster_method == "pacemaker" and openshift.common.is_containerized | bool -- debug: var=openshift_version - - name: Install Master package action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool diff --git a/roles/openshift_master_ca/vars/main.yml b/roles/openshift_master_ca/vars/main.yml index b35339b18..1f6af808c 100644 --- a/roles/openshift_master_ca/vars/main.yml +++ b/roles/openshift_master_ca/vars/main.yml @@ -3,4 +3,3 @@ openshift_master_config_dir: "{{ openshift.common.config_base }}/master" openshift_master_ca_cert: "{{ openshift_master_config_dir }}/ca.crt" openshift_master_ca_key: "{{ openshift_master_config_dir }}/ca.key" openshift_master_ca_serial: "{{ openshift_master_config_dir }}/ca.serial.txt" -openshift_version: "{{ openshift_pkg_version | default('') }}" diff --git a/roles/openshift_node/defaults/main.yml b/roles/openshift_node/defaults/main.yml index 91aed7aa3..fffbf2994 100644 --- a/roles/openshift_node/defaults/main.yml +++ b/roles/openshift_node/defaults/main.yml @@ -13,4 +13,3 @@ os_firewall_allow: - service: OpenShift OVS sdn port: 4789/udp when: openshift.node.use_openshift_sdn | bool -openshift_version: "{{ openshift_pkg_version | default(openshift_image_tag | default(openshift.docker.openshift_image_tag | default(''))) }}" -- cgit v1.2.3 From 436c287335c3b578aaa2c1c8835583feaee2a3cf Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 24 May 2016 11:13:33 -0300 Subject: Stop downgrading Docker because we don't know what version to install yet. --- playbooks/common/openshift-master/config.yml | 2 +- roles/openshift_docker_facts/tasks/main.yml | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 380875a30..206e92c16 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -376,7 +376,7 @@ | union(groups['oo_etcd_to_config'] | default([]))) | oo_collect('openshift.common.hostname') | default([]) | join (',') }}" - #openshift_version: "{{ g_openshift_version_requested }}" + openshift_version: "{{ g_openshift_version_requested }}" when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" pre_tasks: diff --git a/roles/openshift_docker_facts/tasks/main.yml b/roles/openshift_docker_facts/tasks/main.yml index bc3637351..2193b8c02 100644 --- a/roles/openshift_docker_facts/tasks/main.yml +++ b/roles/openshift_docker_facts/tasks/main.yml @@ -49,6 +49,8 @@ changed_when: false when: not openshift.common.is_containerized | bool +- debug: var=openshift_version + - set_fact: l_common_version: "{{ openshift_version | default('0.0', True) | oo_image_tag_to_rpm_version }}" when: openshift.common.is_containerized | bool @@ -59,16 +61,20 @@ - debug: var=l_common_version +# TODO: hardcoding specific docker versions here is not going to be maintainable... +# Don't define a docker version if we don't yet know what version we're going to install. - name: Set docker version to be installed set_fact: docker_version: "{{ '1.8.2' }}" - when: " ( l_common_version | version_compare('3.2','<') and openshift.common.service_type in ['openshift', 'atomic-openshift'] ) or - ( l_common_version | version_compare('1.1.4','<') and openshift.common.service_type == 'origin' )" + when: " l_common_version != '0.0' and + (( l_common_version | version_compare('3.2','<') and openshift.common.service_type in ['openshift', 'atomic-openshift'] ) or + ( l_common_version | version_compare('1.1.4','<') and openshift.common.service_type == 'origin' ))" - name: Set docker version to be installed set_fact: docker_version: "{{ '1.9.1' }}" - when: " ( l_common_version | version_compare('3.2','>') and openshift.common.service_type == 'atomic-openshift' ) or - ( l_common_version | version_compare('1.2','>') and openshift.common.service_type == 'origin' )" + when: " l_common_version != '0.0' and + (( l_common_version | version_compare('3.2','>') and openshift.common.service_type == 'atomic-openshift' ) or + ( l_common_version | version_compare('1.2','>') and openshift.common.service_type == 'origin' ))" - debug: var=docker_version -- cgit v1.2.3 From 5c833d9f29e292d11c0cbf08786e9015f133ce17 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 24 May 2016 11:56:11 -0300 Subject: Complete installation of first master containerized. --- playbooks/common/openshift-master/config.yml | 3 ++- roles/openshift_master/tasks/main.yml | 3 +-- roles/openshift_master/templates/atomic-openshift-master.j2 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 206e92c16..9842e3917 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -360,7 +360,7 @@ with_items: openshift_master_named_certificates when: named_certs_specified | bool -- name: Configure first master instances +- name: Configure first master instance hosts: oo_first_master any_errors_fatal: true serial: 1 @@ -400,6 +400,7 @@ - name: Create group for deployment type group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }} changed_when: False + - fail: # 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 diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 6870def5f..86942f055 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -2,7 +2,6 @@ # TODO: add ability to configure certificates given either a local file to # point to or certificate contents, set in default cert locations. - debug: var=openshift_version -- fail: # Authentication Variable Validation # TODO: validate the different identity provider kinds as well @@ -31,7 +30,7 @@ - name: Pull master image command: > - docker pull {{ openshift.master.master_image }}:{{ openshift_version }} + docker pull {{ openshift.master.master_image }}:v{{ openshift_version }} when: openshift.common.is_containerized | bool - name: Create openshift.common.data_dir diff --git a/roles/openshift_master/templates/atomic-openshift-master.j2 b/roles/openshift_master/templates/atomic-openshift-master.j2 index 026787421..ba2974476 100644 --- a/roles/openshift_master/templates/atomic-openshift-master.j2 +++ b/roles/openshift_master/templates/atomic-openshift-master.j2 @@ -1,7 +1,7 @@ OPTIONS=--loglevel={{ openshift.master.debug_level }} CONFIG_FILE={{ openshift_master_config_file }} {% if openshift.common.is_containerized | bool %} -IMAGE_VERSION={{ openshift_version }} +IMAGE_VERSION=v{{ openshift_version }} {% endif %} {% if 'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws %} -- cgit v1.2.3 From 717012aa4d5df01e5859ce44705abfbf34be8047 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 25 May 2016 09:20:15 -0300 Subject: Hookup node configuration. --- playbooks/common/openshift-master/config.yml | 9 ++++----- playbooks/common/openshift-node/config.yml | 8 ++++++-- roles/openshift_facts/library/openshift_facts.py | 8 ++++++-- roles/openshift_node/tasks/main.yml | 5 +++-- roles/openshift_node/tasks/systemd_units.yml | 2 +- roles/openshift_node/templates/openvswitch.sysconfig.j2 | 2 +- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 9842e3917..fb35a9d2f 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -175,8 +175,8 @@ when: openshift.common.is_containerized | bool and openshift_image_tag is defined - name: Determine version to configure if already installed set_fact: - openshift_version: "{{ openshift.common.version_requested }}" - when: openshift.common.is_containerized | bool and openshift.common.version_requested is defined + openshift_version: "{{ openshift.common.version }}" + when: openshift.common.is_containerized | bool and openshift.common.version is defined - debug: var=openshift_version - name: Determine if master certificates need to be generated @@ -366,6 +366,7 @@ serial: 1 vars: sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" + openshift_version: "{{ g_openshift_version_requested }}" 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 }}" @@ -376,7 +377,6 @@ | union(groups['oo_etcd_to_config'] | default([]))) | oo_collect('openshift.common.hostname') | default([]) | join (',') }}" - openshift_version: "{{ g_openshift_version_requested }}" when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" pre_tasks: @@ -400,7 +400,6 @@ - name: Create group for deployment type group_by: key=oo_masters_deployment_type_{{ openshift.common.deployment_type }} changed_when: False - - fail: # 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 @@ -409,6 +408,7 @@ serial: 1 vars: sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" + openshift_version: "{{ oo_first_master.openshift.common.version.split('-')[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 }}" @@ -419,7 +419,6 @@ | union(groups['oo_etcd_to_config'] | default([]))) | oo_collect('openshift.common.hostname') | default([]) | join (',') }}" - openshift_version: "{{ g_openshift_version_requested }}" when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" pre_tasks: diff --git a/playbooks/common/openshift-node/config.yml b/playbooks/common/openshift-node/config.yml index b3491ef8d..9809ee629 100644 --- a/playbooks/common/openshift-node/config.yml +++ b/playbooks/common/openshift-node/config.yml @@ -113,6 +113,7 @@ hosts: oo_containerized_master_nodes serial: 1 vars: + openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift.common.version }}" openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}" openshift_node_first_master_ip: "{{ hostvars[groups.oo_first_master.0].openshift.common.ip }}" openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" @@ -121,14 +122,17 @@ | 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 + when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" + pre_tasks: + - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version roles: - openshift_node - name: Configure node instances hosts: oo_nodes_to_config:!oo_containerized_master_nodes vars: + openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift.common.version }}" openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}" openshift_node_first_master_ip: "{{ hostvars[groups.oo_first_master.0].openshift.common.ip }}" openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" @@ -137,7 +141,7 @@ | 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 + when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" roles: - openshift_node diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 33596cd3e..eee4d2b8e 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -826,7 +826,7 @@ def set_version_facts_if_unset(facts): if 'common' in facts: deployment_type = facts['common']['deployment_type'] version = get_openshift_version(facts) - if version is not None: + if version: facts['common']['version'] = version if deployment_type == 'origin': version_gte_3_1_or_1_1 = LooseVersion(version) >= LooseVersion('1.1.0') @@ -1150,7 +1150,11 @@ def parse_openshift_version(output): string: the version number """ versions = dict(e.split(' v') for e in output.splitlines() if ' v' in e) - return versions.get('openshift', '') + ver = versions.get('openshift', '') + # Remove trailing build number and commit hash from older versions, we need to return a straight + # w.x.y.z version here for use as openshift_version throughout the playbooks/roles. (i.e. 3.1.1.6-64-g80b61da) + ver = ver.split('-')[0] + return ver def apply_provider_facts(facts, provider_facts): diff --git a/roles/openshift_node/tasks/main.yml b/roles/openshift_node/tasks/main.yml index e8bd13855..ec4252fed 100644 --- a/roles/openshift_node/tasks/main.yml +++ b/roles/openshift_node/tasks/main.yml @@ -1,4 +1,5 @@ --- +- debug: var=openshift_version # TODO: allow for overriding default ports where possible - fail: msg: "SELinux is disabled, This deployment type requires that SELinux is enabled." @@ -39,12 +40,12 @@ - name: Pull node image command: > - docker pull {{ openshift.node.node_image }}:{{ openshift_version }} + docker pull {{ openshift.node.node_image }}:v{{ openshift_version }} when: openshift.common.is_containerized | bool - name: Pull OpenVSwitch image command: > - docker pull {{ openshift.node.ovs_image }}:{{ openshift_version }} + docker pull {{ openshift.node.ovs_image }}:v{{ openshift_version }} when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool - name: Install the systemd units diff --git a/roles/openshift_node/tasks/systemd_units.yml b/roles/openshift_node/tasks/systemd_units.yml index e2a268260..0117a5a02 100644 --- a/roles/openshift_node/tasks/systemd_units.yml +++ b/roles/openshift_node/tasks/systemd_units.yml @@ -44,6 +44,6 @@ - regex: '^CONFIG_FILE=' line: "CONFIG_FILE={{ openshift_node_config_file }}" - regex: '^IMAGE_VERSION=' - line: "IMAGE_VERSION={{ openshift_version }}" + line: "IMAGE_VERSION=v{{ openshift_version }}" notify: - restart node diff --git a/roles/openshift_node/templates/openvswitch.sysconfig.j2 b/roles/openshift_node/templates/openvswitch.sysconfig.j2 index 1f8c20e07..53163b359 100644 --- a/roles/openshift_node/templates/openvswitch.sysconfig.j2 +++ b/roles/openshift_node/templates/openvswitch.sysconfig.j2 @@ -1 +1 @@ -IMAGE_VERSION={{ openshift_version }} +IMAGE_VERSION=v{{ openshift_version }} -- cgit v1.2.3 From 0fc4aae17527d8d51b3d3848ccbbf42c6d03fac9 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 25 May 2016 10:28:14 -0300 Subject: Fix version compare with using just 3.2 or 1.2. --- roles/openshift_docker_facts/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/openshift_docker_facts/tasks/main.yml b/roles/openshift_docker_facts/tasks/main.yml index 2193b8c02..dc369e883 100644 --- a/roles/openshift_docker_facts/tasks/main.yml +++ b/roles/openshift_docker_facts/tasks/main.yml @@ -74,7 +74,7 @@ set_fact: docker_version: "{{ '1.9.1' }}" when: " l_common_version != '0.0' and - (( l_common_version | version_compare('3.2','>') and openshift.common.service_type == 'atomic-openshift' ) or - ( l_common_version | version_compare('1.2','>') and openshift.common.service_type == 'origin' ))" + (( l_common_version | version_compare('3.2','>=') and openshift.common.service_type == 'atomic-openshift' ) or + ( l_common_version | version_compare('1.2','>=') and openshift.common.service_type == 'origin' ))" - debug: var=docker_version -- cgit v1.2.3 From 58f920e854180cd9a8754fee82712fa8dd7b1f34 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 25 May 2016 14:54:59 -0300 Subject: Preserve node versions on re-run. --- playbooks/common/openshift-master/config.yml | 2 +- playbooks/common/openshift-node/config.yml | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index fb35a9d2f..97a7db9a1 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -158,6 +158,7 @@ # Must be run before generating master certs which involved openshift_cli role and needs # to pull down the correct docker container: +# TODO: Handle rpm installs here - name: Determine openshift_version to install on first master hosts: oo_first_master any_errors_fatal: true @@ -366,7 +367,6 @@ serial: 1 vars: sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - openshift_version: "{{ g_openshift_version_requested }}" 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/playbooks/common/openshift-node/config.yml b/playbooks/common/openshift-node/config.yml index 9809ee629..5e92b5cbd 100644 --- a/playbooks/common/openshift-node/config.yml +++ b/playbooks/common/openshift-node/config.yml @@ -109,11 +109,26 @@ with_items: "{{ groups.oo_nodes_to_config | default([]) }}" when: hostvars[item].openshift.common.is_containerized | bool and (item in groups.oo_nodes_to_config and item in groups.oo_masters_to_config) +- name: Determine openshift_version to install on nodes + hosts: oo_nodes_to_config + any_errors_fatal: true + tasks: + - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version + - debug: var=openshift.common.version + - name: Set openshift_version to match first master for new node + set_fact: + openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift.common.version }}" + when: openshift.common.version is not defined + - name: Set openshift_version to currently installed version + set_fact: + openshift_version: "{{ openshift.common.version }}" + when: openshift.common.version is defined + - debug: var=openshift_version + - name: Configure node instances hosts: oo_containerized_master_nodes serial: 1 vars: - openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift.common.version }}" openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}" openshift_node_first_master_ip: "{{ hostvars[groups.oo_first_master.0].openshift.common.ip }}" openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" @@ -124,15 +139,12 @@ }}" when: "{{ (openshift_http_proxy is defined or openshift_https_proxy is defined) and openshift_generate_no_proxy_hosts | default(True) | bool }}" - pre_tasks: - - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version roles: - openshift_node - name: Configure node instances hosts: oo_nodes_to_config:!oo_containerized_master_nodes vars: - openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift.common.version }}" openshift_node_master_api_url: "{{ hostvars[groups.oo_first_master.0].openshift.master.api_url }}" openshift_node_first_master_ip: "{{ hostvars[groups.oo_first_master.0].openshift.common.ip }}" openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" -- cgit v1.2.3 From c45ccc0ee879e93a4fd4304b4848595fa27014c5 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 25 May 2016 15:40:20 -0300 Subject: Convert generic openshift_version=3.2 to specific early in install. --- roles/openshift_docker/tasks/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index 2ab31de8b..1791d20c0 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -19,5 +19,17 @@ 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 -- cgit v1.2.3 From 14b23a8b14636407143375cbac71b090663cee77 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 26 May 2016 14:30:37 -0300 Subject: Get rpm installations functional again. --- filter_plugins/oo_filters.py | 6 ++--- .../upgrades/v3_1_to_v3_2/pre.yml | 2 ++ playbooks/common/openshift-master/config.yml | 14 +++++++---- roles/openshift_common/meta/main.yml | 2 +- roles/openshift_common/tasks/main.yml | 11 --------- roles/openshift_docker/tasks/main.yml | 28 +++++++++++++++++++--- roles/openshift_master_ca/tasks/main.yml | 5 +++- 7 files changed, 45 insertions(+), 23 deletions(-) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index e7409bf22..554ef440f 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -885,11 +885,11 @@ class FilterModule(object): # TODO: Do we need to make this actually convert v1.2.0-rc1 into 1.2.0-0.rc1 # We'd need to be really strict about how we build the RPM Version+Release if version.startswith("v"): - version = version.replace("v", "") + version = version[1:] version = version.split('-')[0] - if include_dash: - version = "-" + version + if include_dash and not version.startswith("-"): + version = "-" + version return version diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index dd9843290..84b7c817b 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -125,6 +125,8 @@ register: g_rpm_versions_result when: not openshift.common.is_containerized | bool + - debug: var=g_rpm_versions_result + - set_fact: g_aos_versions: "{{ g_rpm_versions_result.stdout | from_yaml }}" when: not openshift.common.is_containerized | bool diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 97a7db9a1..063d86f60 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -158,7 +158,6 @@ # Must be run before generating master certs which involved openshift_cli role and needs # to pull down the correct docker container: -# TODO: Handle rpm installs here - name: Determine openshift_version to install on first master hosts: oo_first_master any_errors_fatal: true @@ -170,14 +169,21 @@ set_fact: openshift_version: "{{ openshift_release }}" when: openshift.common.is_containerized | bool and openshift_release is defined - - name: Determine version to configure if containerized and image tag specified +# 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 version to configure if already installed + - 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.is_containerized | bool and openshift.common.version is defined + when: openshift.common.version is defined - debug: var=openshift_version - name: Determine if master certificates need to be generated diff --git a/roles/openshift_common/meta/main.yml b/roles/openshift_common/meta/main.yml index f1cf3e161..d3f8a343f 100644 --- a/roles/openshift_common/meta/main.yml +++ b/roles/openshift_common/meta/main.yml @@ -13,4 +13,4 @@ galaxy_info: - cloud dependencies: - role: openshift_facts -- role: openshift_repos +- role: openshift_docker diff --git a/roles/openshift_common/tasks/main.yml b/roles/openshift_common/tasks/main.yml index 4ec255dbc..d548daae6 100644 --- a/roles/openshift_common/tasks/main.yml +++ b/roles/openshift_common/tasks/main.yml @@ -29,17 +29,6 @@ data_dir: "{{ openshift_data_dir | default(None) }}" use_dnsmasq: "{{ openshift_use_dnsmasq | default(None) }}" -# Using oo_image_tag_to_rpm_version here is a workaround for how -# openshift_version is set. That value is computed based on either RPM -# versions or image tags. openshift_common's usage requires that it be a RPM -# version and openshift_cli expects it to be an image tag. -- name: Install the base package for versioning - 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 openshift.common.is_containerized | bool - -- name: Set version facts - openshift_facts: - # For enterprise versions < 3.1 and origin versions < 1.1 we want to set the # hostname by default. - set_fact: diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index 1791d20c0..c7b8f504a 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -2,12 +2,34 @@ # 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 }}" -# If no openshift_version provided, figure out what to use: -# TODO: May want to move this to another role. -- name: Lookup latest OpenShift version if none specified +- 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 diff --git a/roles/openshift_master_ca/tasks/main.yml b/roles/openshift_master_ca/tasks/main.yml index 4b7ef1d84..613aecc38 100644 --- a/roles/openshift_master_ca/tasks/main.yml +++ b/roles/openshift_master_ca/tasks/main.yml @@ -1,6 +1,9 @@ --- + +- debug: msg="{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }}" + - name: Install the base package for admin tooling - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version }} state=present" + 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 openshift.common.is_containerized | bool register: install_result -- cgit v1.2.3 From 3f7ac81838d0cef4ea95505abf82be7e114ae415 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 09:20:28 -0300 Subject: Protect installed version on subsequent masters. --- playbooks/common/openshift-master/config.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 063d86f60..1812ccd1f 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -158,10 +158,12 @@ # Must be run before generating master certs which involved openshift_cli role and needs # to pull down the correct docker container: -- name: Determine openshift_version to install on first master +- name: Determine openshift_version to configure on first master hosts: oo_first_master any_errors_fatal: true - tasks: + # We do initial seeding of openshift_version if possible with these tasks. The openshift_docker role + # will make absolutely sure it's set to a specific version after this. + pre_tasks: - debug: var=openshift.common - debug: var=openshift_image_tag - debug: var=openshift_release @@ -185,6 +187,24 @@ 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 -- cgit v1.2.3 From 265daf6b65206fc17ad35e682640477d08efbc43 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 11:52:48 -0300 Subject: Refactor openshift_version behavior. Very early in playbooks we must init the openshift_version for each host. First we determine it for the master, logic now is pushed into the openshift_docker role which we run only on first master via openshift_cli. Facts are reloaded leaving us with a first master with openshift.common.version fact we can then re-use on all other hosts. The correct version of docker should be installed as well. We then set openshift_version for all other hosts by re-using the master fact. --- playbooks/common/openshift-cluster/config.yml | 2 + .../initialize_openshift_version.yml | 32 ++++++++ playbooks/common/openshift-master/config.yml | 86 ++-------------------- roles/openshift_cli/tasks/main.yml | 4 + roles/openshift_docker/tasks/main.yml | 29 +++++++- 5 files changed, 73 insertions(+), 80 deletions(-) create mode 100644 playbooks/common/openshift-cluster/initialize_openshift_version.yml 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 -- cgit v1.2.3 From 1d4a3de319f3e3f33bd5bd65298c68c04f576085 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 14:29:50 -0300 Subject: Fix error with containerized etcd install. Role was assuming it could successfully disable the rpm etcd service without checking if it was actuall present. --- roles/etcd/tasks/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index a798dc973..71735dc25 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -28,18 +28,18 @@ state: directory mode: 0700 +- name: Check for etcd service presence + command: systemctl show etcd.service + register: etcd_show + changed_when: false + - name: Disable system etcd when containerized - when: etcd_is_containerized | bool + when: etcd_is_containerized | bool and 'LoadState=not-found' not in etcd_show.stdout service: name: etcd state: stopped enabled: no -- name: Check for etcd service presence - command: systemctl show etcd.service - register: etcd_show - changed_when: false - - name: Mask system etcd when containerized when: etcd_is_containerized | bool and 'LoadState=not-found' not in etcd_show.stdout command: systemctl mask etcd -- cgit v1.2.3 From bab4a4b6aeeb12b5c1fb412a3a95c5d8c90249e4 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 14:41:57 -0300 Subject: Fix image tag to rpm version filter. --- filter_plugins/oo_filters.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 260dea92c..7510975f2 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -881,13 +881,12 @@ class FilterModule(object): """ if not isinstance(version, basestring): raise errors.AnsibleFilterError("|failed expects a string or unicode") - # TODO: Do we need to make this actually convert v1.2.0-rc1 into 1.2.0-0.rc1 - # We'd need to be really strict about how we build the RPM Version+Release if version.startswith("v"): version = version[1:] + # Strip release from requested version, we no longer support this. version = version.split('-')[0] - if include_dash and not version.startswith("-"): + if include_dash and version and not version.startswith("-"): version = "-" + version return version -- cgit v1.2.3 From 5b73307fa59680959da5a61e94a0c7316ca0ccb6 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 16:03:46 -0300 Subject: Fix use of openshift_version in ca role. --- roles/openshift_ca/tasks/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/roles/openshift_ca/tasks/main.yml b/roles/openshift_ca/tasks/main.yml index 497473f22..cd72a4e21 100644 --- a/roles/openshift_ca/tasks/main.yml +++ b/roles/openshift_ca/tasks/main.yml @@ -4,10 +4,7 @@ when: openshift_ca_host is not defined - name: Install the base package for admin tooling - action: > - {{ ansible_pkg_mgr }} - name={{ openshift.common.service_type }}{{ openshift_version }} - state=present + 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 openshift.common.is_containerized | bool register: install_result delegate_to: "{{ openshift_ca_host }}" -- cgit v1.2.3 From 2b9144e782de10627d44afe977cef98686c78a01 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 16:04:10 -0300 Subject: Fix error restarting master service that may not be there. --- roles/openshift_master/tasks/main.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 86942f055..d50d552c8 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -165,9 +165,14 @@ register: start_result notify: Verify API Server -- name: Stop and disable non HA master when running HA +- name: Check for non-HA master service presence + command: systemctl show {{ openshift.common.service_type }}-master.service + register: master_svc_show + changed_when: false + +- name: Stop and disable non-HA master when running HA service: name={{ openshift.common.service_type }}-master enabled=no state=stopped - when: openshift_master_ha | bool + when: openshift_master_ha | bool and 'LoadState=not-found' not in master_svc_show.stdout - set_fact: master_service_status_changed: "{{ start_result | changed }}" -- cgit v1.2.3 From 4a97c9d0f7409b2be90964647f5712e51df37242 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 30 May 2016 16:06:00 -0300 Subject: Add leading v for remaining IMAGE_VERSION templates. --- .../templates/native-cluster/atomic-openshift-master-api.j2 | 2 +- .../templates/native-cluster/atomic-openshift-master-controllers.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 index 02c22e374..36e4446b9 100644 --- a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 +++ b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 @@ -1,7 +1,7 @@ OPTIONS=--loglevel={{ openshift.master.debug_level }} --listen={{ 'https' if openshift.master.api_use_ssl else 'http' }}://{{ openshift.master.bind_addr }}:{{ openshift.master.api_port }} --master={{ openshift.master.loopback_api_url }} CONFIG_FILE={{ openshift_master_config_file }} {% if openshift.common.is_containerized | bool %} -IMAGE_VERSION={{ openshift_version }} +IMAGE_VERSION=v{{ openshift_version }} {% endif %} {% if 'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws %} diff --git a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 index 644640577..ca3ae0ef8 100644 --- a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 +++ b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 @@ -1,7 +1,7 @@ OPTIONS=--loglevel={{ openshift.master.debug_level }} --listen={{ 'https' if openshift.master.api_use_ssl else 'http' }}://{{ openshift.master.bind_addr }}:{{ openshift.master.controllers_port }} CONFIG_FILE={{ openshift_master_config_file }} {% if openshift.common.is_containerized | bool %} -IMAGE_VERSION={{ openshift_version }} +IMAGE_VERSION=v{{ openshift_version }} {% endif %} {% if 'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws %} -- cgit v1.2.3 From efb153693104976e86a91ebf6bf236448be5a84d Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 31 May 2016 10:26:53 -0300 Subject: Drop unnecessary node playbook version calculation. --- playbooks/common/openshift-node/config.yml | 16 ---------------- roles/openshift_docker/tasks/main.yml | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/playbooks/common/openshift-node/config.yml b/playbooks/common/openshift-node/config.yml index 5e92b5cbd..bffac0e56 100644 --- a/playbooks/common/openshift-node/config.yml +++ b/playbooks/common/openshift-node/config.yml @@ -109,22 +109,6 @@ with_items: "{{ groups.oo_nodes_to_config | default([]) }}" when: hostvars[item].openshift.common.is_containerized | bool and (item in groups.oo_nodes_to_config and item in groups.oo_masters_to_config) -- name: Determine openshift_version to install on nodes - hosts: oo_nodes_to_config - any_errors_fatal: true - tasks: - - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version - - debug: var=openshift.common.version - - name: Set openshift_version to match first master for new node - set_fact: - openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift.common.version }}" - when: openshift.common.version is not defined - - name: Set openshift_version to currently installed version - set_fact: - openshift_version: "{{ openshift.common.version }}" - when: openshift.common.version is defined - - debug: var=openshift_version - - name: Configure node instances hosts: oo_containerized_master_nodes serial: 1 diff --git a/roles/openshift_docker/tasks/main.yml b/roles/openshift_docker/tasks/main.yml index c2ba63a1d..00f761987 100644 --- a/roles/openshift_docker/tasks/main.yml +++ b/roles/openshift_docker/tasks/main.yml @@ -29,7 +29,7 @@ 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 +- 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 -- cgit v1.2.3 From 47c8c0b1df866b86b111e3e03b827011ec4c341c Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 31 May 2016 11:56:13 -0300 Subject: Break version calc out into a role, separate yaml for containerized/rpm. --- roles/openshift_docker/meta/main.yml | 4 +- roles/openshift_docker/tasks/main.yml | 81 ---------------------- roles/openshift_version/meta/main.yml | 17 +++++ roles/openshift_version/tasks/main.yml | 29 ++++++++ .../tasks/set_version_containerized.yml | 34 +++++++++ roles/openshift_version/tasks/set_version_rpm.yml | 23 ++++++ 6 files changed, 104 insertions(+), 84 deletions(-) create mode 100644 roles/openshift_version/meta/main.yml create mode 100644 roles/openshift_version/tasks/main.yml create mode 100644 roles/openshift_version/tasks/set_version_containerized.yml create mode 100644 roles/openshift_version/tasks/set_version_rpm.yml 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 -- cgit v1.2.3 From a5a736f4042abca402f7648a830968c205163a34 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 31 May 2016 13:39:16 -0300 Subject: Stop requiring/using first master version fact and use openshift_version var instead. --- .../common/openshift-cluster/initialize_openshift_version.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_openshift_version.yml b/playbooks/common/openshift-cluster/initialize_openshift_version.yml index 85ad52b22..75452f41d 100644 --- a/playbooks/common/openshift-cluster/initialize_openshift_version.yml +++ b/playbooks/common/openshift-cluster/initialize_openshift_version.yml @@ -5,7 +5,7 @@ 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 + - openshift_version pre_tasks: - debug: var=openshift.common.version - debug: var=openshift_version @@ -19,14 +19,13 @@ - 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=hostvars[groups.oo_first_master.0].openshift_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] }}" + openshift_version: "{{ openshift.common.version if openshift.common.version is defined else hostvars[groups.oo_first_master.0].openshift_version }}" when: inventory_hostname != groups.oo_first_master.0 - - debug: var=hostvars[groups.oo_first_master.0].openshift.common.version + - debug: var=hostvars[groups.oo_first_master.0].openshift_version - debug: var=openshift.common.version - debug: var=openshift_version -- cgit v1.2.3 From 87cf5935b0a480aa2b2f4333a48173ef0b44c749 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 1 Jun 2016 12:45:05 -0300 Subject: Fix installing release 3.1 not converting to precise version. --- roles/openshift_version/tasks/main.yml | 4 ++-- roles/openshift_version/tasks/set_version_containerized.yml | 6 +++++- roles/openshift_version/tasks/set_version_rpm.yml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 379809eda..ee04ad59f 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -18,11 +18,11 @@ - name: Set openshift_version for rpm installation include: set_version_rpm.yml - when: not is_containerized and openshift_version is not defined + when: not is_containerized - name: Set openshift_version for containerized installation include: set_version_containerized.yml - when: is_containerized and openshift_version is not defined + when: is_containerized - debug: var=openshift_version diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index 0da3484a9..f3eab4831 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -2,7 +2,7 @@ - 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 + when: openshift_image_tag is defined and openshift_version is not defined - name: Set containerized version to configure if openshift_release specified set_fact: @@ -21,6 +21,9 @@ 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 +- debug: msg="{{ openshift_version }}" +#- debug: var=openshift_version.split('.') + # 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 @@ -32,3 +35,4 @@ - 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 index ab8f4b22f..b201f24d8 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -5,7 +5,7 @@ # 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 + when: openshift_pkg_version is defined and openshift_version is not 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. -- cgit v1.2.3 From 0514bdffca4e06144f4f81db037490d2c0fede40 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 1 Jun 2016 14:28:53 -0300 Subject: Update openshift_version author info. --- roles/openshift_version/meta/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/openshift_version/meta/main.yml b/roles/openshift_version/meta/main.yml index d98f953ea..8142fe823 100644 --- a/roles/openshift_version/meta/main.yml +++ b/roles/openshift_version/meta/main.yml @@ -1,7 +1,7 @@ --- galaxy_info: - author: Jason DeTiberus - description: OpenShift Docker + author: Devan Goodwin + description: Determines the version of OpenShift to install or upgrade to company: Red Hat, Inc. license: Apache License, Version 2.0 min_ansible_version: 1.9 -- cgit v1.2.3 From 88839ab89210ecd3d20d1f10f8f03bf0a801502a Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 6 Jun 2016 11:47:50 -0300 Subject: Do not install rpm for version in openshift_version role. --- .../initialize_openshift_version.yml | 4 ---- playbooks/common/openshift-master/config.yml | 2 +- roles/openshift_common/meta/main.yml | 3 ++- roles/openshift_common/tasks/main.yml | 11 +++++++++++ .../tasks/set_version_containerized.yml | 1 - roles/openshift_version/tasks/set_version_rpm.yml | 19 +++++++++---------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_openshift_version.yml b/playbooks/common/openshift-cluster/initialize_openshift_version.yml index 75452f41d..88ec7840b 100644 --- a/playbooks/common/openshift-cluster/initialize_openshift_version.yml +++ b/playbooks/common/openshift-cluster/initialize_openshift_version.yml @@ -3,14 +3,10 @@ - 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_version 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, diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 8ed62a7f1..7ab046e04 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -317,7 +317,7 @@ vars: sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - # Do not pass a version if this is first master. (openshift_docker will sort it out) + # Do not pass a version if this is first master. (openshift_version 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] }}" diff --git a/roles/openshift_common/meta/main.yml b/roles/openshift_common/meta/main.yml index d3f8a343f..cd8c75ec5 100644 --- a/roles/openshift_common/meta/main.yml +++ b/roles/openshift_common/meta/main.yml @@ -13,4 +13,5 @@ galaxy_info: - cloud dependencies: - role: openshift_facts -- role: openshift_docker +- role: openshift_repos +- role: openshift_version diff --git a/roles/openshift_common/tasks/main.yml b/roles/openshift_common/tasks/main.yml index d548daae6..4ec255dbc 100644 --- a/roles/openshift_common/tasks/main.yml +++ b/roles/openshift_common/tasks/main.yml @@ -29,6 +29,17 @@ data_dir: "{{ openshift_data_dir | default(None) }}" use_dnsmasq: "{{ openshift_use_dnsmasq | default(None) }}" +# Using oo_image_tag_to_rpm_version here is a workaround for how +# openshift_version is set. That value is computed based on either RPM +# versions or image tags. openshift_common's usage requires that it be a RPM +# version and openshift_cli expects it to be an image tag. +- name: Install the base package for versioning + 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 openshift.common.is_containerized | bool + +- name: Set version facts + openshift_facts: + # For enterprise versions < 3.1 and origin versions < 1.1 we want to set the # hostname by default. - set_fact: diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index f3eab4831..fc15b2d35 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -22,7 +22,6 @@ when: openshift_version is not defined - debug: msg="{{ openshift_version }}" -#- debug: var=openshift_version.split('.') # If we got an openshift_version like "3.2", lookup the latest 3.2 container version # and use that value instead. diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index b201f24d8..bcf275135 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -7,17 +7,16 @@ openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" when: openshift_pkg_version is defined and openshift_version is not 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" +- name: Gather common package version + command: > + {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type}}" + register: common_version + failed_when: false + changed_when: false when: openshift_version is not defined -- name: Reload facts to pick up version - openshift_facts: - when: openshift_version is not defined +- debug: var=common_version -- name: Set rpm version to configure to latest available in repos - set_fact: - openshift_version: "{{ openshift.common.version }}" +- set_fact: + openshift_version: "{{ common_version.stdout | default('0.0', True) }}" when: openshift_version is not defined -- cgit v1.2.3 From 9f40c71d007ec7098090a4edafc1846cc37d5dc2 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 6 Jun 2016 12:04:10 -0300 Subject: Drop unused and broken "when" in vars section. --- playbooks/common/openshift-master/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 7ab046e04..5e57cdeef 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -316,13 +316,6 @@ serial: 1 vars: sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - - # Do not pass a version if this is first master. (openshift_version 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 }}" -- cgit v1.2.3 From effc29ad8a0822b3981ff833fe66cc70f4e1e68c Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 7 Jun 2016 10:53:00 -0300 Subject: Verify openshift_release is correct or absent in inventory before upgrade. --- .../upgrades/v3_1_to_v3_2/pre.yml | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 84b7c817b..e4be39f91 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -22,10 +22,10 @@ ############################################################################### # Pre-upgrade checks ############################################################################### -- name: Verify upgrade can proceed +- name: Verify upgrade can proceed on first master hosts: oo_first_master vars: - target_version: "{{ '1.2' if deployment_type == 'origin' else '3.1.1.900' }}" + target_version: "{{ '1.2' if deployment_type == 'origin' else '3.2' }}" g_pacemaker_upgrade_url_segment: "{{ 'org/latest' if deployment_type =='origin' else '.com/enterprise/3.1' }}" gather_facts: no tasks: @@ -41,6 +41,11 @@ https://docs.openshift.{{ g_pacemaker_upgrade_url_segment }}/install_config/upgrading/pacemaker_to_native_ha.html when: openshift.master.cluster_method is defined and openshift.master.cluster_method == 'pacemaker' + # Error out in situations where the user has older versions specified in their + # inventory in any of the openshift_release, openshift_image_tag, and + # openshift_pkg_version variables. These must be removed or updated to proceed + # with upgrade. + # TODO: Should we block if you're *over* the next major release version as well? - fail: msg: > openshift_pkg_version is {{ openshift_pkg_version }} which is not a @@ -53,11 +58,22 @@ valid version for a {{ target_version }} upgrade when: openshift_image_tag is defined and openshift_image_tag.split('v',1).1 | version_compare(target_version ,'<') -- name: Verify upgrade can proceed + - fail: + msg: > + openshift_release is {{ openshift_release }} which is not a + valid release for a {{ target_version }} upgrade + when: openshift_release is defined and not openshift_release | version_compare(target_version ,'=') + +- include: ../../../../common/openshift-cluster/initialize_openshift_version.yml + vars: + openshift_release: "3.2" + +- name: Verify upgrade can proceed on masters hosts: oo_masters_to_config roles: - openshift_facts tasks: + - fail: - openshift_facts: role: master local_facts: @@ -84,7 +100,7 @@ enabled: yes when: openshift.master.ha is defined and openshift.master.ha | bool and openshift.common.is_containerized | bool -- name: Verify upgrade can proceed +- name: Verify upgrade can proceed on nodes hosts: oo_nodes_to_config roles: - openshift_facts -- cgit v1.2.3 From dd8501ca8199484531e0a6d2b40139d4085afefa Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 7 Jun 2016 14:37:34 -0300 Subject: Force version to latest 3.2 during upgrade. --- playbooks/common/openshift-cluster/initialize_openshift_version.yml | 2 +- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 4 +++- roles/openshift_version/tasks/main.yml | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_openshift_version.yml b/playbooks/common/openshift-cluster/initialize_openshift_version.yml index 88ec7840b..098558c01 100644 --- a/playbooks/common/openshift-cluster/initialize_openshift_version.yml +++ b/playbooks/common/openshift-cluster/initialize_openshift_version.yml @@ -19,7 +19,7 @@ - debug: var=openshift.common.version - debug: var=openshift_version - set_fact: - openshift_version: "{{ openshift.common.version if openshift.common.version is defined else hostvars[groups.oo_first_master.0].openshift_version }}" + openshift_version: "{{ openshift.common.version if (openshift.common.version is defined and openshift_version is not defined) else hostvars[groups.oo_first_master.0].openshift_version }}" when: inventory_hostname != groups.oo_first_master.0 - debug: var=hostvars[groups.oo_first_master.0].openshift_version - debug: var=openshift.common.version diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index e4be39f91..f9ca26e34 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -66,7 +66,9 @@ - include: ../../../../common/openshift-cluster/initialize_openshift_version.yml vars: - openshift_release: "3.2" + # Force the openshift_version role to 3.2, it will convert this to a more specific variable and + # make sure the openshift_image_tag and openshift_pkg_version are all set appropriately. + openshift_version: "3.2" - name: Verify upgrade can proceed on masters hosts: oo_masters_to_config diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index ee04ad59f..1cfbff1b0 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -26,4 +26,8 @@ - debug: var=openshift_version +# 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. -- cgit v1.2.3 From 258ea62f3bb1bfc89eb4e676c77d1610aa067c43 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 7 Jun 2016 15:17:28 -0300 Subject: Respect image tag/pkg version during upgrade. --- .../openshift-cluster/initialize_openshift_version.yml | 12 +++++++----- .../common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 8 +++++--- roles/openshift_version/tasks/main.yml | 6 +++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_openshift_version.yml b/playbooks/common/openshift-cluster/initialize_openshift_version.yml index 098558c01..972df050c 100644 --- a/playbooks/common/openshift-cluster/initialize_openshift_version.yml +++ b/playbooks/common/openshift-cluster/initialize_openshift_version.yml @@ -13,14 +13,16 @@ # 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: + hosts: oo_all_hosts:!oo_first_master + vars: + openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift_version }}" + roles: + - openshift_version + pre_tasks: - debug: var=hostvars[groups.oo_first_master.0].openshift_version - debug: var=openshift.common.version - debug: var=openshift_version - - set_fact: - openshift_version: "{{ openshift.common.version if (openshift.common.version is defined and openshift_version is not defined) else hostvars[groups.oo_first_master.0].openshift_version }}" - when: inventory_hostname != groups.oo_first_master.0 + post_tasks: - debug: var=hostvars[groups.oo_first_master.0].openshift_version - debug: var=openshift.common.version - debug: var=openshift_version diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index f9ca26e34..8596443c0 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -66,9 +66,11 @@ - include: ../../../../common/openshift-cluster/initialize_openshift_version.yml vars: - # Force the openshift_version role to 3.2, it will convert this to a more specific variable and - # make sure the openshift_image_tag and openshift_pkg_version are all set appropriately. - openshift_version: "3.2" + # Request openshift_release 3.2 and let the openshift_version role handle converting this + # to a more specific version, respecting openshift_image_tag and openshift_pkg_version if + # defined, and overriding the normal behavior of protecting the installed version + openshift_release: "3.2" + openshift_protect_installed_version: False - name: Verify upgrade can proceed on masters hosts: oo_masters_to_config diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 1cfbff1b0..39accf579 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -9,12 +9,12 @@ - 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. +# 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 and openshift_version is not defined + when: openshift.common.version is defined and openshift_version is not defined and openshift_protect_installed_version - name: Set openshift_version for rpm installation include: set_version_rpm.yml -- cgit v1.2.3 From 096cf64128ebcb1249044a1cb28b1b06154766ae Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 9 Jun 2016 08:08:49 -0300 Subject: Begin major simplification of 3.2 upgrade. --- .../upgrades/v3_1_to_v3_2/pre.yml | 97 ++++++---------------- 1 file changed, 24 insertions(+), 73 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 8596443c0..03b4bd751 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -77,7 +77,6 @@ roles: - openshift_facts tasks: - - fail: - openshift_facts: role: master local_facts: @@ -116,22 +115,20 @@ enabled: yes when: openshift.common.is_containerized | bool -- name: Verify upgrade can proceed +- name: Verify upgrade can proceed on masters and nodes hosts: oo_masters_to_config:oo_nodes_to_config vars: - target_version: "{{ '1.2' if deployment_type == 'origin' else '3.1.1.900' }}" + target_version: "{{ '1.2' if deployment_type == 'origin' else '3.2' }}" openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" - upgrading: True - handlers: - - include: ../../../../../roles/openshift_master/handlers/main.yml - - include: ../../../../../roles/openshift_node/handlers/main.yml - roles: - # We want the cli role to evaluate so that the containerized oc/oadm wrappers - # are modified to use the correct image tag. However, this can trigger a - # docker restart if new configuration is laid down which would immediately - # pull the latest image and defeat the purpose of these tasks. - - { role: openshift_cli } pre_tasks: + - fail: + msg: Verify OpenShift is already installed + when: openshift.common.version is not defined + + - fail: + msg: Verify the correct version was found + when: verify_upgrade_version is defined and openshift_version != verify_upgrade_version + - name: Clean package cache command: "{{ ansible_pkg_mgr }} clean all" when: not openshift.common.is_atomic | bool @@ -140,60 +137,17 @@ g_new_service_name: "{{ 'origin' if deployment_type =='origin' else 'atomic-openshift' }}" when: not openshift.common.is_containerized | bool - - name: Determine available versions - script: ../files/rpm_versions.sh {{ g_new_service_name }} - register: g_rpm_versions_result - when: not openshift.common.is_containerized | bool - - - debug: var=g_rpm_versions_result - - - set_fact: - g_aos_versions: "{{ g_rpm_versions_result.stdout | from_yaml }}" - when: not openshift.common.is_containerized | bool - - - name: Determine available versions - script: ../files/openshift_container_versions.sh {{ openshift.common.service_type }} - register: g_containerized_versions_result - when: openshift.common.is_containerized | bool - - - set_fact: - g_aos_versions: "{{ g_containerized_versions_result.stdout | from_yaml }}" + - name: Verify containers are available for upgrade + command: > + docker pull {{ openshift.common.cli_image }}:v{{ openshift_version }} when: openshift.common.is_containerized | bool - - set_fact: - g_new_version: "{{ g_aos_versions.curr_version.split('-', 1).0 if g_aos_versions.avail_version is none else g_aos_versions.avail_version.split('-', 1).0 }}" - when: openshift_pkg_version is not defined - - - set_fact: - g_new_version: "{{ openshift_pkg_version | replace('-','') }}" - when: openshift_pkg_version is defined - - - set_fact: - g_new_version: "{{ openshift_image_tag | replace('v','') }}" - when: openshift_image_tag is defined - - - fail: - msg: Verifying the correct version was found - when: g_aos_versions.curr_version == "" - - - fail: - msg: Verifying the correct version was found - when: verify_upgrade_version is defined and g_new_version != verify_upgrade_version - - - include_vars: ../../../../../roles/openshift_master/vars/main.yml - when: inventory_hostname in groups.oo_masters_to_config - - - name: Update systemd units - include: ../../../../../roles/openshift_master/tasks/systemd_units.yml openshift_version=v{{ g_new_version }} - when: inventory_hostname in groups.oo_masters_to_config - - - include_vars: ../../../../../roles/openshift_node/vars/main.yml - when: inventory_hostname in groups.oo_nodes_to_config - - - name: Update systemd units - include: ../../../../../roles/openshift_node/tasks/systemd_units.yml openshift_version=v{{ g_new_version }} - when: inventory_hostname in groups.oo_nodes_to_config + - name: Verify RPMs are available for upgrade + command: > + yum list available -e 0 -q "{{ g_new_service_name }}" 2>&1 | tail -n +2 | grep -v 'el7ose' | awk '{ print $2 }' | sort -r | tr '\n' ' ') + when: not openshift.common.is_containerized | bool + # TODO: Are these two grep checks necessary anymore? # Note: the version number is hardcoded here in hopes of catching potential # bugs in how g_aos_versions.curr_version is set - name: Verifying the correct version is installed for upgrade @@ -208,19 +162,15 @@ with_items: - /etc/systemd/system/openvswitch.service - /etc/systemd/system/{{ openshift.common.service_type }}*.service - when: openshift.common.is_containerized | bool - - - fail: - msg: This playbook requires Origin 1.1 or later - when: deployment_type == 'origin' and g_aos_versions.curr_version | version_compare('1.1','<') + when: openshift.common.is_containerized | bool and verify_upgrade_version is defined - fail: - msg: This playbook requires Atomic Enterprise Platform/OpenShift Enterprise 3.1 or later - when: deployment_type == 'atomic-openshift' and g_aos_versions.curr_version | version_compare('3.1','<') + msg: This upgrade playbook must be run on Origin 1.1 or later + when: deployment_type == 'origin' and openshift.common.version | version_compare('1.1','<') - fail: - msg: Upgrade packages not found - when: openshift_image_tag is not defined and (g_aos_versions.avail_version | default(g_aos_versions.curr_version, true) | version_compare(target_version, '<')) + msg: This upgrade playbook must be run on OpenShift Enterprise 3.1 or later + when: deployment_type == 'atomic-openshift' and openshift.common.version | version_compare('3.1','<') - name: Determine available Docker script: ../files/rpm_versions.sh docker @@ -240,6 +190,7 @@ g_docker_version: "{{ g_atomic_docker_version_result.stdout | from_yaml }}" when: openshift.common.is_atomic | bool + # TODO: Update to 1.10 once branch merges - fail: msg: This playbook requires access to Docker 1.9 or later when: g_docker_version.avail_version | default(g_docker_version.curr_version, true) | version_compare('1.9','<') -- cgit v1.2.3 From bcf414e8b559d35909f26420d9e7dec3cd0a1897 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 9 Jun 2016 12:48:40 -0300 Subject: Fix missing openshift.common.version fact on containerized nodes. --- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 2 ++ roles/openshift_facts/library/openshift_facts.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 42641f2eb..770ccaa78 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -107,7 +107,9 @@ hosts: oo_nodes_to_config roles: - openshift_facts + - openshift_docker_facts tasks: + - debug: var=openshift.docker.openshift_version - name: Ensure Node is running service: name: "{{ openshift.common.service_type }}-node" diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 8824a663c..856dcbdb8 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1138,6 +1138,9 @@ def get_openshift_version(facts): # and is falsely acting like openshift is already installed _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) version = parse_openshift_version(output) + elif 'node' in facts and 'common' in facts and 'is_containerized' in facts['common']: + _, output, _ = module.run_command(['docker', 'run', '--rm', facts['common']['cli_image'], 'version']) + version = parse_openshift_version(output) return version -- cgit v1.2.3 From 755a48c4ebf1061ce19892e5378fba769027bfc1 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 10 Jun 2016 10:21:19 -0300 Subject: Fix version unset bug, and set common ver fact on containerized nodes. --- .../common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 1 - roles/openshift_facts/library/openshift_facts.py | 14 ++++++++++++-- roles/openshift_version/tasks/main.yml | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 770ccaa78..1a3b557e7 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -109,7 +109,6 @@ - openshift_facts - openshift_docker_facts tasks: - - debug: var=openshift.docker.openshift_version - name: Ensure Node is running service: name: "{{ openshift.common.service_type }}-node" diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 856dcbdb8..9d7705af7 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1139,11 +1139,21 @@ def get_openshift_version(facts): _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) version = parse_openshift_version(output) elif 'node' in facts and 'common' in facts and 'is_containerized' in facts['common']: - _, output, _ = module.run_command(['docker', 'run', '--rm', facts['common']['cli_image'], 'version']) - version = parse_openshift_version(output) + version = get_containerized_node_openshift_version(facts) return version +def get_containerized_node_openshift_version(facts): + node_svc = "%s-node" % facts['common']['service_type'] + rc, _, _ = module.run_command(['systemctl', 'is-active', node_svc]) + if rc > 0: + # Node service not running or doesn't exist: + return None + # Node service running, exec in and get the version: + _, output, _ = module.run_command(['docker', 'exec', '-ti', node_svc, 'openshift', 'version']) + return parse_openshift_version(output) + + def parse_openshift_version(output): """ Apply provider facts to supplied facts dict diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 39accf579..29724a9e5 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -4,6 +4,11 @@ - set_fact: is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" +# Make sure we copy this to a fact if given a var: +- set_fact: + openshift_version: "{{ openshift_version }}" + when: openshift_version is defined + - debug: var=openshift_version - debug: var=openshift_release - debug: var=openshift_pkg_version -- cgit v1.2.3 From 3a30afcdfaf115ab0fb455127cdafbe25f52e7ed Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 10 Jun 2016 10:47:46 -0300 Subject: Remove unused docker facts tasks. --- roles/openshift_docker_facts/tasks/main.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/roles/openshift_docker_facts/tasks/main.yml b/roles/openshift_docker_facts/tasks/main.yml index 866b6a5fe..2e68809ca 100644 --- a/roles/openshift_docker_facts/tasks/main.yml +++ b/roles/openshift_docker_facts/tasks/main.yml @@ -38,24 +38,3 @@ - set_fact: docker_options: "{{ openshift.docker.options | default(omit) }}" when: not openshift.docker.hosted_registry_insecure | default(False) | bool - -# Avoid docker 1.9 when installing origin < 1.2 or OSE < 3.2 on RHEL/Centos and -# See: https://bugzilla.redhat.com/show_bug.cgi?id=1304038 -- name: Gather common package version - command: > - {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type}}" - register: common_version - failed_when: false - changed_when: false - when: not openshift.common.is_containerized | bool - -- debug: var=openshift_version - -- set_fact: - l_common_version: "{{ openshift_version | default('0.0', True) | oo_image_tag_to_rpm_version }}" - when: openshift.common.is_containerized | bool - -- set_fact: - l_common_version: "{{ common_version.stdout | default('0.0', True) }}" - when: not openshift.common.is_containerized | bool - -- cgit v1.2.3 From 83ec4f5469b8a64d834bb3f57447c34433302fe3 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 10 Jun 2016 11:46:54 -0300 Subject: Temporary fix for upgrading issue. --- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 1a3b557e7..c2847e163 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -71,6 +71,7 @@ # defined, and overriding the normal behavior of protecting the installed version openshift_release: "3.2" openshift_protect_installed_version: False + upgrading: true - name: Verify master processes hosts: oo_masters_to_config -- cgit v1.2.3 From ef37abd3dd236d1c7129527a057ca2ac6377cb75 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 13 Jun 2016 13:02:32 -0300 Subject: Fix rpm installs. --- roles/openshift_facts/tasks/main.yml | 1 - roles/openshift_version/tasks/main.yml | 16 +++++++++------- roles/openshift_version/tasks/set_version_rpm.yml | 2 ++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/roles/openshift_facts/tasks/main.yml b/roles/openshift_facts/tasks/main.yml index c67f6b86a..ca1a9b1e4 100644 --- a/roles/openshift_facts/tasks/main.yml +++ b/roles/openshift_facts/tasks/main.yml @@ -41,4 +41,3 @@ no_proxy: "{{ openshift_no_proxy | default(None) }}" generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}" no_proxy_internal_hostnames: "{{ openshift_no_proxy_internal_hostnames | default(None) }}" - version_requested: "{{ openshift_version | default(None) }}" diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 29724a9e5..e27add09e 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -9,11 +9,6 @@ openshift_version: "{{ openshift_version }}" when: openshift_version is defined -- debug: var=openshift_version -- debug: var=openshift_release -- debug: var=openshift_pkg_version -- debug: var=openshift_image_tag - # 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 @@ -21,13 +16,20 @@ openshift_version: "{{ openshift.common.version }}" when: openshift.common.version is defined and openshift_version is not defined and openshift_protect_installed_version +- debug: var=is_containerized +- debug: var=openshift_version +- debug: msg="{{ openshift_version is defined }}" +- debug: var=openshift_release +- debug: var=openshift_pkg_version +- debug: var=openshift_image_tag + - name: Set openshift_version for rpm installation include: set_version_rpm.yml - when: not is_containerized + when: not is_containerized | bool - name: Set openshift_version for containerized installation include: set_version_containerized.yml - when: is_containerized + when: is_containerized | bool - debug: var=openshift_version diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index bcf275135..b15f0e993 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -7,6 +7,8 @@ openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" when: openshift_pkg_version is defined and openshift_version is not defined +- debug: var=openshift_version + - name: Gather common package version command: > {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type}}" -- cgit v1.2.3 From ba525e1ebfe44b1993f0b37801122c4030e72d48 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 13 Jun 2016 13:02:41 -0300 Subject: Make openshift_version role docker dep conditional. --- roles/openshift_version/meta/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/openshift_version/meta/main.yml b/roles/openshift_version/meta/main.yml index 8142fe823..bddb20708 100644 --- a/roles/openshift_version/meta/main.yml +++ b/roles/openshift_version/meta/main.yml @@ -14,4 +14,6 @@ galaxy_info: dependencies: - role: openshift_repos - role: openshift_docker_facts + when: openshift.common.is_containerized | default(False) | bool - role: docker + when: openshift.common.is_containerized | default(False) | bool -- cgit v1.2.3 From af2cc5587132427faae21785599280b1f05e6cda Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 13 Jun 2016 15:15:50 -0300 Subject: Restore 3.2 RPM version check before upgrading. --- .../openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 19 +++++++++++++++++-- roles/openshift_version/meta/main.yml | 1 - 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index c2847e163..9cba1b40b 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -144,11 +144,26 @@ docker pull {{ openshift.common.cli_image }}:v{{ openshift_version }} when: openshift.common.is_containerized | bool - - name: Verify RPMs are available for upgrade + - set_fact: + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" + when: not openshift.common.is_containerized | bool + + - name: Check latest available OpenShift RPM version command: > - yum list available -e 0 -q "{{ g_new_service_name }}" 2>&1 | tail -n +2 | grep -v 'el7ose' | awk '{ print $2 }' | sort -r | tr '\n' ' ') + {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type }}" + failed_when: false + changed_when: false + register: avail_openshift_version when: not openshift.common.is_containerized | bool + - debug: var=avail_openshift_version + + - name: Verify OpenShift 3.2 RPMs are available for upgrade + fail: + msg: "OpenShift {{ avail_openshift_version.stdout }} is available, but 3.2 or greater is required" + when: not openshift.common.is_containerized | bool and not avail_openshift_version | skipped and avail_openshift_version.stdout | default('0.0', True) | version_compare('3.2', '<') + + # TODO: Are these two grep checks necessary anymore? # Note: the version number is hardcoded here in hopes of catching potential # bugs in how g_aos_versions.curr_version is set diff --git a/roles/openshift_version/meta/main.yml b/roles/openshift_version/meta/main.yml index bddb20708..70974da17 100644 --- a/roles/openshift_version/meta/main.yml +++ b/roles/openshift_version/meta/main.yml @@ -14,6 +14,5 @@ galaxy_info: dependencies: - role: openshift_repos - role: openshift_docker_facts - when: openshift.common.is_containerized | default(False) | bool - role: docker when: openshift.common.is_containerized | default(False) | bool -- cgit v1.2.3 From b1cabe9584c17fb38f4243054c4a40a5e5522b65 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 13 Jun 2016 15:22:39 -0300 Subject: Don't be specific about rpm version to upgrade to for now. --- .../common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml index 5c96ad094..ea27a40d1 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml @@ -1,5 +1,6 @@ +# TODO: Use a specific version here once we're setting openshift_pkg_version reliably in the openshift_version module. - name: Upgrade packages - command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-{{ component }}-{{ g_new_version }}" + command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-{{ component }}" - name: Ensure python-yaml present for config upgrade action: "{{ ansible_pkg_mgr }} name=PyYAML state=present" -- cgit v1.2.3 From 04643670db5709358fe55916705a9ce15ff0bb1e Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 13 Jun 2016 15:32:10 -0300 Subject: Remove the use of the upgrading variable. --- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 1 - playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml | 1 - roles/openshift_docker/defaults/main.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 9cba1b40b..d0960da76 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -71,7 +71,6 @@ # defined, and overriding the normal behavior of protecting the installed version openshift_release: "3.2" openshift_protect_installed_version: False - upgrading: true - name: Verify master processes hosts: oo_masters_to_config diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index c93bf2a17..7b5b9e8d7 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -132,7 +132,6 @@ origin_reconcile_bindings: "{{ deployment_type == 'origin' and g_new_version | version_compare('1.0.6', '>') }}" ent_reconcile_bindings: true openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" - upgrading: True tasks: - name: Verifying the correct commandline tools are available shell: grep {{ verify_upgrade_version }} {{ openshift.common.admin_binary}} diff --git a/roles/openshift_docker/defaults/main.yml b/roles/openshift_docker/defaults/main.yml index aebef75d6..ed97d539c 100644 --- a/roles/openshift_docker/defaults/main.yml +++ b/roles/openshift_docker/defaults/main.yml @@ -1,2 +1 @@ --- -upgrading: False -- cgit v1.2.3 From a836a35b63ff1476eca5a8545a6c11ab389026d0 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 14 Jun 2016 09:06:39 -0300 Subject: Always populate openshift_image_tag and openshift_pkg_version. Allows the use of arbitrary tags, precise control over containers and rpms, and likely mixed environments. --- .../upgrades/files/openshift_container_versions.sh | 22 -------------------- .../upgrades/v3_1_to_v3_2/pre.yml | 2 +- roles/openshift_ca/tasks/main.yml | 2 +- roles/openshift_cli/tasks/main.yml | 3 +-- roles/openshift_common/tasks/main.yml | 6 +----- roles/openshift_master/tasks/main.yml | 5 ++--- .../templates/atomic-openshift-master.j2 | 2 +- .../native-cluster/atomic-openshift-master-api.j2 | 2 +- .../atomic-openshift-master-controllers.j2 | 2 +- roles/openshift_master_ca/tasks/main.yml | 4 +--- roles/openshift_node/tasks/main.yml | 9 ++++---- roles/openshift_node/tasks/systemd_units.yml | 2 +- .../templates/openvswitch.sysconfig.j2 | 2 +- roles/openshift_version/tasks/main.yml | 24 ++++++++++++++++++++-- .../tasks/set_version_containerized.yml | 4 +++- roles/openshift_version/tasks/set_version_rpm.yml | 2 +- 16 files changed, 42 insertions(+), 51 deletions(-) delete mode 100644 playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh diff --git a/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh b/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh deleted file mode 100644 index 9bbeff660..000000000 --- a/playbooks/common/openshift-cluster/upgrades/files/openshift_container_versions.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Here we don't really care if this is a master, api, controller or node image. -# We just need to know the version of one of them. -unit_file=$(ls /etc/systemd/system/${1}*.service | grep -v node-dep | head -n1) - -if [ ${1} == "origin" ]; then - image_name="openshift/origin" -elif grep aep $unit_file 2>&1 > /dev/null; then - image_name="aep3/node" -elif grep openshift3 $unit_file 2>&1 > /dev/null; then - image_name="openshift3/node" -fi - -installed=$(docker run --rm --entrypoint=/bin/openshift ${image_name} version 2> /dev/null | grep openshift | awk '{ print $2 }' | cut -f1 -d"-" | tr -d 'v') - -docker pull ${image_name} 2>&1 > /dev/null -available=$(docker run --rm --entrypoint=/bin/openshift ${image_name} version 2> /dev/null | grep openshift | awk '{ print $2 }' | cut -f1 -d"-" | tr -d 'v') - -echo "---" -echo "curr_version: ${installed}" -echo "avail_version: ${available}" diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index d0960da76..a5a9a0fec 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -140,7 +140,7 @@ - name: Verify containers are available for upgrade command: > - docker pull {{ openshift.common.cli_image }}:v{{ openshift_version }} + docker pull {{ openshift.common.cli_image }}:{{ openshift_image_tag }} when: openshift.common.is_containerized | bool - set_fact: diff --git a/roles/openshift_ca/tasks/main.yml b/roles/openshift_ca/tasks/main.yml index cd72a4e21..4d9768ce7 100644 --- a/roles/openshift_ca/tasks/main.yml +++ b/roles/openshift_ca/tasks/main.yml @@ -4,7 +4,7 @@ when: openshift_ca_host is not defined - name: Install the base package for admin tooling - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool register: install_result delegate_to: "{{ openshift_ca_host }}" diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml index cdd0564c7..097c05483 100644 --- a/roles/openshift_cli/tasks/main.yml +++ b/roles/openshift_cli/tasks/main.yml @@ -6,10 +6,9 @@ action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-clients state=present" when: not openshift.common.is_containerized | bool -# TODO: handle no openshift_version set? - name: Pull CLI Image command: > - docker pull {{ openshift.common.cli_image }}{{ ':v' + openshift_version if openshift_version is defined and openshift_version != '' else '' }} + docker pull {{ openshift.common.cli_image }}:{{ openshift_image_tag }} when: openshift.common.is_containerized | bool - name: Create /usr/local/bin/openshift cli wrapper diff --git a/roles/openshift_common/tasks/main.yml b/roles/openshift_common/tasks/main.yml index 4ec255dbc..77f3811c1 100644 --- a/roles/openshift_common/tasks/main.yml +++ b/roles/openshift_common/tasks/main.yml @@ -29,12 +29,8 @@ data_dir: "{{ openshift_data_dir | default(None) }}" use_dnsmasq: "{{ openshift_use_dnsmasq | default(None) }}" -# Using oo_image_tag_to_rpm_version here is a workaround for how -# openshift_version is set. That value is computed based on either RPM -# versions or image tags. openshift_common's usage requires that it be a RPM -# version and openshift_cli expects it to be an image tag. - name: Install the base package for versioning - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool - name: Set version facts diff --git a/roles/openshift_master/tasks/main.yml b/roles/openshift_master/tasks/main.yml index 6b3893570..7a80ed8e3 100644 --- a/roles/openshift_master/tasks/main.yml +++ b/roles/openshift_master/tasks/main.yml @@ -1,7 +1,6 @@ --- # TODO: add ability to configure certificates given either a local file to # point to or certificate contents, set in default cert locations. -- debug: var=openshift_version # Authentication Variable Validation # TODO: validate the different identity provider kinds as well @@ -25,12 +24,12 @@ when: openshift_master_ha | bool and openshift_master_cluster_method == "pacemaker" and openshift.common.is_containerized | bool - name: Install Master package - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool - name: Pull master image command: > - docker pull {{ openshift.master.master_image }}{{ ':v' + openshift_version if openshift_version is defined and openshift_version != '' else '' }} + docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }} when: openshift.common.is_containerized | bool - name: Create openshift.common.data_dir diff --git a/roles/openshift_master/templates/atomic-openshift-master.j2 b/roles/openshift_master/templates/atomic-openshift-master.j2 index ba2974476..fb9e7c13c 100644 --- a/roles/openshift_master/templates/atomic-openshift-master.j2 +++ b/roles/openshift_master/templates/atomic-openshift-master.j2 @@ -1,7 +1,7 @@ OPTIONS=--loglevel={{ openshift.master.debug_level }} CONFIG_FILE={{ openshift_master_config_file }} {% if openshift.common.is_containerized | bool %} -IMAGE_VERSION=v{{ openshift_version }} +IMAGE_VERSION={{ openshift_image_tag }} {% endif %} {% if 'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws %} diff --git a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 index 36e4446b9..fe439a7b8 100644 --- a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 +++ b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-api.j2 @@ -1,7 +1,7 @@ OPTIONS=--loglevel={{ openshift.master.debug_level }} --listen={{ 'https' if openshift.master.api_use_ssl else 'http' }}://{{ openshift.master.bind_addr }}:{{ openshift.master.api_port }} --master={{ openshift.master.loopback_api_url }} CONFIG_FILE={{ openshift_master_config_file }} {% if openshift.common.is_containerized | bool %} -IMAGE_VERSION=v{{ openshift_version }} +IMAGE_VERSION={{ openshift_image_tag }} {% endif %} {% if 'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws %} diff --git a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 index ca3ae0ef8..44101ea42 100644 --- a/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 +++ b/roles/openshift_master/templates/native-cluster/atomic-openshift-master-controllers.j2 @@ -1,7 +1,7 @@ OPTIONS=--loglevel={{ openshift.master.debug_level }} --listen={{ 'https' if openshift.master.api_use_ssl else 'http' }}://{{ openshift.master.bind_addr }}:{{ openshift.master.controllers_port }} CONFIG_FILE={{ openshift_master_config_file }} {% if openshift.common.is_containerized | bool %} -IMAGE_VERSION=v{{ openshift_version }} +IMAGE_VERSION={{ openshift_image_tag }} {% endif %} {% if 'cloudprovider' in openshift and 'aws' in openshift.cloudprovider and 'kind' in openshift.cloudprovider and openshift.cloudprovider.kind == 'aws' and 'access_key' in openshift.cloudprovider.aws and 'secret_key' in openshift.cloudprovider.aws %} diff --git a/roles/openshift_master_ca/tasks/main.yml b/roles/openshift_master_ca/tasks/main.yml index 613aecc38..ae99467f0 100644 --- a/roles/openshift_master_ca/tasks/main.yml +++ b/roles/openshift_master_ca/tasks/main.yml @@ -1,9 +1,7 @@ --- -- debug: msg="{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }}" - - name: Install the base package for admin tooling - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool register: install_result diff --git a/roles/openshift_node/tasks/main.yml b/roles/openshift_node/tasks/main.yml index 36f69645f..60d5081d3 100644 --- a/roles/openshift_node/tasks/main.yml +++ b/roles/openshift_node/tasks/main.yml @@ -1,5 +1,4 @@ --- -- debug: var=openshift_version # TODO: allow for overriding default ports where possible - fail: msg: "SELinux is disabled, This deployment type requires that SELinux is enabled." @@ -31,21 +30,21 @@ # We have to add tuned-profiles in the same transaction otherwise we run into depsolving # problems because the rpms don't pin the version properly. This was fixed in 3.1 packaging. - name: Install Node package - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }},tuned-profiles-{{ openshift.common.service_type }}-node{{ openshift_pkg_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: not openshift.common.is_containerized | bool - name: Install sdn-ovs package - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_version | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-sdn-ovs{{ openshift_pkg_version | oo_image_tag_to_rpm_version(include_dash=True) }} state=present" when: openshift.common.use_openshift_sdn and not openshift.common.is_containerized | bool - name: Pull node image command: > - docker pull {{ openshift.node.node_image }}{{ ':v' + openshift_version if openshift_version is defined and openshift_version != '' else '' }} + docker pull {{ openshift.node.node_image }}:{{ openshift_image_tag }} when: openshift.common.is_containerized | bool - name: Pull OpenVSwitch image command: > - docker pull {{ openshift.node.ovs_image }}{{ ':v' + openshift_version if openshift_version is defined and openshift_version != '' else '' }} + docker pull {{ openshift.node.ovs_image }}:{{ openshift_image_tag }} when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool - name: Install the systemd units diff --git a/roles/openshift_node/tasks/systemd_units.yml b/roles/openshift_node/tasks/systemd_units.yml index 0117a5a02..39e5386d4 100644 --- a/roles/openshift_node/tasks/systemd_units.yml +++ b/roles/openshift_node/tasks/systemd_units.yml @@ -44,6 +44,6 @@ - regex: '^CONFIG_FILE=' line: "CONFIG_FILE={{ openshift_node_config_file }}" - regex: '^IMAGE_VERSION=' - line: "IMAGE_VERSION=v{{ openshift_version }}" + line: "IMAGE_VERSION={{ openshift_image_tag }}" notify: - restart node diff --git a/roles/openshift_node/templates/openvswitch.sysconfig.j2 b/roles/openshift_node/templates/openvswitch.sysconfig.j2 index 53163b359..da7c3742a 100644 --- a/roles/openshift_node/templates/openvswitch.sysconfig.j2 +++ b/roles/openshift_node/templates/openvswitch.sysconfig.j2 @@ -1 +1 @@ -IMAGE_VERSION=v{{ openshift_version }} +IMAGE_VERSION={{ openshift_image_tag }} diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index e27add09e..d896eb151 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -31,10 +31,30 @@ include: set_version_containerized.yml when: is_containerized | bool -- debug: var=openshift_version - # 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. +- set_fact: + openshift_image_tag: v{{ openshift_version }} + when: openshift_image_tag is not defined + +- set_fact: + openshift_pkg_version: -{{ openshift_version }} + when: openshift_pkg_version is not defined + +# TODO: fail if any of these is unset or looks wrong: +- debug: var=openshift_version +- debug: var=openshift_pkg_version +- debug: var=openshift_image_tag + +- fail: openshift_version role was unable to set openshift_version + when: openshift_version is not defined + +- fail: openshift_version role was unable to set openshift_image_tag + when: openshift_image_tag is not defined + +- fail: openshift_version role was unable to set openshift_pkg_version + when: openshift_pkg_version is not defined + diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index fc15b2d35..6d31d0ddc 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -1,7 +1,9 @@ --- - name: Set containerized version to configure if openshift_image_tag specified set_fact: - openshift_version: "{{ openshift_image_tag.split('v',1)[1] }}" + # Expects a leading "v" in inventory, strip it off here: + # openshift_version should always just be "3.2" or "3.2.0.44" + openshift_version: "{{ openshift_image_tag[1:].split('-')[0] }}" when: openshift_image_tag is defined and openshift_version is not defined - name: Set containerized version to configure if openshift_release specified diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index b15f0e993..90229b0e9 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -2,7 +2,7 @@ # 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, + # Expects a leading "-" in inventory, strip it off here, and remove 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 and openshift_version is not defined -- cgit v1.2.3 From b26b6f8c5bd0767495ee3d256f0772e769029923 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 15 Jun 2016 10:24:00 -0300 Subject: Fix performance hit in openshift_facts. --- roles/openshift_facts/library/openshift_facts.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 9d7705af7..97cca2e5c 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1133,11 +1133,6 @@ def get_openshift_version(facts): if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) - elif os.path.isfile('/usr/local/bin/openshift'): - # TODO: this should probably make sure the actual image is already present, this can take awhile if it has to pull - # and is falsely acting like openshift is already installed - _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) - version = parse_openshift_version(output) elif 'node' in facts and 'common' in facts and 'is_containerized' in facts['common']: version = get_containerized_node_openshift_version(facts) -- cgit v1.2.3 From 739ad9de2a11bb8c67d77641a86cfd39e4594542 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 15 Jun 2016 10:56:29 -0300 Subject: Remove old upgrade playbooks. --- .../upgrades/v3_0_to_v3_1/upgrade.yml | 16 - .../upgrades/v3_0_minor/upgrade.yml | 28 - .../upgrades/v3_0_to_v3_1/upgrade.yml | 28 - .../upgrades/v3_1_minor/upgrade.yml | 32 - .../upgrades/v3_0_minor/upgrade.yml | 113 ---- .../upgrades/v3_0_to_v3_1/upgrade.yml | 645 --------------------- .../upgrades/v3_1_minor/upgrade.yml | 140 ----- 7 files changed, 1002 deletions(-) delete mode 100644 playbooks/aws/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_0_minor/upgrade.yml delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_1_minor/upgrade.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_minor/upgrade.yml diff --git a/playbooks/aws/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml b/playbooks/aws/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml deleted file mode 100644 index 44d9a3e25..000000000 --- a/playbooks/aws/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -# Usage: -# ansible-playbook playbooks/aws/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml -e deployment_type= -e cluster_id= -- include: ../../../../common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml - vars_files: - - "{{lookup('file', '../../../../aws/openshift-cluster/vars.yml')}}" - - "{{lookup('file', '../../../../aws/openshift-cluster/cluster_hosts.yml')}}" - vars: - g_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}" - g_sudo: "{{ deployment_vars[deployment_type].become }}" - g_nodeonmaster: true - openshift_cluster_id: "{{ cluster_id }}" - openshift_debug_level: "{{ debug_level }}" - openshift_deployment_type: "{{ deployment_type }}" - openshift_hostname: "{{ ec2_private_ip_address }}" - openshift_public_hostname: "{{ ec2_ip_address }}" diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/upgrade.yml deleted file mode 100644 index 76bfff9b6..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/upgrade.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - name: Verify Ansible version is greater than or equal to 1.9.4 and less than 2.0 - fail: - msg: "Unsupported ansible version: {{ ansible_version }} found." - when: ansible_version.full | version_compare('1.9.4', 'lt') or ansible_version.full | version_compare('2.0', 'ge') - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - - add_host: - name: "{{ item }}" - groups: l_oo_all_hosts - with_items: g_all_hosts - -- hosts: l_oo_all_hosts - gather_facts: no - tasks: - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - -- include: ../../../../common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml - vars: - # Do not allow adding hosts during upgrade. - g_new_master_hosts: [] - g_new_node_hosts: [] - openshift_cluster_id: "{{ cluster_id | default('default') }}" - openshift_deployment_type: "{{ deployment_type }}" diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml deleted file mode 100644 index c17446162..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - name: Verify Ansible version is greater than or equal to 1.9.4 and less than 2.0 - fail: - msg: "Unsupported ansible version: {{ ansible_version }} found." - when: ansible_version.full | version_compare('1.9.4', 'lt') or ansible_version.full | version_compare('2.0', 'ge') - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - - add_host: - name: "{{ item }}" - groups: l_oo_all_hosts - with_items: g_all_hosts - -- hosts: l_oo_all_hosts - gather_facts: no - tasks: - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - -- include: ../../../../common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml - vars: - # Do not allow adding hosts during upgrade. - g_new_master_hosts: [] - g_new_node_hosts: [] - openshift_cluster_id: "{{ cluster_id | default('default') }}" - openshift_deployment_type: "{{ deployment_type }}" diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/upgrade.yml deleted file mode 100644 index 99592d85a..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/upgrade.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - name: Verify Ansible version is greater than or equal to 1.9.4 and less than 2.0 - fail: - msg: "Unsupported ansible version: {{ ansible_version }} found." - when: ansible_version.full | version_compare('1.9.4', 'lt') or ansible_version.full | version_compare('2.0', 'ge') - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - - add_host: - name: "{{ item }}" - groups: l_oo_all_hosts - with_items: g_all_hosts - -- hosts: l_oo_all_hosts - gather_facts: no - tasks: - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - -- include: ../../../../common/openshift-cluster/evaluate_groups.yml - vars: - # Do not allow adding hosts during upgrade. - g_new_master_hosts: [] - g_new_node_hosts: [] - openshift_cluster_id: "{{ cluster_id | default('default') }}" - openshift_deployment_type: "{{ deployment_type }}" -- include: ../../../../common/openshift-cluster/upgrades/v3_1_minor/pre.yml -- include: ../../../../common/openshift-cluster/upgrades/v3_1_minor/upgrade.yml -- include: ../../../openshift-master/restart.yml -- include: ../../../../common/openshift-cluster/upgrades/v3_1_minor/post.yml diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml deleted file mode 100644 index 5b2bf9f93..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml +++ /dev/null @@ -1,113 +0,0 @@ ---- -- name: Evaluate groups - include: ../../evaluate_groups.yml - -- name: Re-Run cluster configuration to apply latest configuration changes - include: ../../config.yml - -- name: Upgrade masters - hosts: oo_masters_to_config - vars: - openshift_version: "{{ openshift_pkg_version | default('') }}" - tasks: - - name: Upgrade master packages - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-master{{ openshift_version }} state=latest" - - name: Restart master services - service: name="{{ openshift.common.service_type}}-master" state=restarted - -- name: Upgrade nodes - hosts: oo_nodes_to_config - vars: - openshift_version: "{{ openshift_pkg_version | default('') }}" - tasks: - - name: Upgrade node packages - action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-node{{ openshift_version }} state=latest" - - name: Restart node services - service: name="{{ openshift.common.service_type }}-node" state=restarted - -- name: Determine new master version - hosts: oo_first_master - tasks: - - name: Determine new version - command: > - rpm -q --queryformat '%{version}' {{ openshift.common.service_type }}-master - register: _new_version - -- name: Ensure AOS 3.0.2 or Origin 1.0.6 - hosts: oo_first_master - tasks: - - fail: - msg: "This playbook requires Origin 1.0.6 or Atomic OpenShift 3.0.2 or later" - when: _new_version.stdout | version_compare('1.0.6','<') or ( _new_version.stdout | version_compare('3.0','>=' and _new_version.stdout | version_compare('3.0.2','<') ) - -- name: Update cluster policy - hosts: oo_first_master - tasks: - - name: oadm policy reconcile-cluster-roles --additive-only=true --confirm - command: > - {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig - policy reconcile-cluster-roles --additive-only=true --confirm - -- name: Upgrade default router - hosts: oo_first_master - vars: - - router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', 'v' + _new_version.stdout ) }}" - - oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig" - tasks: - - name: Check for default router - command: > - {{ oc_cmd }} get -n default dc/router - register: _default_router - failed_when: false - changed_when: false - - name: Check for allowHostNetwork and allowHostPorts - when: _default_router.rc == 0 - shell: > - {{ oc_cmd }} get -o yaml scc/privileged | /usr/bin/grep -e allowHostPorts -e allowHostNetwork - register: _scc - - name: Grant allowHostNetwork and allowHostPorts - when: - - _default_router.rc == 0 - - "'false' in _scc.stdout" - command: > - {{ oc_cmd }} patch scc/privileged -p '{"allowHostPorts":true,"allowHostNetwork":true}' --loglevel=9 - - name: Update deployment config to 1.0.4/3.0.1 spec - when: _default_router.rc == 0 - command: > - {{ oc_cmd }} patch dc/router -p - '{"spec":{"strategy":{"rollingParams":{"updatePercent":-10},"spec":{"serviceAccount":"router","serviceAccountName":"router"}}}}' - - name: Switch to hostNetwork=true - when: _default_router.rc == 0 - command: > - {{ oc_cmd }} patch dc/router -p '{"spec":{"template":{"spec":{"hostNetwork":true}}}}' - - name: Update router image to current version - when: _default_router.rc == 0 - command: > - {{ oc_cmd }} patch dc/router -p - '{"spec":{"template":{"spec":{"containers":[{"name":"router","image":"{{ router_image }}"}]}}}}' - -- name: Upgrade default - hosts: oo_first_master - vars: - - registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', 'v' + _new_version.stdout ) }}" - - oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig" - tasks: - - name: Check for default registry - command: > - {{ oc_cmd }} get -n default dc/docker-registry - register: _default_registry - failed_when: false - changed_when: false - - name: Update registry image to current version - when: _default_registry.rc == 0 - command: > - {{ oc_cmd }} patch dc/docker-registry -p - '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}' - -- name: Update image streams and templates - hosts: oo_first_master - vars: - openshift_examples_import_command: "update" - openshift_deployment_type: "{{ deployment_type }}" - roles: - - openshift_examples diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml deleted file mode 100644 index 3a4c58e43..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml +++ /dev/null @@ -1,645 +0,0 @@ ---- -############################################################################### -# Evaluate host groups and gather facts -############################################################################### -- name: Evaluate host groups - include: ../../evaluate_groups.yml - -- name: Load openshift_facts - hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config:oo_lb_to_config - roles: - - openshift_facts - -- name: Evaluate additional groups for upgrade - hosts: localhost - connection: local - become: no - tasks: - - name: Evaluate etcd_hosts_to_backup - add_host: - name: "{{ item }}" - groups: etcd_hosts_to_backup - with_items: groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else groups.oo_first_master - - -############################################################################### -# Pre-upgrade checks -############################################################################### -- name: Verify upgrade can proceed - hosts: oo_first_master - vars: - openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}" - target_version: "{{ '1.1' if deployment_type == 'origin' else '3.1' }}" - gather_facts: no - tasks: - # Pacemaker is currently the only supported upgrade path for multiple masters - - fail: - msg: "openshift_master_cluster_method must be set to 'pacemaker'" - when: openshift_master_ha | bool and ((openshift_master_cluster_method is not defined) or (openshift_master_cluster_method is defined and openshift_master_cluster_method != "pacemaker")) - - - fail: - msg: > - This upgrade is only supported for origin, openshift-enterprise, and online - deployment types - when: deployment_type not in ['origin','openshift-enterprise', 'online'] - - - fail: - msg: > - openshift_pkg_version is {{ openshift_pkg_version }} which is not a - valid version for a {{ target_version }} upgrade - when: openshift_pkg_version is defined and openshift_pkg_version.split('-',1).1 | version_compare(target_version ,'<') - - # If this script errors out ansible will show the default stdout/stderr - # which contains details for the user: - - script: ../files/pre-upgrade-check - - -- name: Verify upgrade targets - hosts: oo_masters_to_config:oo_nodes_to_config - vars: - target_version: "{{ '1.1' if deployment_type == 'origin' else '3.1' }}" - tasks: - - name: Clean package cache - command: "{{ ansible_pkg_mgr }} clean all" - - - set_fact: - g_new_service_name: "{{ 'origin' if deployment_type =='origin' else 'atomic-openshift' }}" - - - name: Determine available versions - script: ../files/rpm_versions.sh {{ g_new_service_name }} openshift - register: g_versions_result - - - set_fact: - g_aos_versions: "{{ g_versions_result.stdout | from_yaml }}" - - - set_fact: - g_new_version: "{{ g_aos_versions.curr_version.split('-', 1).0 if g_aos_versions.avail_version is none else g_aos_versions.avail_version.split('-', 1).0 }}" - when: openshift_pkg_version is not defined - - - set_fact: - g_new_version: "{{ openshift_pkg_version | replace('-','') }}" - when: openshift_pkg_version is defined - - - fail: - msg: This playbook requires Origin 1.0.6 or later - when: deployment_type == 'origin' and g_aos_versions.curr_version | version_compare('1.0.6','<') - - - fail: - msg: Upgrade packages not found - when: (g_aos_versions.avail_version | default(g_aos_versions.curr_version, true) | version_compare(target_version, '<')) - - - set_fact: - pre_upgrade_complete: True - - -############################################################################## -# Gate on pre-upgrade checks -############################################################################## -- name: Gate on pre-upgrade checks - hosts: localhost - connection: local - become: no - vars: - pre_upgrade_hosts: "{{ groups.oo_masters_to_config | union(groups.oo_nodes_to_config) }}" - tasks: - - set_fact: - pre_upgrade_completed: "{{ hostvars - | oo_select_keys(pre_upgrade_hosts) - | oo_collect('inventory_hostname', {'pre_upgrade_complete': true}) }}" - - set_fact: - pre_upgrade_failed: "{{ pre_upgrade_hosts | difference(pre_upgrade_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following hosts did not complete pre-upgrade checks: {{ pre_upgrade_failed | join(',') }}" - when: pre_upgrade_failed | length > 0 - - - -############################################################################### -# Backup etcd -############################################################################### -- name: Backup etcd - hosts: etcd_hosts_to_backup - vars: - embedded_etcd: "{{ openshift.master.embedded_etcd }}" - timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}" - roles: - - openshift_facts - tasks: - # Ensure we persist the etcd role for this host in openshift_facts - - openshift_facts: - role: etcd - local_facts: {} - when: "'etcd' not in openshift" - - - stat: path=/var/lib/openshift - register: var_lib_openshift - - - stat: path=/var/lib/origin - register: var_lib_origin - - - name: Create origin symlink if necessary - file: src=/var/lib/openshift/ dest=/var/lib/origin state=link - when: var_lib_openshift.stat.exists == True and var_lib_origin.stat.exists == False - - # TODO: replace shell module with command and update later checks - # We assume to be using the data dir for all backups. - - name: Check available disk space for etcd backup - shell: df --output=avail -k {{ openshift.common.data_dir }} | tail -n 1 - register: avail_disk - - # TODO: replace shell module with command and update later checks - - name: Check current embedded etcd disk usage - shell: du -k {{ openshift.etcd.etcd_data_dir }} | tail -n 1 | cut -f1 - register: etcd_disk_usage - when: embedded_etcd | bool - - - name: Abort if insufficient disk space for etcd backup - fail: - msg: > - {{ etcd_disk_usage.stdout }} Kb disk space required for etcd backup, - {{ avail_disk.stdout }} Kb available. - when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int) - - - name: Install etcd (for etcdctl) - action: "{{ ansible_pkg_mgr }} name=etcd state=latest" - - - name: Generate etcd backup - command: > - etcdctl backup --data-dir={{ openshift.etcd.etcd_data_dir }} - --backup-dir={{ openshift.common.data_dir }}/etcd-backup-{{ timestamp }} - - - set_fact: - etcd_backup_complete: True - - - name: Display location of etcd backup - debug: - msg: "Etcd backup created in {{ openshift.common.data_dir }}/etcd-backup-{{ timestamp }}" - - -############################################################################## -# Gate on etcd backup -############################################################################## -- name: Gate on etcd backup - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - etcd_backup_completed: "{{ hostvars - | oo_select_keys(groups.etcd_hosts_to_backup) - | oo_collect('inventory_hostname', {'etcd_backup_complete': true}) }}" - - set_fact: - etcd_backup_failed: "{{ groups.etcd_hosts_to_backup | difference(etcd_backup_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following hosts did not complete etcd backup: {{ etcd_backup_failed | join(',') }}" - when: etcd_backup_failed | length > 0 - - - -############################################################################### -# Upgrade Masters -############################################################################### -- name: Create temp directory for syncing certs - hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - name: Create local temp directory for syncing certs - local_action: command mktemp -d /tmp/openshift-ansible-XXXXXXX - register: g_master_mktemp - changed_when: False - -- name: Update deployment type - hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config - vars: - openshift_deployment_type: "{{ deployment_type }}" - roles: - - openshift_facts - -- name: Update master facts - hosts: oo_masters_to_config - roles: - - openshift_facts - post_tasks: - - openshift_facts: - role: master - local_facts: - cluster_method: "{{ openshift_master_cluster_method | default(None) }}" - -- name: Upgrade master packages and configuration - hosts: oo_masters_to_config - vars: - openshift_version: "{{ openshift_pkg_version | default('') }}" - roles: - - openshift_facts - tasks: - - name: Upgrade to latest available kernel - action: "{{ ansible_pkg_mgr}} name=kernel state=latest" - - - name: Upgrade master packages - command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-master{{ openshift_version }}" - when: openshift_pkg_version is not defined - - - name: Upgrade packages - command: "{{ ansible_pkg_mgr}} install -y {{ openshift.common.installed_variant_rpms | oo_31_rpm_rename_conversion(openshift_version) | join (' ')}}" - when: openshift_pkg_version is defined and deployment_type == 'openshift-enterprise' - - - name: Ensure python-yaml present for config upgrade - action: "{{ ansible_pkg_mgr }} name=PyYAML state=present" - when: not openshift.common.is_atomic | bool - - - name: Upgrade master configuration - openshift_upgrade_config: - from_version: '3.0' - to_version: '3.1' - role: master - config_base: "{{ hostvars[inventory_hostname].openshift.common.config_base }}" - - - set_fact: - openshift_master_certs_no_etcd: - - admin.crt - - master.kubelet-client.crt - - "{{ 'master.proxy-client.crt' if openshift.common.version_gte_3_1_or_1_1 else omit }}" - - master.server.crt - - openshift-master.crt - - openshift-registry.crt - - openshift-router.crt - - etcd.server.crt - openshift_master_certs_etcd: - - master.etcd-client.crt - - - set_fact: - openshift_master_certs: "{{ (openshift_master_certs_no_etcd | union(openshift_master_certs_etcd)) if (groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config) else openshift_master_certs_no_etcd }}" - - - name: Check status of master certificates - stat: - path: "{{ openshift.common.config_base }}/master/{{ item }}" - with_items: openshift_master_certs - register: g_master_cert_stat_result - - - set_fact: - master_certs_missing: "{{ False in (g_master_cert_stat_result.results - | oo_collect(attribute='stat.exists') - | list ) }}" - master_cert_subdir: master-{{ openshift.common.hostname }} - master_cert_config_dir: "{{ openshift.common.config_base }}/master" - - -- name: Generate missing master certificates - hosts: oo_first_master - vars: - master_hostnames: "{{ hostvars - | oo_select_keys(groups.oo_masters_to_config) - | oo_collect('openshift.common.all_hostnames') - | oo_flatten | unique }}" - master_generated_certs_dir: "{{ openshift.common.config_base }}/generated-configs" - masters_needing_certs: "{{ hostvars - | oo_select_keys(groups['oo_masters_to_config'] | difference(groups['oo_first_master'])) - | oo_filter_list(filter_attr='master_certs_missing') }}" - sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - openshift_deployment_type: "{{ deployment_type }}" - roles: - - openshift_master_certificates - post_tasks: - - name: Remove generated etcd client certs when using external etcd - file: - path: "{{ master_generated_certs_dir }}/{{ item.0.master_cert_subdir }}/{{ item.1 }}" - state: absent - when: groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config - with_nested: - - masters_needing_certs - - - master.etcd-client.crt - - master.etcd-client.key - - - name: Create a tarball of the master certs - command: > - tar -czvf {{ master_generated_certs_dir }}/{{ item.master_cert_subdir }}.tgz - -C {{ master_generated_certs_dir }}/{{ item.master_cert_subdir }} . - with_items: masters_needing_certs - - - name: Retrieve the master cert tarball from the master - fetch: - src: "{{ master_generated_certs_dir }}/{{ item.master_cert_subdir }}.tgz" - dest: "{{ sync_tmpdir }}/" - flat: yes - fail_on_missing: yes - validate_checksum: yes - with_items: masters_needing_certs - - -- name: Sync generated certs, update service config and restart master services - hosts: oo_masters_to_config - vars: - sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}" - openshift_deployment_type: "{{ deployment_type }}" - tasks: - - name: Unarchive the tarball on the master - unarchive: - src: "{{ sync_tmpdir }}/{{ master_cert_subdir }}.tgz" - dest: "{{ master_cert_config_dir }}" - when: inventory_hostname != groups.oo_first_master.0 - - - name: Restart master service - service: name="{{ openshift.common.service_type}}-master" state=restarted - when: not openshift_master_ha | bool - - - name: Ensure the master service is enabled - service: name="{{ openshift.common.service_type}}-master" state=started enabled=yes - when: not openshift_master_ha | bool - - - name: Check for configured cluster - stat: - path: /etc/corosync/corosync.conf - register: corosync_conf - when: openshift_master_ha | bool - - - name: Destroy cluster - command: pcs cluster destroy --all - when: openshift_master_ha | bool and corosync_conf.stat.exists == true - run_once: true - - - name: Start pcsd - service: name=pcsd enabled=yes state=started - when: openshift_master_ha | bool - - -- name: Re-create cluster - hosts: oo_first_master - vars: - openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}" - openshift_deployment_type: "{{ deployment_type }}" - omc_cluster_hosts: "{{ groups.oo_masters_to_config | join(' ') }}" - roles: - - role: openshift_master_cluster - when: openshift_master_ha | bool - - -- name: Delete temporary directory on localhost - hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - file: name={{ g_master_mktemp.stdout }} state=absent - changed_when: False - - -- name: Set master update status to complete - hosts: oo_masters_to_config - tasks: - - set_fact: - master_update_complete: True - - -############################################################################## -# Gate on master update complete -############################################################################## -- name: Gate on master update - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - master_update_completed: "{{ hostvars - | oo_select_keys(groups.oo_masters_to_config) - | oo_collect('inventory_hostname', {'master_update_complete': true}) }}" - - set_fact: - master_update_failed: "{{ groups.oo_masters_to_config | difference(master_update_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following masters did not finish updating: {{ master_update_failed | join(',') }}" - when: master_update_failed | length > 0 - - -############################################################################### -# Upgrade Nodes -############################################################################### -- name: Upgrade nodes - hosts: oo_nodes_to_config - vars: - openshift_version: "{{ openshift_pkg_version | default('') }}" - roles: - - openshift_facts - tasks: - - name: Upgrade node packages - command: "{{ ansible_pkg_mgr }} update -y {{ openshift.common.service_type }}-node{{ openshift_version }}" - when: openshift_pkg_version is not defined - - - name: Upgrade packages - command: "{{ ansible_pkg_mgr}} install -y {{ openshift.common.installed_variant_rpms | oo_31_rpm_rename_conversion(openshift_version) | join (' ')}}" - when: openshift_pkg_version is defined and deployment_type == 'openshift-enterprise' - - - name: Restart node service - service: name="{{ openshift.common.service_type }}-node" state=restarted - - - name: Ensure node service enabled - service: name="{{ openshift.common.service_type }}-node" state=started enabled=yes - - - name: Install Ceph storage plugin dependencies - action: "{{ ansible_pkg_mgr }} name=ceph-common state=present" - - - name: Install GlusterFS storage plugin dependencies - action: "{{ ansible_pkg_mgr }} name=glusterfs-fuse state=present" - - - name: Set sebooleans to allow gluster storage plugin access from containers - seboolean: - name: "{{ item }}" - state: yes - persistent: yes - when: ansible_selinux and ansible_selinux.status == "enabled" - with_items: - - virt_use_fusefs - - virt_sandbox_use_fusefs - register: sebool_result - failed_when: "'state' not in sebool_result and 'msg' in sebool_result and 'SELinux boolean {{ item }} does not exist' not in sebool_result.msg" - - - set_fact: - node_update_complete: True - - -############################################################################## -# Gate on nodes update -############################################################################## -- name: Gate on nodes update - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - node_update_completed: "{{ hostvars - | oo_select_keys(groups.oo_nodes_to_config) - | oo_collect('inventory_hostname', {'node_update_complete': true}) }}" - - set_fact: - node_update_failed: "{{ groups.oo_nodes_to_config | difference(node_update_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following nodes did not finish updating: {{ node_update_failed | join(',') }}" - when: node_update_failed | length > 0 - - -############################################################################### -# Post upgrade - Reconcile Cluster Roles and Cluster Role Bindings -############################################################################### -- name: Reconcile Cluster Roles and Cluster Role Bindings - hosts: oo_masters_to_config - vars: - origin_reconcile_bindings: "{{ deployment_type == 'origin' and g_new_version | version_compare('1.0.6', '>') }}" - ent_reconcile_bindings: true - openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}" - tasks: - - name: Reconcile Cluster Roles - command: > - {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig - policy reconcile-cluster-roles --additive-only=true --confirm - run_once: true - - - name: Reconcile Cluster Role Bindings - command: > - {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig - policy reconcile-cluster-role-bindings - --exclude-groups=system:authenticated - --exclude-groups=system:authenticated:oauth - --exclude-groups=system:unauthenticated - --exclude-users=system:anonymous - --additive-only=true --confirm - when: origin_reconcile_bindings | bool or ent_reconcile_bindings | bool - run_once: true - - - name: Restart master services - service: name="{{ openshift.common.service_type}}-master" state=restarted - when: not openshift_master_ha | bool - - - name: Restart master cluster - command: pcs resource restart master - when: openshift_master_ha | bool - run_once: true - - - name: Wait for the clustered master service to be available - wait_for: - host: "{{ openshift_master_cluster_vip }}" - port: 8443 - state: started - timeout: 180 - delay: 90 - when: openshift_master_ha | bool - run_once: true - - - set_fact: - reconcile_complete: True - - -############################################################################## -# Gate on reconcile -############################################################################## -- name: Gate on reconcile - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - reconcile_completed: "{{ hostvars - | oo_select_keys(groups.oo_masters_to_config) - | oo_collect('inventory_hostname', {'reconcile_complete': true}) }}" - - set_fact: - reconcile_failed: "{{ groups.oo_masters_to_config | difference(reconcile_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following masters did not finish reconciling: {{ reconcile_failed | join(',') }}" - when: reconcile_failed | length > 0 - - - - -############################################################################### -# Post upgrade - Upgrade default router, default registry and examples -############################################################################### -- name: Upgrade default router and default registry - hosts: oo_first_master - vars: - openshift_deployment_type: "{{ deployment_type }}" - registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', 'v' + g_new_version ) }}" - router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', 'v' + g_new_version ) }}" - oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig" - roles: - # Create the new templates shipped in 3.1, existing templates are left - # unmodified. This prevents the subsequent role definition for - # openshift_examples from failing when trying to replace templates that do - # not already exist. We could have potentially done a replace --force to - # create and update in one step. - - openshift_examples - # Update the existing templates - - role: openshift_examples - openshift_examples_import_command: replace - pre_tasks: - - name: Collect all routers - command: > - {{ oc_cmd }} get pods --all-namespaces -l 'router' -o json - register: all_routers - failed_when: false - changed_when: false - - - set_fact: haproxy_routers="{{ (all_routers.stdout | from_json)['items'] | oo_pods_match_component(openshift_deployment_type, 'haproxy-router') | oo_select_keys_from_list(['metadata']) }}" - when: all_routers.rc == 0 - - - set_fact: haproxy_routers=[] - when: all_routers.rc != 0 - - - name: Check for allowHostNetwork and allowHostPorts - when: all_routers.rc == 0 - shell: > - {{ oc_cmd }} get -o yaml scc/privileged | /usr/bin/grep -e allowHostPorts -e allowHostNetwork - register: _scc - - - name: Grant allowHostNetwork and allowHostPorts - when: - - all_routers.rc == 0 - - "'false' in _scc.stdout" - command: > - {{ oc_cmd }} patch scc/privileged -p - '{"allowHostPorts":true,"allowHostNetwork":true}' --api-version=v1 - - - name: Update deployment config to 1.0.4/3.0.1 spec - when: all_routers.rc == 0 - command: > - {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -p - '{"spec":{"strategy":{"rollingParams":{"updatePercent":-10},"spec":{"serviceAccount":"router","serviceAccountName":"router"}}}}' - --api-version=v1 - with_items: haproxy_routers - - - name: Switch to hostNetwork=true - when: all_routers.rc == 0 - command: > - {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -p '{"spec":{"template":{"spec":{"hostNetwork":true}}}}' - --api-version=v1 - with_items: haproxy_routers - - - name: Update router image to current version - when: all_routers.rc == 0 - command: > - {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -p - '{"spec":{"template":{"spec":{"containers":[{"name":"router","image":"{{ router_image }}"}]}}}}' - --api-version=v1 - with_items: haproxy_routers - when: not openshift.common.version_gte_3_1_1_or_1_1_1 - - - name: Update router image to current version - when: all_routers.rc == 0 - command: > - {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -p - '{"spec":{"template":{"spec":{"containers":[{"name":"router","image":"{{ router_image }}","livenessProbe":{"tcpSocket":null,"httpGet":{"path": "/healthz", "port": 1936, "host": "localhost", "scheme": "HTTP"},"initialDelaySeconds":10,"timeoutSeconds":1}}]}}}}' - --api-version=v1 - with_items: haproxy_routers - when: openshift.common.version_gte_3_1_1_or_1_1_1 - - - name: Check for default registry - command: > - {{ oc_cmd }} get -n default dc/docker-registry - register: _default_registry - failed_when: false - changed_when: false - - - name: Update registry image to current version - when: _default_registry.rc == 0 - command: > - {{ oc_cmd }} patch dc/docker-registry -p - '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}' - --api-version=v1 diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/upgrade.yml deleted file mode 100644 index e5cfa58aa..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/upgrade.yml +++ /dev/null @@ -1,140 +0,0 @@ ---- -############################################################################### -# The restart playbook should be run after this playbook completes. -############################################################################### - -############################################################################### -# Upgrade Masters -############################################################################### -- name: Upgrade master packages and configuration - hosts: oo_masters_to_config - vars: - openshift_version: "{{ openshift_pkg_version | default('') }}" - tasks: - - name: Upgrade master packages - command: "{{ ansible_pkg_mgr}} update-to -y {{ openshift.common.service_type }}-master{{ openshift_version }} {{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }}" - when: not openshift.common.is_containerized | bool - - - name: Ensure python-yaml present for config upgrade - action: "{{ ansible_pkg_mgr }} name=PyYAML state=present" - when: not openshift.common.is_containerized | bool - -# Currently 3.1.1 does not have any new configuration settings -# -# - name: Upgrade master configuration -# openshift_upgrade_config: -# from_version: '3.0' -# to_version: '3.1' -# role: master -# config_base: "{{ hostvars[inventory_hostname].openshift.common.config_base }}" - -- name: Set master update status to complete - hosts: oo_masters_to_config - tasks: - - set_fact: - master_update_complete: True - -############################################################################## -# Gate on master update complete -############################################################################## -- name: Gate on master update - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - master_update_completed: "{{ hostvars - | oo_select_keys(groups.oo_masters_to_config) - | oo_collect('inventory_hostname', {'master_update_complete': true}) }}" - - set_fact: - master_update_failed: "{{ groups.oo_masters_to_config | difference(master_update_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following masters did not finish updating: {{ master_update_failed | join(',') }}" - when: master_update_failed | length > 0 - -############################################################################### -# Upgrade Nodes -############################################################################### -- name: Upgrade nodes - hosts: oo_nodes_to_config - vars: - openshift_version: "{{ openshift_pkg_version | default('') }}" - roles: - - openshift_facts - tasks: - - name: Upgrade node packages - command: "{{ ansible_pkg_mgr }} update-to -y {{ openshift.common.service_type }}-node{{ openshift_version }} {{ openshift.common.service_type }}-sdn-ovs{{ openshift_version }}" - when: not openshift.common.is_containerized | bool - - - name: Restart node service - service: name="{{ openshift.common.service_type }}-node" state=restarted - - - set_fact: - node_update_complete: True - -############################################################################## -# Gate on nodes update -############################################################################## -- name: Gate on nodes update - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - node_update_completed: "{{ hostvars - | oo_select_keys(groups.oo_nodes_to_config) - | oo_collect('inventory_hostname', {'node_update_complete': true}) }}" - - set_fact: - node_update_failed: "{{ groups.oo_nodes_to_config | difference(node_update_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following nodes did not finish updating: {{ node_update_failed | join(',') }}" - when: node_update_failed | length > 0 - -############################################################################### -# Reconcile Cluster Roles and Cluster Role Bindings -############################################################################### -- name: Reconcile Cluster Roles and Cluster Role Bindings - hosts: oo_masters_to_config - vars: - origin_reconcile_bindings: "{{ deployment_type == 'origin' and g_new_version | version_compare('1.0.6', '>') }}" - ent_reconcile_bindings: true - openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}" - tasks: - - name: Reconcile Cluster Roles - command: > - {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig - policy reconcile-cluster-roles --additive-only=true --confirm - run_once: true - - - name: Reconcile Cluster Role Bindings - command: > - {{ openshift.common.admin_binary}} --config={{ openshift.common.config_base }}/master/admin.kubeconfig - policy reconcile-cluster-role-bindings - --exclude-groups=system:authenticated - --exclude-groups=system:authenticated:oauth - --exclude-groups=system:unauthenticated - --exclude-users=system:anonymous - --additive-only=true --confirm - when: origin_reconcile_bindings | bool or ent_reconcile_bindings | bool - run_once: true - - - set_fact: - reconcile_complete: True - -############################################################################## -# Gate on reconcile -############################################################################## -- name: Gate on reconcile - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - reconcile_completed: "{{ hostvars - | oo_select_keys(groups.oo_masters_to_config) - | oo_collect('inventory_hostname', {'reconcile_complete': true}) }}" - - set_fact: - reconcile_failed: "{{ groups.oo_masters_to_config | difference(reconcile_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following masters did not finish reconciling: {{ reconcile_failed | join(',') }}" - when: reconcile_failed | length > 0 -- cgit v1.2.3 From 5346266575045e1a42914e10249dc6e9874da7ec Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 15 Jun 2016 12:07:05 -0300 Subject: More stable containerized version lookup. --- roles/openshift_facts/library/openshift_facts.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 97cca2e5c..eb6369f50 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1133,7 +1133,10 @@ def get_openshift_version(facts): if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) - elif 'node' in facts and 'common' in facts and 'is_containerized' in facts['common']: + # TODO: it probably makes more sense to read this from sysconfig service env files, + # these control the running versions when containerized, and would work even if the service + # is dead for some reason. + elif 'common' in facts and 'is_containerized' in facts['common']: version = get_containerized_node_openshift_version(facts) return version @@ -1148,6 +1151,23 @@ def get_containerized_node_openshift_version(facts): _, output, _ = module.run_command(['docker', 'exec', '-ti', node_svc, 'openshift', 'version']) return parse_openshift_version(output) + # If containerized, see if we can determine the installed version via the systemd environment files: + node_env = '/etc/sysconfig/%s-node' % facts['common']['service_type'] + if not os.path.exists(node_env): + return None + + with open(node_env) as f: + for line in f: + if line.startwith("IMAGE_VERSION="): + tag = line[len("IMAGE_VERSION="):] + # Remove leading "v" and any trailing release info, we just want + # a version number here: + version = tag[1:].split("-")[0] + return version + return None + + + def parse_openshift_version(output): """ Apply provider facts to supplied facts dict -- cgit v1.2.3 From 955d295652c59f0e8ed4ddd77f50d4c6e09293a5 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 15 Jun 2016 15:04:13 -0300 Subject: Support origin alpha tags. --- roles/openshift_version/tasks/main.yml | 1 + .../tasks/set_version_containerized.yml | 19 ++++++++++++++++--- roles/openshift_version/tasks/set_version_rpm.yml | 1 - 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index d896eb151..ee277d1ca 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -22,6 +22,7 @@ - debug: var=openshift_release - debug: var=openshift_pkg_version - debug: var=openshift_image_tag +- debug: var=openshift.common.version - name: Set openshift_version for rpm installation include: set_version_rpm.yml diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index 6d31d0ddc..7a09c0310 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -2,7 +2,6 @@ - name: Set containerized version to configure if openshift_image_tag specified set_fact: # Expects a leading "v" in inventory, strip it off here: - # openshift_version should always just be "3.2" or "3.2.0.44" openshift_version: "{{ openshift_image_tag[1:].split('-')[0] }}" when: openshift_image_tag is defined and openshift_version is not defined @@ -19,12 +18,26 @@ - debug: var=cli_image_version +# Origin latest = released version (i.e. 1.2.0) - 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 + openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" + when: openshift_version is not defined and openshift.common.deployment_type == 'origin' and cli_image_version.stdout_lines[0].split('-') | length == 0 + + +# 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 + +# OSE +- set_fact: + openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" + when: openshift_version is not defined and openshift.common.deployment_type != 'origin' - debug: msg="{{ openshift_version }}" + + # 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 diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index 90229b0e9..889ecc56c 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -3,7 +3,6 @@ - name: Set rpm version to configure if openshift_pkg_version specified set_fact: # Expects a leading "-" in inventory, strip it off here, and remove 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 and openshift_version is not defined -- cgit v1.2.3 From 42dec74c57fa76e31a588b2a58f913c68825360d Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 16 Jun 2016 12:17:14 -0300 Subject: More version fixes. --- roles/openshift_cli/templates/openshift.j2 | 2 +- roles/openshift_version/tasks/main.yml | 1 - roles/openshift_version/tasks/set_version_containerized.yml | 9 +-------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/roles/openshift_cli/templates/openshift.j2 b/roles/openshift_cli/templates/openshift.j2 index 1c82e02a2..7786acead 100644 --- a/roles/openshift_cli/templates/openshift.j2 +++ b/roles/openshift_cli/templates/openshift.j2 @@ -5,7 +5,7 @@ fi cmd=`basename $0` user=`id -u` group=`id -g` -image_tag="v{{ openshift_version }}" +image_tag="{{ openshift_image_tag }}" >&2 echo """ ================================================================================ diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index ee277d1ca..e3bdad691 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -45,7 +45,6 @@ openshift_pkg_version: -{{ openshift_version }} when: openshift_pkg_version is not defined -# TODO: fail if any of these is unset or looks wrong: - debug: var=openshift_version - debug: var=openshift_pkg_version - debug: var=openshift_image_tag diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index 7a09c0310..d822ee164 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -18,21 +18,14 @@ - debug: var=cli_image_version -# Origin latest = released version (i.e. 1.2.0) -- set_fact: - openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" - when: openshift_version is not defined and openshift.common.deployment_type == 'origin' and cli_image_version.stdout_lines[0].split('-') | length == 0 - - # 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 -# OSE - set_fact: openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" - when: openshift_version is not defined and openshift.common.deployment_type != 'origin' + when: openshift_version is not defined - debug: msg="{{ openshift_version }}" -- cgit v1.2.3 From 78dd487871796a71c450a1a1daf78b079a3a1090 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 16 Jun 2016 14:27:20 -0300 Subject: Cleanup, fix 3.1 version bug in facts. --- .../upgrades/v3_1_to_v3_2/pre.yml | 5 ++--- .../upgrades/v3_1_to_v3_2/rpm_upgrade.yml | 2 +- roles/openshift_facts/library/openshift_facts.py | 23 +++++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index a5a9a0fec..e5a1d30f7 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -206,10 +206,9 @@ g_docker_version: "{{ g_atomic_docker_version_result.stdout | from_yaml }}" when: openshift.common.is_atomic | bool - # TODO: Update to 1.10 once branch merges - fail: - msg: This playbook requires access to Docker 1.9 or later - when: g_docker_version.avail_version | default(g_docker_version.curr_version, true) | version_compare('1.9','<') + msg: This playbook requires access to Docker 1.10 or later + when: g_docker_version.avail_version | default(g_docker_version.curr_version, true) | version_compare('1.10','<') # TODO: add check to upgrade ostree to get latest Docker diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml index ea27a40d1..1d97d3802 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml @@ -1,4 +1,4 @@ -# TODO: Use a specific version here once we're setting openshift_pkg_version reliably in the openshift_version module. +# We verified latest rpm available is suitable, so just yum update. - name: Upgrade packages command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-{{ component }}" diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index eb6369f50..a979639f8 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1113,7 +1113,9 @@ def get_docker_version_info(): return result def get_openshift_version(facts): - """ Get current version of openshift on the host + """ Get current version of openshift on the host. + + Checks a variety of ways ranging from fastest to slowest. Args: facts (dict): existing facts @@ -1139,18 +1141,17 @@ def get_openshift_version(facts): elif 'common' in facts and 'is_containerized' in facts['common']: version = get_containerized_node_openshift_version(facts) + # Handle containerized masters that have not yet been configured as a node. + # This can be very slow and may get re-run multiple times, so we only use this + # if other methods failed to find a version. + if not version and os.path.isfile('/usr/local/bin/openshift'): + _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) + version = parse_openshift_version(output) + return version -def get_containerized_node_openshift_version(facts): - node_svc = "%s-node" % facts['common']['service_type'] - rc, _, _ = module.run_command(['systemctl', 'is-active', node_svc]) - if rc > 0: - # Node service not running or doesn't exist: - return None - # Node service running, exec in and get the version: - _, output, _ = module.run_command(['docker', 'exec', '-ti', node_svc, 'openshift', 'version']) - return parse_openshift_version(output) +def get_containerized_node_openshift_version(facts): # If containerized, see if we can determine the installed version via the systemd environment files: node_env = '/etc/sysconfig/%s-node' % facts['common']['service_type'] if not os.path.exists(node_env): @@ -1167,8 +1168,6 @@ def get_containerized_node_openshift_version(facts): return None - - def parse_openshift_version(output): """ Apply provider facts to supplied facts dict -- cgit v1.2.3 From f0f69623f6852badb7b912064de539371da6e2f1 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 16 Jun 2016 14:58:15 -0300 Subject: Fix typo in facts. --- roles/openshift_facts/library/openshift_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index a979639f8..6c31f0fa8 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1159,7 +1159,7 @@ def get_containerized_node_openshift_version(facts): with open(node_env) as f: for line in f: - if line.startwith("IMAGE_VERSION="): + if line.startswith("IMAGE_VERSION="): tag = line[len("IMAGE_VERSION="):] # Remove leading "v" and any trailing release info, we just want # a version number here: -- cgit v1.2.3 From b4d702c0115cb97f118e1fdc77f6326eda923a47 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 09:10:00 -0300 Subject: Upgrade fixes. --- .../upgrades/v3_1_to_v3_2/post.yml | 4 ++-- .../upgrades/v3_1_to_v3_2/upgrade.yml | 27 +++------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/post.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/post.yml index 31e76805c..d52fd7cb0 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/post.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/post.yml @@ -6,8 +6,8 @@ hosts: oo_first_master vars: openshift_deployment_type: "{{ deployment_type }}" - registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', 'v' + g_new_version ) }}" - router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', 'v' + g_new_version ) }}" + registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', openshift_image_tag ) }}" + router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', openshift_image_tag ) }}" oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig" roles: - openshift_manageiq diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index 7b5b9e8d7..66f6f8e71 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -13,29 +13,8 @@ - name: Set post docker install facts openshift_facts: role: "{{ item.role }}" - local_facts: "{{ item.local_facts }}" with_items: - role: docker - local_facts: - openshift_image_tag: "v{{ g_new_version }}" - openshift_version: "{{ g_new_version }}" - -# The cli image is used by openshift_docker_facts to determine the currently installed -# version. We need to explicitly pull the latest image to handle cases where -# the locally cached 'latest' tag is older the g_new_version. -- name: Download cli image - hosts: oo_masters_to_config:oo_nodes_to_config - roles: - - { role: openshift_docker_facts } - vars: - openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" - tasks: - - name: Pull Images - command: > - docker pull {{ item }}:latest - with_items: - - "{{ openshift.common.cli_image }}" - when: openshift.common.is_containerized | bool ############################################################################### # Upgrade Masters @@ -53,7 +32,7 @@ - include_vars: ../../../../../roles/openshift_master/vars/main.yml - name: Update systemd units - include: ../../../../../roles/openshift_master/tasks/systemd_units.yml openshift_version=v{{ g_new_version }} + include: ../../../../../roles/openshift_master/tasks/systemd_units.yml # - name: Upgrade master configuration # openshift_upgrade_config: @@ -127,9 +106,9 @@ - name: Reconcile Cluster Roles and Cluster Role Bindings and Security Context Constraints hosts: oo_masters_to_config roles: - - { role: openshift_cli, openshift_image_tag: "v{{ g_new_version }}" } + - { role: openshift_cli } vars: - origin_reconcile_bindings: "{{ deployment_type == 'origin' and g_new_version | version_compare('1.0.6', '>') }}" + origin_reconcile_bindings: "{{ deployment_type == 'origin' and openshift_version | version_compare('1.0.6', '>') }}" ent_reconcile_bindings: true openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" tasks: -- cgit v1.2.3 From 63ea5cce369710363dd09b2b64c40871c6ce55f9 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 09:10:20 -0300 Subject: More stable lookup of running openshift version. --- roles/openshift_facts/library/openshift_facts.py | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 6c31f0fa8..62d478bfc 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1139,7 +1139,7 @@ def get_openshift_version(facts): # these control the running versions when containerized, and would work even if the service # is dead for some reason. elif 'common' in facts and 'is_containerized' in facts['common']: - version = get_containerized_node_openshift_version(facts) + version = get_containerized_openshift_version(facts) # Handle containerized masters that have not yet been configured as a node. # This can be very slow and may get re-run multiple times, so we only use this @@ -1151,20 +1151,21 @@ def get_openshift_version(facts): return version -def get_containerized_node_openshift_version(facts): +def get_containerized_openshift_version(facts): # If containerized, see if we can determine the installed version via the systemd environment files: - node_env = '/etc/sysconfig/%s-node' % facts['common']['service_type'] - if not os.path.exists(node_env): - return None - - with open(node_env) as f: - for line in f: - if line.startswith("IMAGE_VERSION="): - tag = line[len("IMAGE_VERSION="):] - # Remove leading "v" and any trailing release info, we just want - # a version number here: - version = tag[1:].split("-")[0] - return version + for filename in ['/etc/sysconfig/%s-master', '/etc/sysconfig/%s-node']: + env_file = filename % facts['common']['service_type'] + if not os.path.exists(env_file): + continue + + with open(env_file) as f: + for line in f: + if line.startswith("IMAGE_VERSION="): + tag = line[len("IMAGE_VERSION="):] + # Remove leading "v" and any trailing release info, we just want + # a version number here: + version = tag[1:].split("-")[0] + return version return None -- cgit v1.2.3 From e60b8976ef638c3368dd229906078f1077f00a99 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 09:10:39 -0300 Subject: Block attempts to install origin without specifying any release info. --- roles/openshift_version/tasks/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index e3bdad691..9ff13d35c 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -1,6 +1,13 @@ --- # Determine the openshift_version to configure if none has been specified or set previously. +# 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, openshift_image_tag, or openshift_pkg_version in inventory to install origin. (suggestion: add openshift_release=\"1.2\" to inventory)" + when: openshift.common.deployment_type == 'origin' and openshift_release is not defined and openshift_pkg_version is not defined and openshift_image_tag is not defined + - set_fact: is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" -- cgit v1.2.3 From dc75bf3a6c7913c519706e69a3ea82efd191b378 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 10:48:38 -0300 Subject: Check that detected version matches openshift_release in rpm installations. --- filter_plugins/oo_filters.py | 5 +++++ roles/openshift_version/tasks/main.yml | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 7510975f2..54891b066 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -891,6 +891,10 @@ class FilterModule(object): return version + @staticmethod + def oo_startswith(input, prefix): + return input.startswith(prefix) + def filters(self): """ returns a mapping of filters to methods """ return { @@ -924,4 +928,5 @@ class FilterModule(object): "oo_oc_nodes_matching_selector": self.oo_oc_nodes_matching_selector, "oo_oc_nodes_with_label": self.oo_oc_nodes_with_label, "oo_merge_hostvars": self.oo_merge_hostvars, + "oo_startswith": self.oo_startswith, } diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 9ff13d35c..b11bf62fe 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -1,15 +1,15 @@ --- # 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, openshift_image_tag, or openshift_pkg_version in inventory to install origin. (suggestion: add openshift_release=\"1.2\" to inventory)" - when: openshift.common.deployment_type == 'origin' and openshift_release is not defined and openshift_pkg_version is not defined and openshift_image_tag is not defined - -- set_fact: - is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}" + 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 # Make sure we copy this to a fact if given a var: - set_fact: @@ -65,3 +65,8 @@ - fail: openshift_version role was unable to set openshift_pkg_version when: openshift_pkg_version is not defined +# 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 or specify an exact openshift_pkg_version." + when: not is_containerized | bool and openshift_release is defined and not openshift_version | oo_startswith(openshift_release) | bool -- cgit v1.2.3 From 2cab796e15d834dfb9f3743941dd5311731fc70f Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 10:54:14 -0300 Subject: Normalize some of the version inventory vars which users might mistakenly enter wrong. --- roles/openshift_version/tasks/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index b11bf62fe..ac3efe7e9 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -11,6 +11,19 @@ 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 +# 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 and openshift_release[0] == 'v' + +- set_fact: + openshift_image_tag: "{{ 'v' + openshift_image_tag }}" + when: openshift_image_tag is defined and openshift_image_tag[0] != 'v' + +- set_fact: + openshift_pkg_version: "{{ '-' + openshift_pkg_version }}" + when: openshift_pkg_version is defined and openshift_pkg_version[0] != '-' + # Make sure we copy this to a fact if given a var: - set_fact: openshift_version: "{{ openshift_version }}" -- cgit v1.2.3 From fa8f17557a152cf0da98f66403cfeb65dce68732 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 11:01:11 -0300 Subject: Document the new and old version variables. --- inventory/byo/hosts.aep.example | 17 +++++++++++++++++ inventory/byo/hosts.origin.example | 17 +++++++++++++++++ inventory/byo/hosts.ose.example | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/inventory/byo/hosts.aep.example b/inventory/byo/hosts.aep.example index 1e050f0f6..ffed3c042 100644 --- a/inventory/byo/hosts.aep.example +++ b/inventory/byo/hosts.aep.example @@ -24,6 +24,23 @@ debug_level=2 # deployment type valid values are origin, online, atomic-enterprise, and openshift-enterprise deployment_type=atomic-enterprise +# Specify the generic release of OpenShift to install. This is used mainly just during installation, after which we +# rely on the version running on the first master. Works best for containerized installs where we can usually +# use this to lookup the latest exact version of the container images, which is the tag actually used to configure +# the cluster. For RPM installations we just verify the version detected in your configured repos matches this +# release. +openshift_release=v3.2 + +# Specify an exact container image tag to install or configure. +# WARNING: This value will be used for all hosts in containerized environments, even those that have another version installed. +# This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. +#openshift_image_tag=v3.2.0.46 + +# Specify an exact rpm version to install or configure. +# WARNING: This value will be used for all hosts in RPM based environments, even those that have another version installed. +# This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. +#openshift_image_tag=-3.2.0.46 + # Install the openshift examples #openshift_install_examples=true diff --git a/inventory/byo/hosts.origin.example b/inventory/byo/hosts.origin.example index 104c64c23..d3d1e3994 100644 --- a/inventory/byo/hosts.origin.example +++ b/inventory/byo/hosts.origin.example @@ -25,6 +25,23 @@ debug_level=2 # deployment type valid values are origin, online, atomic-enterprise and openshift-enterprise deployment_type=origin +# Specify the generic release of OpenShift to install. This is used mainly just during installation, after which we +# rely on the version running on the first master. Works best for containerized installs where we can usually +# use this to lookup the latest exact version of the container images, which is the tag actually used to configure +# the cluster. For RPM installations we just verify the version detected in your configured repos matches this +# release. +openshift_release=v1.2 + +# Specify an exact container image tag to install or configure. +# WARNING: This value will be used for all hosts in containerized environments, even those that have another version installed. +# This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. +#openshift_image_tag=v1.2.0 + +# Specify an exact rpm version to install or configure. +# WARNING: This value will be used for all hosts in RPM based environments, even those that have another version installed. +# This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. +#openshift_image_tag=-1.2.0 + # Install the openshift examples #openshift_install_examples=true diff --git a/inventory/byo/hosts.ose.example b/inventory/byo/hosts.ose.example index ebac28fc6..2514fcc96 100644 --- a/inventory/byo/hosts.ose.example +++ b/inventory/byo/hosts.ose.example @@ -24,6 +24,23 @@ debug_level=2 # deployment type valid values are origin, online, atomic-enterprise, and openshift-enterprise deployment_type=openshift-enterprise +# Specify the generic release of OpenShift to install. This is used mainly just during installation, after which we +# rely on the version running on the first master. Works best for containerized installs where we can usually +# use this to lookup the latest exact version of the container images, which is the tag actually used to configure +# the cluster. For RPM installations we just verify the version detected in your configured repos matches this +# release. +openshift_release=v3.2 + +# Specify an exact container image tag to install or configure. +# WARNING: This value will be used for all hosts in containerized environments, even those that have another version installed. +# This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. +#openshift_image_tag=v3.2.0.46 + +# Specify an exact rpm version to install or configure. +# WARNING: This value will be used for all hosts in RPM based environments, even those that have another version installed. +# This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. +#openshift_image_tag=-3.2.0.46 + # Install the openshift examples #openshift_install_examples=true -- cgit v1.2.3 From 9ce7443cefb53a400f5b38ac004c41e1b443635c Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 17 Jun 2016 15:40:31 -0300 Subject: Fix version facts with trailing newline. --- roles/openshift_facts/library/openshift_facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 62d478bfc..43cca90d6 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1161,7 +1161,7 @@ def get_containerized_openshift_version(facts): with open(env_file) as f: for line in f: if line.startswith("IMAGE_VERSION="): - tag = line[len("IMAGE_VERSION="):] + tag = line[len("IMAGE_VERSION="):].strip() # Remove leading "v" and any trailing release info, we just want # a version number here: version = tag[1:].split("-")[0] -- cgit v1.2.3 From 4966c635ed19154cace877fcd2b613c798faa7f8 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 20 Jun 2016 11:19:03 -0300 Subject: Support setting a docker version in inventory. --- roles/docker/tasks/main.yml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 1f5f891c7..34be0a666 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -2,10 +2,42 @@ - stat: path=/etc/sysconfig/docker-storage register: docker_storage_check +- debug: var=docker_version + +- name: Get current installed Docker version + command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker" + when: docker_version is defined and not openshift.common.is_atomic | bool + register: curr_docker_version + changed_when: false + +- name: Get latest available version of Docker + command: > + {{ repoquery_cmd }} --qf '%{version}' "docker" + register: avail_docker_version + failed_when: false + changed_when: false + when: docker_version is defined and not openshift.common.is_atomic | bool + +# TODO: Should we use docker_version defaulted to 1.10 here? + +# If a docker_version was requested, sanity check that we can install or upgrade to it, and +# no downgrade is required. +- name: Fail if Docker version requested but downgrade is required + fail: + msg: "Docker {{ curr_docker_version.stdout }} is installed, but version {{ docker_version }} was requested." + when: not curr_docker_version | skipped and curr_docker_version.stdout | default('0.0', True) | version_compare(docker_version, '>') + +# This involves an extremely slow migration process, users should instead run the +# Docker 1.10 upgrade playbook to accomplish this. +- name: Error out if attempting to upgrade Docker across the 1.10 boundary + fail: + msg: "Cannot upgrade Docker to >= 1.10, please use the Docker upgrade playbook for this." + when: not curr_docker_version | skipped and curr_docker_version.stdout | default('0.0', True) | version_compare('1.10', '<') and docker_version | version_compare('1.10', '>=') + # Make sure Docker is installed, but does not update a running version. # Docker upgrades are handled by a separate playbook. - name: Install Docker - action: "{{ ansible_pkg_mgr }} name=docker state=present" + action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version if docker_version is defined else '' }} state=present" when: not openshift.common.is_atomic | bool - name: Start the Docker service @@ -60,6 +92,9 @@ - restart docker when: "{{ 'http_proxy' in openshift.common or 'https_proxy' in openshift.common and docker_check.stat.isreg }}" +- debug: var=openshift.docker.options +- debug: var=docker_options + - name: Set various Docker options lineinfile: dest: /etc/sysconfig/docker -- cgit v1.2.3 From 8c9ed6719bdbc0ce7574fa9261c60e4978c203e6 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 20 Jun 2016 14:45:42 -0300 Subject: Fix docker restarts during openshift_version role. The variable here must be explicitly passed to the docker role, if it's passed sometimes and not others, the docker config changes triggers a docker restart effectively killing everything on the node in an unsafe manner. Instead lets make sure the value is set. --- playbooks/common/openshift-cluster/initialize_facts.yml | 2 ++ playbooks/common/openshift-master/config.yml | 2 -- roles/docker/defaults/main.yml | 1 - roles/openshift_docker_facts/tasks/main.yml | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_facts.yml b/playbooks/common/openshift-cluster/initialize_facts.yml index cda490b1f..a4af5efc5 100644 --- a/playbooks/common/openshift-cluster/initialize_facts.yml +++ b/playbooks/common/openshift-cluster/initialize_facts.yml @@ -8,3 +8,5 @@ role: common local_facts: hostname: "{{ openshift_hostname | default(None) }}" + - set_fact: + openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" diff --git a/playbooks/common/openshift-master/config.yml b/playbooks/common/openshift-master/config.yml index 5e57cdeef..f17f6a1e9 100644 --- a/playbooks/common/openshift-master/config.yml +++ b/playbooks/common/openshift-master/config.yml @@ -204,7 +204,6 @@ | oo_collect('openshift.common.all_hostnames') | oo_flatten | unique }}" sync_tmpdir: "{{ hostvars.localhost.g_master_mktemp.stdout }}" - openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" roles: - openshift_master_certificates post_tasks: @@ -320,7 +319,6 @@ 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([]))) diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 1b26af0dd..ed97d539c 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -1,2 +1 @@ --- -docker_version: '' \ No newline at end of file diff --git a/roles/openshift_docker_facts/tasks/main.yml b/roles/openshift_docker_facts/tasks/main.yml index 2e68809ca..eb8b5e99b 100644 --- a/roles/openshift_docker_facts/tasks/main.yml +++ b/roles/openshift_docker_facts/tasks/main.yml @@ -34,7 +34,8 @@ - set_fact: docker_options: "--insecure-registry={{ openshift.docker.hosted_registry_network }} {{ openshift.docker.options | default ('') }}" when: openshift.docker.hosted_registry_insecure | default(False) | bool and openshift.docker.hosted_registry_network is defined + register: hosted_registry_options - set_fact: docker_options: "{{ openshift.docker.options | default(omit) }}" - when: not openshift.docker.hosted_registry_insecure | default(False) | bool + when: hosted_registry_options | skipped -- cgit v1.2.3 From 2a52c5e57646b78d703aea1fd8e51ce2e90c7722 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 21 Jun 2016 10:02:05 -0300 Subject: Remove more legacy upgrade playbooks. --- .../upgrades/v3_0_minor/filter_plugins | 1 - .../openshift-cluster/upgrades/v3_0_minor/library | 1 - .../upgrades/v3_0_minor/lookup_plugins | 1 - .../openshift-cluster/upgrades/v3_0_minor/roles | 1 - .../upgrades/v3_0_to_v3_1/filter_plugins | 1 - .../upgrades/v3_0_to_v3_1/library | 1 - .../upgrades/v3_0_to_v3_1/lookup_plugins | 1 - .../openshift-cluster/upgrades/v3_0_to_v3_1/roles | 1 - .../upgrades/v3_1_minor/filter_plugins | 1 - .../openshift-cluster/upgrades/v3_1_minor/library | 1 - .../upgrades/v3_1_minor/lookup_plugins | 1 - .../openshift-cluster/upgrades/v3_1_minor/post.yml | 57 -------------- .../openshift-cluster/upgrades/v3_1_minor/pre.yml | 88 ---------------------- .../openshift-cluster/upgrades/v3_1_minor/roles | 1 - 14 files changed, 157 deletions(-) delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_minor/filter_plugins delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_minor/library delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_minor/lookup_plugins delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_minor/roles delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/filter_plugins delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/library delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/lookup_plugins delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/roles delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_minor/filter_plugins delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_minor/library delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_minor/lookup_plugins delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_minor/post.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_minor/pre.yml delete mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_minor/roles diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/filter_plugins b/playbooks/common/openshift-cluster/upgrades/v3_0_minor/filter_plugins deleted file mode 120000 index 27ddaa18b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/filter_plugins +++ /dev/null @@ -1 +0,0 @@ -../../../../../filter_plugins \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/library b/playbooks/common/openshift-cluster/upgrades/v3_0_minor/library deleted file mode 120000 index 53bed9684..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/library +++ /dev/null @@ -1 +0,0 @@ -../library \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/lookup_plugins b/playbooks/common/openshift-cluster/upgrades/v3_0_minor/lookup_plugins deleted file mode 120000 index cf407f69b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/lookup_plugins +++ /dev/null @@ -1 +0,0 @@ -../../../../../lookup_plugins \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/roles b/playbooks/common/openshift-cluster/upgrades/v3_0_minor/roles deleted file mode 120000 index 6bc1a7aef..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_minor/roles +++ /dev/null @@ -1 +0,0 @@ -../../../../../roles \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/filter_plugins b/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/filter_plugins deleted file mode 120000 index 27ddaa18b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/filter_plugins +++ /dev/null @@ -1 +0,0 @@ -../../../../../filter_plugins \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/library b/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/library deleted file mode 120000 index 53bed9684..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/library +++ /dev/null @@ -1 +0,0 @@ -../library \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/lookup_plugins b/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/lookup_plugins deleted file mode 120000 index cf407f69b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/lookup_plugins +++ /dev/null @@ -1 +0,0 @@ -../../../../../lookup_plugins \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/roles b/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/roles deleted file mode 120000 index 6bc1a7aef..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_0_to_v3_1/roles +++ /dev/null @@ -1 +0,0 @@ -../../../../../roles \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/filter_plugins b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/filter_plugins deleted file mode 120000 index 27ddaa18b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/filter_plugins +++ /dev/null @@ -1 +0,0 @@ -../../../../../filter_plugins \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/library b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/library deleted file mode 120000 index 53bed9684..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/library +++ /dev/null @@ -1 +0,0 @@ -../library \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/lookup_plugins b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/lookup_plugins deleted file mode 120000 index cf407f69b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/lookup_plugins +++ /dev/null @@ -1 +0,0 @@ -../../../../../lookup_plugins \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/post.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/post.yml deleted file mode 100644 index 196393b2a..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/post.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -############################################################################### -# Post upgrade - Upgrade default router, default registry and examples -############################################################################### -- name: Upgrade default router and default registry - hosts: oo_first_master - vars: - openshift_deployment_type: "{{ deployment_type }}" - registry_image: "{{ openshift.master.registry_url | replace( '${component}', 'docker-registry' ) | replace ( '${version}', 'v' + g_new_version ) }}" - router_image: "{{ openshift.master.registry_url | replace( '${component}', 'haproxy-router' ) | replace ( '${version}', 'v' + g_new_version ) }}" - oc_cmd: "{{ openshift.common.client_binary }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig" - roles: - # Create the new templates shipped in 3.1.z, existing templates are left - # unmodified. This prevents the subsequent role definition for - # openshift_examples from failing when trying to replace templates that do - # not already exist. We could have potentially done a replace --force to - # create and update in one step. - - openshift_examples - # Update the existing templates - - role: openshift_examples - openshift_examples_import_command: replace - pre_tasks: - - name: Collect all routers - command: > - {{ oc_cmd }} get pods --all-namespaces -l 'router' -o json - register: all_routers - failed_when: false - changed_when: false - - - set_fact: haproxy_routers="{{ (all_routers.stdout | from_json)['items'] | oo_pods_match_component(openshift_deployment_type, 'haproxy-router') | oo_select_keys_from_list(['metadata']) }}" - when: all_routers.rc == 0 - - - set_fact: haproxy_routers=[] - when: all_routers.rc != 0 - - - name: Update router image to current version - when: all_routers.rc == 0 - command: > - {{ oc_cmd }} patch dc/{{ item['labels']['deploymentconfig'] }} -p - '{"spec":{"template":{"spec":{"containers":[{"name":"router","image":"{{ router_image }}","livenessProbe":{"tcpSocket":null,"httpGet":{"path": "/healthz", "port": 1936, "host": "localhost", "scheme": "HTTP"},"initialDelaySeconds":10,"timeoutSeconds":1}}]}}}}' - --api-version=v1 - with_items: haproxy_routers - - - name: Check for default registry - command: > - {{ oc_cmd }} get -n default dc/docker-registry - register: _default_registry - failed_when: false - changed_when: false - - - name: Update registry image to current version - when: _default_registry.rc == 0 - command: > - {{ oc_cmd }} patch dc/docker-registry -p - '{"spec":{"template":{"spec":{"containers":[{"name":"registry","image":"{{ registry_image }}"}]}}}}' - --api-version=v1 - diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/pre.yml deleted file mode 100644 index 85d7073f2..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/pre.yml +++ /dev/null @@ -1,88 +0,0 @@ ---- -############################################################################### -# Evaluate host groups and gather facts -############################################################################### -- name: Load openshift_facts - hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config:oo_lb_to_config - roles: - - openshift_facts - -############################################################################### -# Pre-upgrade checks -############################################################################### -- name: Verify upgrade can proceed - hosts: oo_first_master - vars: - openshift_master_ha: "{{ groups.oo_masters_to_config | length > 1 }}" - target_version: "{{ '1.1.1' if deployment_type == 'origin' else '3.1.1' }}" - gather_facts: no - tasks: - - fail: - msg: > - This upgrade is only supported for origin, openshift-enterprise, and online - deployment types - when: deployment_type not in ['origin','openshift-enterprise', 'online'] - - - fail: - msg: > - openshift_pkg_version is {{ openshift_pkg_version }} which is not a - valid version for a {{ target_version }} upgrade - when: openshift_pkg_version is defined and openshift_pkg_version.split('-',1).1 | version_compare(target_version ,'<') - -- name: Verify upgrade targets - hosts: oo_masters_to_config:oo_nodes_to_config - vars: - target_version: "{{ '1.1.1' if deployment_type == 'origin' else '3.1.1' }}" - tasks: - - name: Clean package cache - command: "{{ ansible_pkg_mgr }} clean all" - when: not openshift.common.is_atomic | bool - - - set_fact: - g_new_service_name: "{{ 'origin' if deployment_type =='origin' else 'atomic-openshift' }}" - - - name: Determine available versions - script: ../files/rpm_versions.sh {{ g_new_service_name }} - register: g_versions_result - - - set_fact: - g_aos_versions: "{{ g_versions_result.stdout | from_yaml }}" - - - set_fact: - g_new_version: "{{ g_aos_versions.curr_version.split('-', 1).0 if g_aos_versions.avail_version is none else g_aos_versions.avail_version.split('-', 1).0 }}" - - - fail: - msg: This playbook requires Origin 1.1 or later - when: deployment_type == 'origin' and g_aos_versions.curr_version | version_compare('1.1','<') - - - fail: - msg: This playbook requires Atomic Enterprise Platform/OpenShift Enterprise 3.1 or later - when: deployment_type == 'atomic-openshift' and g_aos_versions.curr_version | version_compare('3.1','<') - - - fail: - msg: Upgrade packages not found - when: (g_aos_versions.avail_version | default(g_aos_versions.curr_version, true) | version_compare(target_version, '<')) - - - set_fact: - pre_upgrade_complete: True - - -############################################################################## -# Gate on pre-upgrade checks -############################################################################## -- name: Gate on pre-upgrade checks - hosts: localhost - connection: local - become: no - vars: - pre_upgrade_hosts: "{{ groups.oo_masters_to_config | union(groups.oo_nodes_to_config) }}" - tasks: - - set_fact: - pre_upgrade_completed: "{{ hostvars - | oo_select_keys(pre_upgrade_hosts) - | oo_collect('inventory_hostname', {'pre_upgrade_complete': true}) }}" - - set_fact: - pre_upgrade_failed: "{{ pre_upgrade_hosts | difference(pre_upgrade_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following hosts did not complete pre-upgrade checks: {{ pre_upgrade_failed | join(',') }}" - when: pre_upgrade_failed | length > 0 diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/roles b/playbooks/common/openshift-cluster/upgrades/v3_1_minor/roles deleted file mode 120000 index 6bc1a7aef..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_minor/roles +++ /dev/null @@ -1 +0,0 @@ -../../../../../roles \ No newline at end of file -- cgit v1.2.3 From 50c5e7ac797313537dd31a528f187063b54a903f Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 21 Jun 2016 11:05:27 -0300 Subject: Fix use of v3.2 format for openshift_release in upgrade. --- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index e5a1d30f7..d8d04470c 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -58,6 +58,10 @@ valid version for a {{ target_version }} upgrade when: openshift_image_tag is defined and openshift_image_tag.split('v',1).1 | version_compare(target_version ,'<') + - set_fact: + openshift_release: "{{ openshift_release[1:] }}" + when: openshift_release is defined and openshift_release[0] == 'v' + - fail: msg: > openshift_release is {{ openshift_release }} which is not a -- cgit v1.2.3 From b5f5b88221d5976d71c0a0a70e73fd353c7419a9 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 21 Jun 2016 13:37:42 -0300 Subject: Use common fact initialization include in upgrade. --- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index d8d04470c..cdc691829 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -2,10 +2,12 @@ ############################################################################### # Evaluate host groups and gather facts ############################################################################### -- name: Load openshift_facts and update repos + +- include: ../../common/openshift-cluster/initialize_facts.yml + +- name: Update repos hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config:oo_lb_to_config roles: - - openshift_facts - openshift_repos - name: Evaluate additional groups for upgrade -- cgit v1.2.3 From ea99abc4461f3e2edb7993b9c7961a13c727ab7c Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 22 Jun 2016 16:20:06 -0300 Subject: Add missing defaults file. --- roles/openshift_version/defaults/main.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 roles/openshift_version/defaults/main.yml diff --git a/roles/openshift_version/defaults/main.yml b/roles/openshift_version/defaults/main.yml new file mode 100644 index 000000000..01a1a7472 --- /dev/null +++ b/roles/openshift_version/defaults/main.yml @@ -0,0 +1,2 @@ +--- +openshift_protect_installed_version: True -- cgit v1.2.3 From 5c7e3e9d3a36062a6bf0d79da0c95e1f2e17b9a0 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 22 Jun 2016 11:28:19 -0300 Subject: Update docker upgrade playbook to be more flexible. Now more of a generic upgrade playbook to go to the latest Docker version. Added support for docker_version inventory variable, in which case we disable the check for >= 1.10 and make sure you're running at least the specified version. (we will not downgrade you to the requested version however, this is much too complicated) --- .../upgrades/docker/docker_upgrade.yml | 59 +++++++++++++++------- .../upgrades/v3_1_to_v3_2/pre.yml | 1 - 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml index 8b1b2fb1b..9434d8e15 100644 --- a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml +++ b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml @@ -1,51 +1,68 @@ -- name: Check for appropriate Docker versions for 1.9.x to 1.10.x upgrade +- name: Check for appropriate Docker versions hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config roles: - openshift_facts tasks: + - set_fact: + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" + + - fail: + msg: Cannot upgrade Docker on Atomic hosts + when: openshift.common.is_atomic | bool + - name: Determine available Docker version script: ../../../../common/openshift-cluster/upgrades/files/rpm_versions.sh docker register: g_docker_version_result - when: not openshift.common.is_atomic | bool - name: Check if Docker is installed command: rpm -q docker register: pkg_check failed_when: pkg_check.rc > 1 changed_when: no - when: not openshift.common.is_atomic | bool - - set_fact: - g_docker_version: "{{ g_docker_version_result.stdout | from_yaml }}" - when: not openshift.common.is_atomic | bool + - name: Get current version of Docker + command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker" + register: curr_docker_version + changed_when: false - - name: Set fact if docker requires an upgrade - set_fact: - docker_upgrade: true - when: not openshift.common.is_atomic | bool and pkg_check.rc == 0 and g_docker_version.curr_version | version_compare('1.10','<') + - name: Get latest available version of Docker + command: > + {{ repoquery_cmd }} --qf '%{version}' "docker" + register: avail_docker_version + failed_when: false + changed_when: false - fail: msg: This playbook requires access to Docker 1.10 or later - when: g_docker_version.avail_version | default(g_docker_version.curr_version, true) | version_compare('1.10','<') + # Disable the 1.10 requirement if the user set a specific Docker version + when: avail_docker_version.stdout | version_compare('1.10','<') and docker_version is not defined + + - name: Flag for upgrade if Docker version does not equal latest + set_fact: + docker_upgrade: true + when: docker_version is not defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(avail_docker_version.stdout,'<') + + - name: Flag for upgrade if Docker version does not equal requested version + set_fact: + docker_upgrade: true + when: docker_version is defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') + # If a node fails, halt everything, the admin will need to clean up and we # don't want to carry on, potentially taking out every node. The playbook can safely be re-run -# and will not take any action on a node already running 1.10+. +# and will not take any action on a node already running the requested docker version. - name: Evacuate and upgrade nodes hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config serial: 1 any_errors_fatal: true tasks: - - debug: var=docker_upgrade - - name: Prepare for Node evacuation command: > {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=false delegate_to: "{{ groups.oo_first_master.0 }}" when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config -# TODO: skip all node evac stuff for non-nodes (i.e. separate containerized etcd hosts) - name: Evacuate Node for Kubelet upgrade command: > {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --evacuate --force @@ -69,10 +86,16 @@ register: nuke_images_result when: docker_upgrade is defined and docker_upgrade | bool - - name: Upgrade Docker - command: "{{ ansible_pkg_mgr}} update -y docker" + # TODO: should we use the docker role to actually do the upgrade? + - name: Upgrade to specified Docker version + action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version }} state=present" register: docker_upgrade_result - when: docker_upgrade is defined and docker_upgrade | bool + when: docker_upgrade is defined and docker_upgrade | bool and docker_version is defined + + - name: Upgrade to latest Docker version + action: "{{ ansible_pkg_mgr }} name=docker state=latest" + register: docker_upgrade_result + when: docker_upgrade is defined and docker_upgrade | bool and docker_version is not defined - name: Restart containerized services service: name={{ item }} state=started diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 6a3d60276..ec07f0a60 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -163,7 +163,6 @@ - set_fact: repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" - when: not openshift.common.is_containerized | bool - name: Check latest available OpenShift RPM version command: > -- cgit v1.2.3 From 82f4e4eaeaaf3059013e9ea23d87dcf89fd8455e Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 21 Jun 2016 15:01:01 -0300 Subject: Refactor 3.2 upgrade to avoid killing nodes without evac. We now handle the two pieces of upgrade that require a node evac in the same play. (docker, and node itself) --- .../upgrades/docker/docker_upgrade.yml | 88 +--------------------- .../upgrades/docker/files/nuke_images.sh | 23 ------ .../openshift-cluster/upgrades/docker/upgrade.yml | 52 +++++++++++++ .../upgrades/docker/upgrade_check.yml | 37 +++++++++ .../upgrades/files/nuke_images.sh | 23 ++++++ .../v3_1_to_v3_2/containerized_node_upgrade.yml | 11 +++ .../v3_1_to_v3_2/containerized_upgrade.yml | 11 --- .../upgrades/v3_1_to_v3_2/docker_upgrade.yml | 14 ---- .../upgrades/v3_1_to_v3_2/node_upgrade.yml | 24 ------ .../upgrades/v3_1_to_v3_2/pre.yml | 2 +- .../upgrades/v3_1_to_v3_2/upgrade.yml | 72 +++++++++--------- 11 files changed, 164 insertions(+), 193 deletions(-) delete mode 100644 playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh create mode 100644 playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml create mode 100644 playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml create mode 100644 playbooks/common/openshift-cluster/upgrades/files/nuke_images.sh create mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_upgrade.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/docker_upgrade.yml delete mode 100644 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/node_upgrade.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml index 9434d8e15..96c9fb15d 100644 --- a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml +++ b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml @@ -4,6 +4,7 @@ roles: - openshift_facts tasks: + - set_fact: repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" @@ -11,42 +12,7 @@ msg: Cannot upgrade Docker on Atomic hosts when: openshift.common.is_atomic | bool - - name: Determine available Docker version - script: ../../../../common/openshift-cluster/upgrades/files/rpm_versions.sh docker - register: g_docker_version_result - - - name: Check if Docker is installed - command: rpm -q docker - register: pkg_check - failed_when: pkg_check.rc > 1 - changed_when: no - - - name: Get current version of Docker - command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker" - register: curr_docker_version - changed_when: false - - - name: Get latest available version of Docker - command: > - {{ repoquery_cmd }} --qf '%{version}' "docker" - register: avail_docker_version - failed_when: false - changed_when: false - - - fail: - msg: This playbook requires access to Docker 1.10 or later - # Disable the 1.10 requirement if the user set a specific Docker version - when: avail_docker_version.stdout | version_compare('1.10','<') and docker_version is not defined - - - name: Flag for upgrade if Docker version does not equal latest - set_fact: - docker_upgrade: true - when: docker_version is not defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(avail_docker_version.stdout,'<') - - - name: Flag for upgrade if Docker version does not equal requested version - set_fact: - docker_upgrade: true - when: docker_version is defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') + - include: ../../../common/openshift-cluster/upgrades/docker/upgrade_check-yml # If a node fails, halt everything, the admin will need to clean up and we @@ -69,55 +35,7 @@ delegate_to: "{{ groups.oo_first_master.0 }}" when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config - - name: Stop containerized services - service: name={{ item }} state=stopped - with_items: - - "{{ openshift.common.service_type }}-master" - - "{{ openshift.common.service_type }}-master-api" - - "{{ openshift.common.service_type }}-master-controllers" - - "{{ openshift.common.service_type }}-node" - - etcd_container - - openvswitch - failed_when: false - when: docker_upgrade is defined and docker_upgrade | bool and openshift.common.is_containerized | bool - - - name: Remove all containers and images - script: files/nuke_images.sh docker - register: nuke_images_result - when: docker_upgrade is defined and docker_upgrade | bool - - # TODO: should we use the docker role to actually do the upgrade? - - name: Upgrade to specified Docker version - action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version }} state=present" - register: docker_upgrade_result - when: docker_upgrade is defined and docker_upgrade | bool and docker_version is defined - - - name: Upgrade to latest Docker version - action: "{{ ansible_pkg_mgr }} name=docker state=latest" - register: docker_upgrade_result - when: docker_upgrade is defined and docker_upgrade | bool and docker_version is not defined - - - name: Restart containerized services - service: name={{ item }} state=started - with_items: - - etcd_container - - openvswitch - - "{{ openshift.common.service_type }}-master" - - "{{ openshift.common.service_type }}-master-api" - - "{{ openshift.common.service_type }}-master-controllers" - - "{{ openshift.common.service_type }}-node" - failed_when: false - when: docker_upgrade is defined and docker_upgrade | bool and openshift.common.is_containerized | bool - - - name: Wait for master API to come back online - become: no - local_action: - module: wait_for - host="{{ inventory_hostname }}" - state=started - delay=10 - port="{{ openshift.master.api_port }}" - when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_masters_to_config + - include: ../../../common/openshift-cluster/upgrades/docker/upgrade.yml - name: Set node schedulability command: > diff --git a/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh b/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh deleted file mode 100644 index 9a5ee2276..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# Stop any running containers -running_container_count=`docker ps -q | wc -l` -if test $running_container_count -gt 0 -then - docker stop $(docker ps -q) -fi - -# Delete all containers -container_count=`docker ps -a -q | wc -l` -if test $container_count -gt 0 -then - docker rm -f -v $(docker ps -a -q) -fi - -# Delete all images (forcefully) -image_count=`docker images -q | wc -l` -if test $image_count -gt 0 -then - # Taken from: https://gist.github.com/brianclements/f72b2de8e307c7b56689#gistcomment-1443144 - docker rmi $(docker images | grep "$2/\|/$2 \| $2 \|$2 \|$2-\|$2_" | awk '{print $1 ":" $2}') 2>/dev/null || echo "No images matching \"$2\" left to purge." -fi diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml new file mode 100644 index 000000000..78b123881 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml @@ -0,0 +1,52 @@ +--- +# We need docker service up to remove all the images, but these services will keep +# trying to re-start and thus re-pull the images we're trying to delete. +- name: stop containerized services + service: name={{ item }} state=stopped + with_items: + - "{{ openshift.common.service_type }}-master" + - "{{ openshift.common.service_type }}-master-api" + - "{{ openshift.common.service_type }}-master-controllers" + - "{{ openshift.common.service_type }}-node" + - etcd_container + - openvswitch + failed_when: false + when: docker_upgrade is defined and docker_upgrade | bool and openshift.common.is_containerized | bool + +- name: remove all containers and images + script: nuke_images.sh docker + register: nuke_images_result + when: docker_upgrade is defined and docker_upgrade | bool + +# todo: should we use the docker role to actually do the upgrade? +- name: upgrade to specified docker version + action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version }} state=present" + register: docker_upgrade_result + when: docker_upgrade is defined and docker_upgrade | bool and docker_version is defined + +- name: upgrade to latest docker version + action: "{{ ansible_pkg_mgr }} name=docker state=latest" + register: docker_upgrade_result + when: docker_upgrade is defined and docker_upgrade | bool and docker_version is not defined + +- name: restart containerized services + service: name={{ item }} state=started + with_items: + - etcd_container + - openvswitch + - "{{ openshift.common.service_type }}-master" + - "{{ openshift.common.service_type }}-master-api" + - "{{ openshift.common.service_type }}-master-controllers" + - "{{ openshift.common.service_type }}-node" + failed_when: false + when: docker_upgrade is defined and docker_upgrade | bool and openshift.common.is_containerized | bool + +- name: wait for master api to come back online + become: no + local_action: + module: wait_for + host="{{ inventory_hostname }}" + state=started + delay=10 + port="{{ openshift.master.api_port }}" + when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_masters_to_config diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml new file mode 100644 index 000000000..928913ef3 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml @@ -0,0 +1,37 @@ +--- +- name: Determine available Docker version + script: ../../../../common/openshift-cluster/upgrades/files/rpm_versions.sh docker + register: g_docker_version_result + +- name: Check if Docker is installed + command: rpm -q docker + register: pkg_check + failed_when: pkg_check.rc > 1 + changed_when: no + +- name: Get current version of Docker + command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker" + register: curr_docker_version + changed_when: false + +- name: Get latest available version of Docker + command: > + {{ repoquery_cmd }} --qf '%{version}' "docker" + register: avail_docker_version + failed_when: false + changed_when: false + +- fail: + msg: This playbook requires access to Docker 1.10 or later + # Disable the 1.10 requirement if the user set a specific Docker version + when: avail_docker_version.stdout | version_compare('1.10','<') and docker_version is not defined + +- name: Flag for upgrade if Docker version does not equal latest + set_fact: + docker_upgrade: true + when: docker_version is not defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(avail_docker_version.stdout,'<') + +- name: Flag for upgrade if Docker version does not equal requested version + set_fact: + docker_upgrade: true + when: docker_version is defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') diff --git a/playbooks/common/openshift-cluster/upgrades/files/nuke_images.sh b/playbooks/common/openshift-cluster/upgrades/files/nuke_images.sh new file mode 100644 index 000000000..9a5ee2276 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/files/nuke_images.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Stop any running containers +running_container_count=`docker ps -q | wc -l` +if test $running_container_count -gt 0 +then + docker stop $(docker ps -q) +fi + +# Delete all containers +container_count=`docker ps -a -q | wc -l` +if test $container_count -gt 0 +then + docker rm -f -v $(docker ps -a -q) +fi + +# Delete all images (forcefully) +image_count=`docker images -q | wc -l` +if test $image_count -gt 0 +then + # Taken from: https://gist.github.com/brianclements/f72b2de8e307c7b56689#gistcomment-1443144 + docker rmi $(docker images | grep "$2/\|/$2 \| $2 \|$2 \|$2-\|$2_" | awk '{print $1 ":" $2}') 2>/dev/null || echo "No images matching \"$2\" left to purge." +fi diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml new file mode 100644 index 000000000..319758a06 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml @@ -0,0 +1,11 @@ +- include_vars: ../../../../../roles/openshift_node/vars/main.yml + +- name: Update systemd units + include: ../../../../../roles/openshift_node/tasks/systemd_units.yml openshift_version=v{{ g_new_version }} + +- name: Verifying the correct version was configured + shell: grep {{ verify_upgrade_version }} {{ item }} + with_items: + - /etc/sysconfig/openvswitch + - /etc/sysconfig/{{ openshift.common.service_type }}* + when: verify_upgrade_version is defined diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_upgrade.yml deleted file mode 100644 index 319758a06..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_upgrade.yml +++ /dev/null @@ -1,11 +0,0 @@ -- include_vars: ../../../../../roles/openshift_node/vars/main.yml - -- name: Update systemd units - include: ../../../../../roles/openshift_node/tasks/systemd_units.yml openshift_version=v{{ g_new_version }} - -- name: Verifying the correct version was configured - shell: grep {{ verify_upgrade_version }} {{ item }} - with_items: - - /etc/sysconfig/openvswitch - - /etc/sysconfig/{{ openshift.common.service_type }}* - when: verify_upgrade_version is defined diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/docker_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/docker_upgrade.yml deleted file mode 100644 index c7b18f51b..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/docker_upgrade.yml +++ /dev/null @@ -1,14 +0,0 @@ -- name: Check if Docker is installed - command: rpm -q docker - register: pkg_check - failed_when: pkg_check.rc > 1 - changed_when: no - -- name: Upgrade Docker - command: "{{ ansible_pkg_mgr}} update -y docker" - when: pkg_check.rc == 0 and g_docker_version.curr_version | version_compare('1.9','<') - register: docker_upgrade - -- name: Restart Docker - command: systemctl restart docker - when: docker_upgrade | changed diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/node_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/node_upgrade.yml deleted file mode 100644 index a911f12be..000000000 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/node_upgrade.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Prepare for Node evacuation - command: > - {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=false - delegate_to: "{{ groups.oo_first_master.0 }}" - -- name: Evacuate Node for Kubelet upgrade - command: > - {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --evacuate --force - delegate_to: "{{ groups.oo_first_master.0 }}" - -- include: rpm_upgrade.yml - vars: - component: "node" - openshift_version: "{{ openshift_pkg_version | default('') }}" - when: not openshift.common.is_containerized | bool - -- include: containerized_upgrade.yml - when: openshift.common.is_containerized | bool - -- name: Set node schedulability - command: > - {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=true - delegate_to: "{{ groups.oo_first_master.0 }}" - when: openshift.node.schedulable | bool diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index ec07f0a60..55ede13f0 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -3,7 +3,7 @@ # Evaluate host groups and gather facts ############################################################################### -- include: ../../common/openshift-cluster/initialize_facts.yml +- include: ../../initialize_facts.yml - name: Update repos hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config:oo_lb_to_config diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index 66f6f8e71..8eeb652a7 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -3,19 +3,6 @@ # The restart playbook should be run after this playbook completes. ############################################################################### -- name: Upgrade docker - hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config - roles: - - openshift_facts - tasks: - - include: docker_upgrade.yml - when: not openshift.common.is_atomic | bool - - name: Set post docker install facts - openshift_facts: - role: "{{ item.role }}" - with_items: - - role: docker - ############################################################################### # Upgrade Masters ############################################################################### @@ -68,36 +55,51 @@ ############################################################################### # Upgrade Nodes ############################################################################### -- name: Upgrade nodes - hosts: oo_nodes_to_config + +# Here we handle all tasks that might require a node evac. (upgrading docker, and the node service) +- name: Perform upgrades that may require node evacuation + hosts: oo_masters_to_config:oo_etcd_to_config:oo_nodes_to_config serial: 1 + any_errors_fatal: true roles: - openshift_facts handlers: - include: ../../../../../roles/openshift_node/handlers/main.yml tasks: - - include: node_upgrade.yml + # TODO: To better handle re-trying failed upgrades, it would be nice to check if the node + # or docker actually needs an upgrade before proceeding. + - name: Mark unschedulable if host is a node + command: > + {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=false + delegate_to: "{{ groups.oo_first_master.0 }}" + when: inventory_hostname in groups.oo_nodes_to_config - - set_fact: - node_update_complete: True + - name: Evacuate Node for Kubelet upgrade + command: > + {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --evacuate --force + delegate_to: "{{ groups.oo_first_master.0 }}" + when: inventory_hostname in groups.oo_nodes_to_config + + - include: ../docker/upgrade_check.yml + + - include: ../docker/upgrade.yml + when: docker_upgrade is defined and docker_upgrade | bool + + - include: rpm_upgrade.yml + vars: + component: "node" + openshift_version: "{{ openshift_pkg_version | default('') }}" + when: inventory_hostname in groups.oo_nodes_to_config and not openshift.common.is_containerized | bool + + - include: containerized_node_upgrade.yml + when: inventory_hostname in groups.oo_nodes_to_config and openshift.common.is_containerized | bool + + - name: Set node schedulability + command: > + {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=true + delegate_to: "{{ groups.oo_first_master.0 }}" + when: inventory_hostname in groups.oo_nodes_to_config and openshift.node.schedulable | bool -############################################################################## -# Gate on nodes update -############################################################################## -- name: Gate on nodes update - hosts: localhost - connection: local - become: no - tasks: - - set_fact: - node_update_completed: "{{ hostvars - | oo_select_keys(groups.oo_nodes_to_config) - | oo_collect('inventory_hostname', {'node_update_complete': true}) }}" - - set_fact: - node_update_failed: "{{ groups.oo_nodes_to_config | difference(node_update_completed) }}" - - fail: - msg: "Upgrade cannot continue. The following nodes did not finish updating: {{ node_update_failed | join(',') }}" - when: node_update_failed | length > 0 ############################################################################### # Reconcile Cluster Roles, Cluster Role Bindings and Security Context Constraints -- cgit v1.2.3 From fb2f9f9d2be747a631e9ab13cb7c7898987d509d Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 24 Jun 2016 10:59:11 -0300 Subject: Allow skipping Docker upgrade during OpenShift upgrade. --- inventory/byo/hosts.aep.example | 7 +++++++ inventory/byo/hosts.origin.example | 7 +++++++ inventory/byo/hosts.ose.example | 7 +++++++ .../openshift-cluster/upgrades/docker/upgrade_check.yml | 13 +++++++++++++ .../openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml | 3 +++ 5 files changed, 37 insertions(+) diff --git a/inventory/byo/hosts.aep.example b/inventory/byo/hosts.aep.example index ffed3c042..0f7998008 100644 --- a/inventory/byo/hosts.aep.example +++ b/inventory/byo/hosts.aep.example @@ -92,6 +92,13 @@ openshift_release=v3.2 # Default value: "--log-driver=json-file --log-opt max-size=50m" #openshift_docker_options="-l warn --ipv6=false" +# Specify exact version of Docker to configure or upgrade to. +# Downgrades are not supported and will error out. Be careful when upgrading docker from < 1.10 to > 1.10. +# docker_version="1.10.3" + +# Skip upgrading Docker during an OpenShift upgrade, leaves the current Docker version alone. +# docker_upgrade=False + # Alternate image format string. If you're not modifying the format string and # only need to inject your own registry you may want to consider # openshift_docker_additional_registries instead diff --git a/inventory/byo/hosts.origin.example b/inventory/byo/hosts.origin.example index d3d1e3994..27dd5a575 100644 --- a/inventory/byo/hosts.origin.example +++ b/inventory/byo/hosts.origin.example @@ -93,6 +93,13 @@ openshift_release=v1.2 # Default value: "--log-driver=json-file --log-opt max-size=50m" #openshift_docker_options="-l warn --ipv6=false" +# Specify exact version of Docker to configure or upgrade to. +# Downgrades are not supported and will error out. Be careful when upgrading docker from < 1.10 to > 1.10. +# docker_version="1.10.3" + +# Skip upgrading Docker during an OpenShift upgrade, leaves the current Docker version alone. +# docker_upgrade=False + # Alternate image format string. If you're not modifying the format string and # only need to inject your own registry you may want to consider # openshift_docker_additional_registries instead diff --git a/inventory/byo/hosts.ose.example b/inventory/byo/hosts.ose.example index 2514fcc96..1831b0bae 100644 --- a/inventory/byo/hosts.ose.example +++ b/inventory/byo/hosts.ose.example @@ -92,6 +92,13 @@ openshift_release=v3.2 # Default value: "--log-driver=json-file --log-opt max-size=50m" #openshift_docker_options="-l warn --ipv6=false" +# Specify exact version of Docker to configure or upgrade to. +# Downgrades are not supported and will error out. Be careful when upgrading docker from < 1.10 to > 1.10. +# docker_version="1.10.3" + +# Skip upgrading Docker during an OpenShift upgrade, leaves the current Docker version alone. +# docker_upgrade=False + # Alternate image format string. If you're not modifying the format string and # only need to inject your own registry you may want to consider # openshift_docker_additional_registries instead diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml index 928913ef3..caf8d1de5 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml @@ -1,4 +1,10 @@ --- + +# This snippet determines if docker_upgrade should be set for the host. If it's already +# set via the inventory we will respect it. Otherwise we check if the current version +# is equal to the either the latest, or the requested docker_version, and set +# docker_upgrade accordingly. + - name: Determine available Docker version script: ../../../../common/openshift-cluster/upgrades/files/rpm_versions.sh docker register: g_docker_version_result @@ -26,6 +32,13 @@ # Disable the 1.10 requirement if the user set a specific Docker version when: avail_docker_version.stdout | version_compare('1.10','<') and docker_version is not defined +# We respect docker_upgrade=False in the inventory, but True is the default and +# if set in inventory, we still flip it to False here and only set to true if +# they're not already running the required version. +- set_fact: + docker_upgrade: False + when: docker_upgrade is not defined or docker_upgrade | bool + - name: Flag for upgrade if Docker version does not equal latest set_fact: docker_upgrade: true diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index 8eeb652a7..f2e408ad4 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -80,7 +80,10 @@ delegate_to: "{{ groups.oo_first_master.0 }}" when: inventory_hostname in groups.oo_nodes_to_config + # Only check if docker upgrade is required if docker_upgrade is not + # already set to False. - include: ../docker/upgrade_check.yml + when: docker_upgrade is not defined or docker_upgrade | bool - include: ../docker/upgrade.yml when: docker_upgrade is defined and docker_upgrade | bool -- cgit v1.2.3 From 9a5bd6ab7b46228b62f8d8d29dd1f0574c3ec3fa Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 24 Jun 2016 17:04:43 -0300 Subject: Fix node/openvswitch containers not restarting after upgrade. --- .../upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml index 319758a06..60ea84f8e 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/containerized_node_upgrade.yml @@ -1,7 +1,7 @@ - include_vars: ../../../../../roles/openshift_node/vars/main.yml - name: Update systemd units - include: ../../../../../roles/openshift_node/tasks/systemd_units.yml openshift_version=v{{ g_new_version }} + include: ../../../../../roles/openshift_node/tasks/systemd_units.yml openshift_version={{ openshift_image_tag }} - name: Verifying the correct version was configured shell: grep {{ verify_upgrade_version }} {{ item }} -- cgit v1.2.3 From 08f1caed84d46d0263f0c1aaaf2da891946b1a96 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 27 Jun 2016 11:15:40 -0300 Subject: Only nuke images when crossing the Docker 1.10 boundary in upgrade. --- .../openshift-cluster/upgrades/docker/upgrade.yml | 27 ++++++++-------------- .../upgrades/docker/upgrade_check.yml | 17 +++++++++----- .../upgrades/v3_1_to_v3_2/pre.yml | 4 ++++ .../upgrades/v3_1_to_v3_2/upgrade.yml | 2 +- roles/docker/defaults/main.yml | 1 + roles/docker/tasks/main.yml | 2 +- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml index 78b123881..81db9ef20 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml @@ -1,7 +1,7 @@ --- # We need docker service up to remove all the images, but these services will keep # trying to re-start and thus re-pull the images we're trying to delete. -- name: stop containerized services +- name: Stop containerized services service: name={{ item }} state=stopped with_items: - "{{ openshift.common.service_type }}-master" @@ -11,25 +11,18 @@ - etcd_container - openvswitch failed_when: false - when: docker_upgrade is defined and docker_upgrade | bool and openshift.common.is_containerized | bool + when: docker_upgrade | bool and openshift.common.is_containerized | bool -- name: remove all containers and images +- name: Remove all containers and images script: nuke_images.sh docker register: nuke_images_result - when: docker_upgrade is defined and docker_upgrade | bool + when: docker_upgrade | bool and docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool -# todo: should we use the docker role to actually do the upgrade? -- name: upgrade to specified docker version +- name: Upgrade Docker action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version }} state=present" - register: docker_upgrade_result - when: docker_upgrade is defined and docker_upgrade | bool and docker_version is defined + when: docker_upgrade | bool -- name: upgrade to latest docker version - action: "{{ ansible_pkg_mgr }} name=docker state=latest" - register: docker_upgrade_result - when: docker_upgrade is defined and docker_upgrade | bool and docker_version is not defined - -- name: restart containerized services +- name: Restart containerized services service: name={{ item }} state=started with_items: - etcd_container @@ -39,9 +32,9 @@ - "{{ openshift.common.service_type }}-master-controllers" - "{{ openshift.common.service_type }}-node" failed_when: false - when: docker_upgrade is defined and docker_upgrade | bool and openshift.common.is_containerized | bool + when: docker_upgrade | bool and openshift.common.is_containerized | bool -- name: wait for master api to come back online +- name: Wait for master API to come back online become: no local_action: module: wait_for @@ -49,4 +42,4 @@ state=started delay=10 port="{{ openshift.master.api_port }}" - when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_masters_to_config + when: docker_upgrade | bool and inventory_hostname in groups.oo_masters_to_config diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml index caf8d1de5..7fd4657d5 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml @@ -39,12 +39,17 @@ docker_upgrade: False when: docker_upgrade is not defined or docker_upgrade | bool -- name: Flag for upgrade if Docker version does not equal latest - set_fact: - docker_upgrade: true - when: docker_version is not defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(avail_docker_version.stdout,'<') +# Make sure a docker_verison is set if none was requested: +- set_fact: + docker_version: avail_docker_version.stdout + when: docker_version is not defined -- name: Flag for upgrade if Docker version does not equal requested version +- name: Flag for Docker upgrade if necessary set_fact: - docker_upgrade: true + docker_upgrade: True when: docker_version is defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') + +- name: Flag to delete all images prior to upgrade if crossing Docker 1.10 boundary + set_fact: + docker_upgrade_nuke_images: True + when: docker_upgrade_nuke_images is not defined and docker_upgrade | bool and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=') diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 55ede13f0..e78418c6c 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -89,6 +89,10 @@ # defined, and overriding the normal behavior of protecting the installed version openshift_release: "3.2" openshift_protect_installed_version: False + # Docker role (a dependency) should be told not to do anything to installed version + # of docker, we handle this separately during upgrade. (the inventory may have a + # docker_version defined, we don't want to actually do it until later) + docker_protect_installed_version: True - name: Verify master processes hosts: oo_masters_to_config diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index f2e408ad4..bea1eb4e1 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -86,7 +86,7 @@ when: docker_upgrade is not defined or docker_upgrade | bool - include: ../docker/upgrade.yml - when: docker_upgrade is defined and docker_upgrade | bool + when: docker_upgrade | bool - include: rpm_upgrade.yml vars: diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index ed97d539c..da11ed0af 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -1 +1,2 @@ --- +docker_protect_installed_version: False diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 34be0a666..a52a28375 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -37,7 +37,7 @@ # Make sure Docker is installed, but does not update a running version. # Docker upgrades are handled by a separate playbook. - name: Install Docker - action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version if docker_version is defined else '' }} state=present" + action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version if docker_version is defined and not docker_protect_installed_version | bool else '' }} state=present" when: not openshift.common.is_atomic | bool - name: Start the Docker service -- cgit v1.2.3 From f004b526078b78b0ba9435b82af4d4f4d42de5e2 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 27 Jun 2016 15:44:04 -0300 Subject: More docker upgrade fixes. --- .../upgrades/docker/docker_upgrade.yml | 12 ++++++---- .../openshift-cluster/upgrades/docker/upgrade.yml | 9 ++++--- .../upgrades/docker/upgrade_check.yml | 28 ++++++++++------------ .../upgrades/v3_1_to_v3_2/upgrade.yml | 2 +- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml index 96c9fb15d..2d499329d 100644 --- a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml +++ b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml @@ -12,7 +12,8 @@ msg: Cannot upgrade Docker on Atomic hosts when: openshift.common.is_atomic | bool - - include: ../../../common/openshift-cluster/upgrades/docker/upgrade_check-yml + - include: ../../../../common/openshift-cluster/upgrades/docker/upgrade_check.yml + when: docker_upgrade is not defined or docker_upgrade | bool # If a node fails, halt everything, the admin will need to clean up and we @@ -27,20 +28,21 @@ command: > {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=false delegate_to: "{{ groups.oo_first_master.0 }}" - when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config + when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config - name: Evacuate Node for Kubelet upgrade command: > {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --evacuate --force delegate_to: "{{ groups.oo_first_master.0 }}" - when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config + when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config - - include: ../../../common/openshift-cluster/upgrades/docker/upgrade.yml + - include: ../../../../common/openshift-cluster/upgrades/docker/upgrade.yml + when: l_docker_upgrade is defined and l_docker_upgrade | bool - name: Set node schedulability command: > {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=true delegate_to: "{{ groups.oo_first_master.0 }}" when: openshift.node.schedulable | bool - when: docker_upgrade is defined and docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config and openshift.node.schedulable | bool + when: l_docker_upgrade is defined and l_docker_upgrade | bool and inventory_hostname in groups.oo_nodes_to_config and openshift.node.schedulable | bool diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml index 81db9ef20..20d66522f 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade.yml @@ -11,16 +11,15 @@ - etcd_container - openvswitch failed_when: false - when: docker_upgrade | bool and openshift.common.is_containerized | bool + when: openshift.common.is_containerized | bool - name: Remove all containers and images script: nuke_images.sh docker register: nuke_images_result - when: docker_upgrade | bool and docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool + when: docker_upgrade_nuke_images is defined and docker_upgrade_nuke_images | bool - name: Upgrade Docker action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version }} state=present" - when: docker_upgrade | bool - name: Restart containerized services service: name={{ item }} state=started @@ -32,7 +31,7 @@ - "{{ openshift.common.service_type }}-master-controllers" - "{{ openshift.common.service_type }}-node" failed_when: false - when: docker_upgrade | bool and openshift.common.is_containerized | bool + when: openshift.common.is_containerized | bool - name: Wait for master API to come back online become: no @@ -42,4 +41,4 @@ state=started delay=10 port="{{ openshift.master.api_port }}" - when: docker_upgrade | bool and inventory_hostname in groups.oo_masters_to_config + when: inventory_hostname in groups.oo_masters_to_config diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml index 7fd4657d5..0a70ab723 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml @@ -1,13 +1,11 @@ --- -# This snippet determines if docker_upgrade should be set for the host. If it's already -# set via the inventory we will respect it. Otherwise we check if the current version -# is equal to the either the latest, or the requested docker_version, and set -# docker_upgrade accordingly. +# This snippet determines if a Docker upgrade is required by checking the inventory +# variables, the available packages, and sets l_docker_version to True if so. -- name: Determine available Docker version - script: ../../../../common/openshift-cluster/upgrades/files/rpm_versions.sh docker - register: g_docker_version_result +- set_fact: + docker_upgrade: True + when: docker_upgrade is not defined - name: Check if Docker is installed command: rpm -q docker @@ -32,24 +30,22 @@ # Disable the 1.10 requirement if the user set a specific Docker version when: avail_docker_version.stdout | version_compare('1.10','<') and docker_version is not defined -# We respect docker_upgrade=False in the inventory, but True is the default and -# if set in inventory, we still flip it to False here and only set to true if -# they're not already running the required version. +# Default l_docker_upgrade to False, we'll set to True if an upgrade is required: - set_fact: - docker_upgrade: False - when: docker_upgrade is not defined or docker_upgrade | bool + l_docker_upgrade: False # Make sure a docker_verison is set if none was requested: - set_fact: - docker_version: avail_docker_version.stdout + docker_version: "{{ avail_docker_version.stdout }}" when: docker_version is not defined - name: Flag for Docker upgrade if necessary set_fact: - docker_upgrade: True - when: docker_version is defined and pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') + l_docker_upgrade: True + when: pkg_check.rc == 0 and curr_docker_version.stdout | version_compare(docker_version,'<') - name: Flag to delete all images prior to upgrade if crossing Docker 1.10 boundary set_fact: docker_upgrade_nuke_images: True - when: docker_upgrade_nuke_images is not defined and docker_upgrade | bool and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=') + when: docker_upgrade_nuke_images is not defined and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=') + diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index bea1eb4e1..6c27b0d44 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -86,7 +86,7 @@ when: docker_upgrade is not defined or docker_upgrade | bool - include: ../docker/upgrade.yml - when: docker_upgrade | bool + when: l_docker_upgrade is defined and l_docker_upgrade | bool - include: rpm_upgrade.yml vars: -- cgit v1.2.3 From 6c746ab59b9c02a9e416dd2ccb9552f1d9112fcb Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 28 Jun 2016 10:56:12 -0300 Subject: Fixes for non-containerized separate etcd hosts. --- playbooks/common/openshift-cluster/initialize_facts.yml | 3 +++ playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml | 2 +- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 5 +---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_facts.yml b/playbooks/common/openshift-cluster/initialize_facts.yml index a4af5efc5..b44102abc 100644 --- a/playbooks/common/openshift-cluster/initialize_facts.yml +++ b/playbooks/common/openshift-cluster/initialize_facts.yml @@ -10,3 +10,6 @@ hostname: "{{ openshift_hostname | default(None) }}" - set_fact: openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" + - set_fact: + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" + diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml index 0a70ab723..06b3e244f 100644 --- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml +++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml @@ -47,5 +47,5 @@ - name: Flag to delete all images prior to upgrade if crossing Docker 1.10 boundary set_fact: docker_upgrade_nuke_images: True - when: docker_upgrade_nuke_images is not defined and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=') + when: l_docker_upgrade | bool and docker_upgrade_nuke_images is not defined and curr_docker_version.stdout | version_compare('1.10','<') and docker_version | version_compare('1.10','>=') diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index 11e77c3de..b49b3df7d 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -5,7 +5,7 @@ - include: ../../initialize_facts.yml -- name: Update repos +- name: Update repos and initialize facts on all hosts hosts: oo_masters_to_config:oo_nodes_to_config:oo_etcd_to_config:oo_lb_to_config roles: - openshift_repos @@ -165,9 +165,6 @@ docker pull {{ openshift.common.cli_image }}:{{ openshift_image_tag }} when: openshift.common.is_containerized | bool - - set_fact: - repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" - - name: Check latest available OpenShift RPM version command: > {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type }}" -- cgit v1.2.3 From 212faa41ce03f1719598e87fc1453ed8580655ca Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 4 Jul 2016 09:55:25 -0300 Subject: Fix typo in example inventories. --- inventory/byo/hosts.aep.example | 2 +- inventory/byo/hosts.origin.example | 2 +- inventory/byo/hosts.ose.example | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inventory/byo/hosts.aep.example b/inventory/byo/hosts.aep.example index a4f730bc0..7f3f7ee50 100644 --- a/inventory/byo/hosts.aep.example +++ b/inventory/byo/hosts.aep.example @@ -39,7 +39,7 @@ openshift_release=v3.2 # Specify an exact rpm version to install or configure. # WARNING: This value will be used for all hosts in RPM based environments, even those that have another version installed. # This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. -#openshift_image_tag=-3.2.0.46 +#openshift_pkg_version=-3.2.0.46 # Install the openshift examples #openshift_install_examples=true diff --git a/inventory/byo/hosts.origin.example b/inventory/byo/hosts.origin.example index 5b17bbe71..892c015c5 100644 --- a/inventory/byo/hosts.origin.example +++ b/inventory/byo/hosts.origin.example @@ -40,7 +40,7 @@ openshift_release=v1.2 # Specify an exact rpm version to install or configure. # WARNING: This value will be used for all hosts in RPM based environments, even those that have another version installed. # This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. -#openshift_image_tag=-1.2.0 +#openshift_pkg_version=-1.2.0 # Install the openshift examples #openshift_install_examples=true diff --git a/inventory/byo/hosts.ose.example b/inventory/byo/hosts.ose.example index e74474b58..6e6af3ea7 100644 --- a/inventory/byo/hosts.ose.example +++ b/inventory/byo/hosts.ose.example @@ -39,7 +39,7 @@ openshift_release=v3.2 # Specify an exact rpm version to install or configure. # WARNING: This value will be used for all hosts in RPM based environments, even those that have another version installed. # This could potentially trigger an upgrade and downtime, so be careful with modifying this value after the cluster is set up. -#openshift_image_tag=-3.2.0.46 +#openshift_pkg_version=-3.2.0.46 # Install the openshift examples #openshift_install_examples=true -- cgit v1.2.3 From 0071ab46bf9ae73bbb09c9fa0c9eb8a342a81ba1 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 4 Jul 2016 10:08:36 -0300 Subject: Fix unsafe bool usage. --- roles/openshift_version/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index ac3efe7e9..8cd66cbe9 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -34,7 +34,7 @@ - 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 + when: openshift.common.version is defined and openshift_version is not defined and openshift_protect_installed_version | bool - debug: var=is_containerized - debug: var=openshift_version -- cgit v1.2.3 From 0f5b273c977af59ee2fdbb63efe8b8a3722c988c Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 4 Jul 2016 10:35:50 -0300 Subject: Update repoquery_cmd definitions to match latest in master. --- playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml | 2 +- playbooks/common/openshift-cluster/initialize_facts.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml index 1919039d1..3a285ab9f 100644 --- a/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml +++ b/playbooks/byo/openshift-cluster/upgrades/docker/docker_upgrade.yml @@ -5,7 +5,7 @@ - openshift_facts tasks: - set_fact: - repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}" - fail: msg: Cannot upgrade Docker on Atomic operating systems. diff --git a/playbooks/common/openshift-cluster/initialize_facts.yml b/playbooks/common/openshift-cluster/initialize_facts.yml index 4cade9c61..d6759cb13 100644 --- a/playbooks/common/openshift-cluster/initialize_facts.yml +++ b/playbooks/common/openshift-cluster/initialize_facts.yml @@ -12,5 +12,5 @@ - set_fact: openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" - set_fact: - repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery' }}" + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}" -- cgit v1.2.3 From cf737735ffdbc2a83d03361e57538a5bff903f6f Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 4 Jul 2016 12:52:06 -0300 Subject: Fixes for Ansible 2.1. --- .../byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml | 4 ---- roles/openshift_version/tasks/main.yml | 9 ++++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index 24617620b..8c89e118e 100644 --- a/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -4,10 +4,6 @@ become: no gather_facts: no tasks: - - name: Verify Ansible version is greater than or equal to 1.9.4 and less than 2.0 - fail: - msg: "Unsupported ansible version: {{ ansible_version }} found." - when: ansible_version.full | version_compare('1.9.4', 'lt') or ansible_version.full | version_compare('2.0', 'ge') - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - add_host: name: "{{ item }}" diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 8cd66cbe9..a27ddeaee 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -69,13 +69,16 @@ - debug: var=openshift_pkg_version - debug: var=openshift_image_tag -- fail: openshift_version role was unable to set openshift_version +- fail: + msg: openshift_version role was unable to set openshift_version when: openshift_version is not defined -- fail: openshift_version role was unable to set openshift_image_tag +- fail: + msg: openshift_version role was unable to set openshift_image_tag when: openshift_image_tag is not defined -- fail: openshift_version role was unable to set openshift_pkg_version +- fail: + msg: openshift_version role was unable to set openshift_pkg_version when: openshift_pkg_version is not defined # We can't map an openshift_release to full rpm version like we can with containers, make sure -- cgit v1.2.3 From 76829048f7b529f0932bb99d96a774244329291a Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 4 Jul 2016 14:32:25 -0300 Subject: Add symlinks for node templates. This is an unfortunate side effect of including a role yaml file in a playbook, ideally we would just run the full node role here. For now we'll follow the lead for the master template. --- .../upgrades/v3_1_to_v3_2/openshift.docker.node.dep.service | 1 + .../upgrades/v3_1_to_v3_2/openshift.docker.node.service | 1 + .../openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.docker.service | 1 + .../openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.sysconfig.j2 | 1 + 4 files changed, 4 insertions(+) create mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.dep.service create mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.service create mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.docker.service create mode 120000 playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.sysconfig.j2 diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.dep.service b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.dep.service new file mode 120000 index 000000000..b384a3f4d --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.dep.service @@ -0,0 +1 @@ +../../../../../roles/openshift_node/templates/openshift.docker.node.dep.service \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.service b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.service new file mode 120000 index 000000000..a2f140144 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openshift.docker.node.service @@ -0,0 +1 @@ +../../../../../roles/openshift_node/templates/openshift.docker.node.service \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.docker.service b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.docker.service new file mode 120000 index 000000000..61946ff91 --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.docker.service @@ -0,0 +1 @@ +../../../../../roles/openshift_node/templates/openvswitch.docker.service \ No newline at end of file diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.sysconfig.j2 b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.sysconfig.j2 new file mode 120000 index 000000000..3adc56e4e --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/openvswitch.sysconfig.j2 @@ -0,0 +1 @@ +../../../../../roles/openshift_node/templates/openvswitch.sysconfig.j2 \ No newline at end of file -- cgit v1.2.3 From c1728c8847177988e4532b9c9c777e1a23223410 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 7 Jul 2016 12:28:28 -0300 Subject: Move repoquery fact definition to openshift_common. --- playbooks/common/openshift-cluster/initialize_facts.yml | 3 --- roles/openshift_common/tasks/main.yml | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_facts.yml b/playbooks/common/openshift-cluster/initialize_facts.yml index d6759cb13..04dde632b 100644 --- a/playbooks/common/openshift-cluster/initialize_facts.yml +++ b/playbooks/common/openshift-cluster/initialize_facts.yml @@ -11,6 +11,3 @@ hostname: "{{ openshift_hostname | default(None) }}" - set_fact: openshift_docker_hosted_registry_network: "{{ hostvars[groups.oo_first_master.0].openshift.common.portal_net }}" - - set_fact: - repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}" - diff --git a/roles/openshift_common/tasks/main.yml b/roles/openshift_common/tasks/main.yml index 77f3811c1..afddef125 100644 --- a/roles/openshift_common/tasks/main.yml +++ b/roles/openshift_common/tasks/main.yml @@ -45,3 +45,8 @@ command: > hostnamectl set-hostname {{ openshift.common.hostname }} when: openshift_set_hostname | default(set_hostname_default) | bool + +- name: Set repoquery command + set_fact: + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}" + -- cgit v1.2.3 From 6ec757e4449fbc59f509f980bd9423bdb35412eb Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 7 Jul 2016 15:05:11 -0300 Subject: Update quick upgrade to remove unsupported options. Upgrade mappings can now optionally support an upgrade to latest minor version, and an upgrade to next major version. Dropped the "minor_version" as it is already defined by the mapping key. For 3.2 the minor upgrade playbook is the same as the major. --- utils/src/ooinstall/cli_installer.py | 67 +++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index c896a74b4..cd74ed233 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -828,46 +828,63 @@ def upgrade(ctx, latest_minor, next_major): oo_cfg = ctx.obj['oo_cfg'] verbose = ctx.obj['verbose'] + # major/minor fields are optional, as we don't always support minor/major + # upgrade for what you're currently running. upgrade_mappings = { - '3.0':{ - 'minor_version' :'3.0', - 'minor_playbook':'v3_0_minor/upgrade.yml', - 'major_version' :'3.1', - 'major_playbook':'v3_0_to_v3_1/upgrade.yml', - }, '3.1':{ - 'minor_version' :'3.1', - 'minor_playbook':'v3_1_minor/upgrade.yml', 'major_playbook':'v3_1_to_v3_2/upgrade.yml', 'major_version' :'3.2', - } + }, + '3.2':{ + 'minor_playbook':'v3_1_to_v3_2/upgrade.yml', +# Uncomment these when we're ready to support 3.3. +# 'major_version' :'3.3', +# 'major_playbook':'v3_1_to_v3_2/upgrade.yml', + }, } if len(oo_cfg.hosts) == 0: click.echo("No hosts defined in: %s" % oo_cfg.config_path) sys.exit(1) - old_variant = oo_cfg.settings['variant'] + variant = oo_cfg.settings['variant'] + if find_variant(variant)[0] is None: + click.echo("%s is not a supported variant for upgrade." % variant) + sys.exit(0) + old_version = oo_cfg.settings['variant_version'] mapping = upgrade_mappings.get(old_version) message = """ This tool will help you upgrade your existing OpenShift installation. + Currently running: %s %s """ - click.echo(message) + click.echo(message % (variant, old_version)) + # Map the dynamic upgrade options to the playbook to run for each. + # Index offset by 1. + # List contains tuples of booleans for (latest_minor, next_major) + selections = [] if not (latest_minor or next_major): - click.echo("Version {} found. Do you want to update to the latest version of {} " \ - "or migrate to the next major release?".format(old_version, old_version)) - response = click.prompt("(1) Update to latest {} " \ - "(2) Migrate to next release".format(old_version), - type=click.Choice(['1', '2']),) - if response == "1": - latest_minor = True - if response == "2": - next_major = True + i = 0 + if 'minor_playbook' in mapping: + click.echo("(%s) Update to latest %s" % (i + 1, old_version)) + selections.append((True, False)) + i += 1 + if 'major_playbook' in mapping: + click.echo("(%s) Upgrade to next release: %s" % (i + 1, mapping['major_version'])) + selections.append((False, True)) + i += 1 + + response = click.prompt("\nChoose an option from above", + type=click.Choice(list(map(str, range(1, len(selections) + 1))))) + latest_minor, next_major = selections[int(response) - 1] if next_major: + if 'major_playbook' not in mapping: + click.echo("No major upgrade supported for %s %s with this version "\ + "of atomic-openshift-utils." % (variant, version)) + sys.exit(0) playbook = mapping['major_playbook'] new_version = mapping['major_version'] # Update config to reflect the version we're targetting, we'll write @@ -877,11 +894,15 @@ def upgrade(ctx, latest_minor, next_major): oo_cfg.settings['variant'] = 'openshift-enterprise' if latest_minor: + if 'minor_playbook' not in mapping: + click.echo("No minor upgrade supported for %s %s with this version "\ + "of atomic-openshift-utils." % (variant, old_version)) + sys.exit(0) playbook = mapping['minor_playbook'] - new_version = mapping['minor_version'] + new_version = old_version - click.echo("Openshift will be upgraded from %s %s to %s %s on the following hosts:\n" % ( - old_variant, old_version, oo_cfg.settings['variant'], new_version)) + click.echo("Openshift will be upgraded from %s %s to latest %s %s on the following hosts:\n" % ( + variant, old_version, oo_cfg.settings['variant'], new_version)) for host in oo_cfg.hosts: click.echo(" * %s" % host.connect_to) -- cgit v1.2.3 From 5628e0ce7c86efd47f11310dee204f4a4a8dfc04 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 8 Jul 2016 11:43:25 -0300 Subject: Remove all debug used during devel of openshift_version. --- .../openshift-cluster/initialize_openshift_version.yml | 13 ------------- .../common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml | 2 -- roles/docker/tasks/main.yml | 5 ----- roles/openshift_cli/tasks/main.yml | 3 --- roles/openshift_version/tasks/main.yml | 12 ------------ roles/openshift_version/tasks/set_version_containerized.yml | 6 ------ roles/openshift_version/tasks/set_version_rpm.yml | 4 ---- 7 files changed, 45 deletions(-) diff --git a/playbooks/common/openshift-cluster/initialize_openshift_version.yml b/playbooks/common/openshift-cluster/initialize_openshift_version.yml index 972df050c..7112a6084 100644 --- a/playbooks/common/openshift-cluster/initialize_openshift_version.yml +++ b/playbooks/common/openshift-cluster/initialize_openshift_version.yml @@ -4,10 +4,6 @@ hosts: oo_first_master roles: - openshift_version - pre_tasks: - - debug: var=openshift_version - post_tasks: - - 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 @@ -18,12 +14,3 @@ openshift_version: "{{ hostvars[groups.oo_first_master.0].openshift_version }}" roles: - openshift_version - pre_tasks: - - debug: var=hostvars[groups.oo_first_master.0].openshift_version - - debug: var=openshift.common.version - - debug: var=openshift_version - post_tasks: - - debug: var=hostvars[groups.oo_first_master.0].openshift_version - - debug: var=openshift.common.version - - debug: var=openshift_version - diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index b49b3df7d..7a8dfdf91 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -173,8 +173,6 @@ register: avail_openshift_version when: not openshift.common.is_containerized | bool - - debug: var=avail_openshift_version - - name: Verify OpenShift 3.2 RPMs are available for upgrade fail: msg: "OpenShift {{ avail_openshift_version.stdout }} is available, but 3.2 or greater is required" diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index a52a28375..aba852e63 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -2,8 +2,6 @@ - stat: path=/etc/sysconfig/docker-storage register: docker_storage_check -- debug: var=docker_version - - name: Get current installed Docker version command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker" when: docker_version is defined and not openshift.common.is_atomic | bool @@ -92,9 +90,6 @@ - restart docker when: "{{ 'http_proxy' in openshift.common or 'https_proxy' in openshift.common and docker_check.stat.isreg }}" -- debug: var=openshift.docker.options -- debug: var=docker_options - - name: Set various Docker options lineinfile: dest: /etc/sysconfig/docker diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml index 097c05483..6b4f16c78 100644 --- a/roles/openshift_cli/tasks/main.yml +++ b/roles/openshift_cli/tasks/main.yml @@ -1,7 +1,4 @@ --- -- debug: var=openshift_version -- debug: var=openshift.common - - name: Install clients action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-clients state=present" when: not openshift.common.is_containerized | bool diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index a27ddeaee..b4f3fb36d 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -36,14 +36,6 @@ openshift_version: "{{ openshift.common.version }}" when: openshift.common.version is defined and openshift_version is not defined and openshift_protect_installed_version | bool -- debug: var=is_containerized -- debug: var=openshift_version -- debug: msg="{{ openshift_version is defined }}" -- debug: var=openshift_release -- debug: var=openshift_pkg_version -- debug: var=openshift_image_tag -- debug: var=openshift.common.version - - name: Set openshift_version for rpm installation include: set_version_rpm.yml when: not is_containerized | bool @@ -65,10 +57,6 @@ openshift_pkg_version: -{{ openshift_version }} when: openshift_pkg_version is not defined -- debug: var=openshift_version -- debug: var=openshift_pkg_version -- debug: var=openshift_image_tag - - fail: msg: openshift_version role was unable to set openshift_version when: openshift_version is not defined diff --git a/roles/openshift_version/tasks/set_version_containerized.yml b/roles/openshift_version/tasks/set_version_containerized.yml index d822ee164..8e2702391 100644 --- a/roles/openshift_version/tasks/set_version_containerized.yml +++ b/roles/openshift_version/tasks/set_version_containerized.yml @@ -16,8 +16,6 @@ register: cli_image_version when: openshift_version is not defined -- debug: var=cli_image_version - # 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:] }}" @@ -27,10 +25,6 @@ openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}" when: openshift_version is not defined -- debug: msg="{{ openshift_version }}" - - - # 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 diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index 889ecc56c..cf0a3b51f 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -6,8 +6,6 @@ openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}" when: openshift_pkg_version is defined and openshift_version is not defined -- debug: var=openshift_version - - name: Gather common package version command: > {{ repoquery_cmd }} --qf '%{version}' "{{ openshift.common.service_type}}" @@ -16,8 +14,6 @@ changed_when: false when: openshift_version is not defined -- debug: var=common_version - - set_fact: openshift_version: "{{ common_version.stdout | default('0.0', True) }}" when: openshift_version is not defined -- cgit v1.2.3 From 2a8b144073f474bf966c6ab92329442a1a526bde Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Fri, 8 Jul 2016 11:48:12 -0300 Subject: Remove/update TODOs. --- playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml | 3 ++- roles/docker/tasks/main.yml | 2 -- roles/openshift_facts/library/openshift_facts.py | 3 --- roles/openshift_version/tasks/set_version_rpm.yml | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml index 6c27b0d44..0ea315d0a 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml @@ -67,7 +67,8 @@ - include: ../../../../../roles/openshift_node/handlers/main.yml tasks: # TODO: To better handle re-trying failed upgrades, it would be nice to check if the node - # or docker actually needs an upgrade before proceeding. + # or docker actually needs an upgrade before proceeding. Perhaps best to save this until + # we merge upgrade functionality into the base roles and a normal config.yml playbook run. - name: Mark unschedulable if host is a node command: > {{ openshift.common.admin_binary }} manage-node {{ openshift.common.hostname | lower }} --schedulable=false diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index aba852e63..ac065ea51 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -16,8 +16,6 @@ changed_when: false when: docker_version is defined and not openshift.common.is_atomic | bool -# TODO: Should we use docker_version defaulted to 1.10 here? - # If a docker_version was requested, sanity check that we can install or upgrade to it, and # no downgrade is required. - name: Fail if Docker version requested but downgrade is required diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 135224c16..fdd3e8708 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1142,9 +1142,6 @@ def get_openshift_version(facts): if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) - # TODO: it probably makes more sense to read this from sysconfig service env files, - # these control the running versions when containerized, and would work even if the service - # is dead for some reason. elif 'common' in facts and 'is_containerized' in facts['common']: version = get_containerized_openshift_version(facts) diff --git a/roles/openshift_version/tasks/set_version_rpm.yml b/roles/openshift_version/tasks/set_version_rpm.yml index cf0a3b51f..7fa74e24f 100644 --- a/roles/openshift_version/tasks/set_version_rpm.yml +++ b/roles/openshift_version/tasks/set_version_rpm.yml @@ -1,5 +1,4 @@ --- -# 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 remove trailing release, -- cgit v1.2.3 From 02d4470e1ff26350a2e02567246627aaf09455eb Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 11 Jul 2016 10:08:14 -0300 Subject: Use proper startswith. --- filter_plugins/oo_filters.py | 5 ----- roles/openshift_version/tasks/main.yml | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 54891b066..7510975f2 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -891,10 +891,6 @@ class FilterModule(object): return version - @staticmethod - def oo_startswith(input, prefix): - return input.startswith(prefix) - def filters(self): """ returns a mapping of filters to methods """ return { @@ -928,5 +924,4 @@ class FilterModule(object): "oo_oc_nodes_matching_selector": self.oo_oc_nodes_matching_selector, "oo_oc_nodes_with_label": self.oo_oc_nodes_with_label, "oo_merge_hostvars": self.oo_merge_hostvars, - "oo_startswith": self.oo_startswith, } diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index b4f3fb36d..2d96d2765 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -73,4 +73,4 @@ # 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 or specify an exact openshift_pkg_version." - when: not is_containerized | bool and openshift_release is defined and not openshift_version | oo_startswith(openshift_release) | bool + when: not is_containerized | bool and openshift_release is defined and not openshift_version.startswith(openshift_release) | bool -- cgit v1.2.3 From 02fde33acd3022b1a684c3aaa42b4d2052d1c830 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 11 Jul 2016 16:06:27 -0300 Subject: Add dependency on docker to openshift_docker role. I think this is intended anytime a role uses openshift_docker. Fixes issue where docker_version is ignored for rpm based installs. We made the dependency in openshift_version conditional to allow use of openshift_version without significantly impacting the system, however nothing ever actually ran the docker role after that, resulting in docker simply being installed via the rpm dependency on atomic-openshift. --- roles/openshift_docker/meta/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/openshift_docker/meta/main.yml b/roles/openshift_docker/meta/main.yml index c1a6611d1..10131f717 100644 --- a/roles/openshift_docker/meta/main.yml +++ b/roles/openshift_docker/meta/main.yml @@ -13,3 +13,5 @@ galaxy_info: - cloud dependencies: - role: openshift_version +- role: openshift_docker_facts +- role: docker -- cgit v1.2.3 From b9d00cb5bf5d81b6c94e08a67021c32f3239103c Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 11 Jul 2016 16:27:59 -0300 Subject: Move repoquery_cmd fact setting into a more logical place. --- roles/openshift_common/tasks/main.yml | 4 ---- roles/openshift_facts/tasks/main.yml | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/roles/openshift_common/tasks/main.yml b/roles/openshift_common/tasks/main.yml index afddef125..ece335fbf 100644 --- a/roles/openshift_common/tasks/main.yml +++ b/roles/openshift_common/tasks/main.yml @@ -46,7 +46,3 @@ hostnamectl set-hostname {{ openshift.common.hostname }} when: openshift_set_hostname | default(set_hostname_default) | bool -- name: Set repoquery command - set_fact: - repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}" - diff --git a/roles/openshift_facts/tasks/main.yml b/roles/openshift_facts/tasks/main.yml index ca1a9b1e4..c3723672d 100644 --- a/roles/openshift_facts/tasks/main.yml +++ b/roles/openshift_facts/tasks/main.yml @@ -41,3 +41,8 @@ no_proxy: "{{ openshift_no_proxy | default(None) }}" generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}" no_proxy_internal_hostnames: "{{ openshift_no_proxy_internal_hostnames | default(None) }}" + +- name: Set repoquery command + set_fact: + repoquery_cmd: "{{ 'dnf repoquery --latest-limit 1 -d 0' if ansible_pkg_mgr == 'dnf' else 'repoquery --plugins' }}" + -- cgit v1.2.3 From 7ce564ca44ef1b02037a2255244bd8f3057734dc Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 12 Jul 2016 10:27:39 -0300 Subject: Fix upgrades with an openshift_image_tag set. --- .../common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml index 1d97d3802..f5e4d807e 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml @@ -1,6 +1,6 @@ # We verified latest rpm available is suitable, so just yum update. - name: Upgrade packages - command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-{{ component }}" + action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}-{{ component }}{{ openshift_pkg_version }} state=present" - name: Ensure python-yaml present for config upgrade action: "{{ ansible_pkg_mgr }} name=PyYAML state=present" -- cgit v1.2.3 From 9b5e7f325247a204d36812558cce8c0eed5732ab Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 12 Jul 2016 15:27:46 -0300 Subject: Rename upgrade to just v3_2 as it's now major and minor. --- .../upgrades/v3_1_to_v3_2/README.md | 16 ------- .../upgrades/v3_1_to_v3_2/upgrade.yml | 55 ---------------------- .../byo/openshift-cluster/upgrades/v3_2/README.md | 16 +++++++ .../openshift-cluster/upgrades/v3_2/upgrade.yml | 55 ++++++++++++++++++++++ 4 files changed, 71 insertions(+), 71 deletions(-) delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/README.md delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml create mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_2/README.md create mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/README.md b/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/README.md deleted file mode 100644 index 62577c3df..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# v3.1 to v3.2 upgrade playbook - -## Overview -This playbook currently performs the -following steps. - - * Upgrade and restart master services - * Upgrade and restart node services - * Modifies the subset of the configuration necessary - * Applies the latest cluster policies - * Updates the default router if one exists - * Updates the default registry if one exists - * Updates image streams and quickstarts - -## Usage -ansible-playbook -i ~/ansible-inventory openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml deleted file mode 100644 index 8c89e118e..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -- hosts: localhost - connection: local - become: no - gather_facts: no - tasks: - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - - add_host: - name: "{{ item }}" - groups: l_oo_all_hosts - with_items: g_all_hosts | default([]) - -- hosts: l_oo_all_hosts - gather_facts: no - tasks: - - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml - -- include: ../../../../common/openshift-cluster/evaluate_groups.yml - vars: - # Do not allow adding hosts during upgrade. - g_new_master_hosts: [] - g_new_node_hosts: [] - openshift_cluster_id: "{{ cluster_id | default('default') }}" - openshift_deployment_type: "{{ deployment_type }}" - -- name: Set oo_options - hosts: oo_all_hosts - tasks: - - set_fact: - openshift_docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries') }}" - when: openshift_docker_additional_registries is not defined - - set_fact: - openshift_docker_insecure_registries: "{{ lookup('oo_option', 'docker_insecure_registries') }}" - when: openshift_docker_insecure_registries is not defined - - set_fact: - openshift_docker_blocked_registries: "{{ lookup('oo_option', 'docker_blocked_registries') }}" - when: openshift_docker_blocked_registries is not defined - - set_fact: - openshift_docker_options: "{{ lookup('oo_option', 'docker_options') }}" - when: openshift_docker_options is not defined - - set_fact: - openshift_docker_log_driver: "{{ lookup('oo_option', 'docker_log_driver') }}" - when: openshift_docker_log_driver is not defined - - set_fact: - openshift_docker_log_options: "{{ lookup('oo_option', 'docker_log_options') }}" - when: openshift_docker_log_options is not defined - -- include: ../../../../common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml - vars: - openshift_deployment_type: "{{ deployment_type }}" -- include: ../../../../common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml - vars: - openshift_deployment_type: "{{ deployment_type }}" -- include: ../../../openshift-master/restart.yml -- include: ../../../../common/openshift-cluster/upgrades/v3_1_to_v3_2/post.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_2/README.md b/playbooks/byo/openshift-cluster/upgrades/v3_2/README.md new file mode 100644 index 000000000..62577c3df --- /dev/null +++ b/playbooks/byo/openshift-cluster/upgrades/v3_2/README.md @@ -0,0 +1,16 @@ +# v3.1 to v3.2 upgrade playbook + +## Overview +This playbook currently performs the +following steps. + + * Upgrade and restart master services + * Upgrade and restart node services + * Modifies the subset of the configuration necessary + * Applies the latest cluster policies + * Updates the default router if one exists + * Updates the default registry if one exists + * Updates image streams and quickstarts + +## Usage +ansible-playbook -i ~/ansible-inventory openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml new file mode 100644 index 000000000..8c89e118e --- /dev/null +++ b/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml @@ -0,0 +1,55 @@ +--- +- hosts: localhost + connection: local + become: no + gather_facts: no + tasks: + - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml + - add_host: + name: "{{ item }}" + groups: l_oo_all_hosts + with_items: g_all_hosts | default([]) + +- hosts: l_oo_all_hosts + gather_facts: no + tasks: + - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml + +- include: ../../../../common/openshift-cluster/evaluate_groups.yml + vars: + # Do not allow adding hosts during upgrade. + g_new_master_hosts: [] + g_new_node_hosts: [] + openshift_cluster_id: "{{ cluster_id | default('default') }}" + openshift_deployment_type: "{{ deployment_type }}" + +- name: Set oo_options + hosts: oo_all_hosts + tasks: + - set_fact: + openshift_docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries') }}" + when: openshift_docker_additional_registries is not defined + - set_fact: + openshift_docker_insecure_registries: "{{ lookup('oo_option', 'docker_insecure_registries') }}" + when: openshift_docker_insecure_registries is not defined + - set_fact: + openshift_docker_blocked_registries: "{{ lookup('oo_option', 'docker_blocked_registries') }}" + when: openshift_docker_blocked_registries is not defined + - set_fact: + openshift_docker_options: "{{ lookup('oo_option', 'docker_options') }}" + when: openshift_docker_options is not defined + - set_fact: + openshift_docker_log_driver: "{{ lookup('oo_option', 'docker_log_driver') }}" + when: openshift_docker_log_driver is not defined + - set_fact: + openshift_docker_log_options: "{{ lookup('oo_option', 'docker_log_options') }}" + when: openshift_docker_log_options is not defined + +- include: ../../../../common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml + vars: + openshift_deployment_type: "{{ deployment_type }}" +- include: ../../../../common/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml + vars: + openshift_deployment_type: "{{ deployment_type }}" +- include: ../../../openshift-master/restart.yml +- include: ../../../../common/openshift-cluster/upgrades/v3_1_to_v3_2/post.yml -- cgit v1.2.3 From db8b2513071c367e0f67203feabede25545a6d97 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Tue, 12 Jul 2016 15:28:45 -0300 Subject: Remove 3.0 and 3.1 upgrade sub-dirs. --- .../openshift-cluster/upgrades/v3_0_minor/README.md | 21 --------------------- .../upgrades/v3_0_to_v3_1/README.md | 16 ---------------- .../openshift-cluster/upgrades/v3_1_minor/README.md | 17 ----------------- 3 files changed, 54 deletions(-) delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_0_minor/README.md delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/README.md delete mode 100644 playbooks/byo/openshift-cluster/upgrades/v3_1_minor/README.md diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/README.md b/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/README.md deleted file mode 100644 index c91a6cb96..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# v3.0 minor upgrade playbook -**Note:** This playbook will re-run installation steps overwriting any local -modifications. You should ensure that your inventory has been updated with any -modifications you've made after your initial installation. If you find any items -that cannot be configured via ansible please open an issue at -https://github.com/openshift/openshift-ansible - -## Overview -This playbook is available as a technical preview. It currently performs the -following steps. - - * Upgrade and restart master services - * Upgrade and restart node services - * Applies latest configuration by re-running the installation playbook - * Applies the latest cluster policies - * Updates the default router if one exists - * Updates the default registry if one exists - * Updates image streams and quickstarts - -## Usage -ansible-playbook -i ~/ansible-inventory openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_0_minor/upgrade.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/README.md b/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/README.md deleted file mode 100644 index eb1f481d7..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# v3.0 to v3.1 upgrade playbook - -## Overview -This playbook currently performs the -following steps. - - * Upgrade and restart master services - * Upgrade and restart node services - * Modifies the subset of the configuration necessary - * Applies the latest cluster policies - * Updates the default router if one exists - * Updates the default registry if one exists - * Updates image streams and quickstarts - -## Usage -ansible-playbook -i ~/ansible-inventory openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/README.md b/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/README.md deleted file mode 100644 index b230835c3..000000000 --- a/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# v3.1 minor upgrade playbook -This upgrade will preserve all locally made configuration modifications to the -Masters and Nodes. - -## Overview -This playbook is available as a technical preview. It currently performs the -following steps. - - * Upgrade and restart master services - * Upgrade and restart node services - * Applies the latest cluster policies - * Updates the default router if one exists - * Updates the default registry if one exists - * Updates image streams and quickstarts - -## Usage -ansible-playbook -i ~/ansible-inventory openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_1_minor/upgrade.yml -- cgit v1.2.3 From af2c6f8fee050173b846221371c34538f4dc8f79 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 13 Jul 2016 11:56:17 -0300 Subject: Add checks to docker role for 1.9.1+. If Docker 1.8.2 is pre-installed, and no docker_version was requested, role will now error out because 1.9.1 is required. If docker_version is set to <= 1.9.1, we also error out as this is not supported. --- roles/docker/tasks/main.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index ac065ea51..8b6ce7eae 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -4,10 +4,20 @@ - name: Get current installed Docker version command: "{{ repoquery_cmd }} --installed --qf '%{version}' docker" - when: docker_version is defined and not openshift.common.is_atomic | bool + when: not openshift.common.is_atomic | bool register: curr_docker_version changed_when: false +- name: Error out if Docker pre-installed but too old + fail: + msg: "Docker {{ curr_docker_version.stdout }} is installed, but >= 1.9.1 is required." + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.9.1', '<') and not docker_version is defined + +- name: Error out if requested Docker is too old + fail: + msg: "Docker {{ docker_version }} requested, but >= 1.9.1 is required." + when: docker_version is defined and docker_version | version_compare('1.9.1', '<') + - name: Get latest available version of Docker command: > {{ repoquery_cmd }} --qf '%{version}' "docker" @@ -21,14 +31,14 @@ - name: Fail if Docker version requested but downgrade is required fail: msg: "Docker {{ curr_docker_version.stdout }} is installed, but version {{ docker_version }} was requested." - when: not curr_docker_version | skipped and curr_docker_version.stdout | default('0.0', True) | version_compare(docker_version, '>') + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare(docker_version, '>') # This involves an extremely slow migration process, users should instead run the # Docker 1.10 upgrade playbook to accomplish this. - name: Error out if attempting to upgrade Docker across the 1.10 boundary fail: msg: "Cannot upgrade Docker to >= 1.10, please use the Docker upgrade playbook for this." - when: not curr_docker_version | skipped and curr_docker_version.stdout | default('0.0', True) | version_compare('1.10', '<') and docker_version | version_compare('1.10', '>=') + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.10', '<') and docker_version | version_compare('1.10', '>=') # Make sure Docker is installed, but does not update a running version. # Docker upgrades are handled by a separate playbook. -- cgit v1.2.3 From e1a032988800da90219af2944a1b34328ca6ae9e Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 13 Jul 2016 12:04:51 -0300 Subject: Fix more docker role logic. --- roles/docker/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 8b6ce7eae..545317890 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -31,14 +31,14 @@ - name: Fail if Docker version requested but downgrade is required fail: msg: "Docker {{ curr_docker_version.stdout }} is installed, but version {{ docker_version }} was requested." - when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare(docker_version, '>') + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and docker_version is defined and curr_docker_version.stdout | version_compare(docker_version, '>') # This involves an extremely slow migration process, users should instead run the # Docker 1.10 upgrade playbook to accomplish this. - name: Error out if attempting to upgrade Docker across the 1.10 boundary fail: msg: "Cannot upgrade Docker to >= 1.10, please use the Docker upgrade playbook for this." - when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.10', '<') and docker_version | version_compare('1.10', '>=') + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.10', '<') and docker_version is defined and docker_version | version_compare('1.10', '>=') # Make sure Docker is installed, but does not update a running version. # Docker upgrades are handled by a separate playbook. -- cgit v1.2.3 From 2a4f65ad4b19fc594851195b3180d1fe81853909 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 13 Jul 2016 14:18:09 -0300 Subject: pylint fixes --- roles/openshift_facts/library/openshift_facts.py | 53 ++++++++++++------------ utils/src/ooinstall/cli_installer.py | 19 ++++----- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index fdd3e8708..3de8faace 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -7,16 +7,6 @@ """Ansible module for retrieving and setting openshift related facts""" -DOCUMENTATION = ''' ---- -module: openshift_facts -short_description: Cluster Facts -author: Jason DeTiberus -requirements: [ ] -''' -EXAMPLES = ''' -''' - import ConfigParser import copy import io @@ -30,6 +20,17 @@ from dbus import SystemBus, Interface from dbus.exceptions import DBusException +DOCUMENTATION = ''' +--- +module: openshift_facts +short_description: Cluster Facts +author: Jason DeTiberus +requirements: [ ] +''' +EXAMPLES = ''' +''' + + def migrate_docker_facts(facts): """ Apply migrations for docker facts """ params = { @@ -499,10 +500,8 @@ def set_dnsmasq_facts_if_unset(facts): """ if 'common' in facts: - if 'use_dnsmasq' not in facts['common'] and safe_get_bool(facts['common']['version_gte_3_2_or_1_2']): - facts['common']['use_dnsmasq'] = True - else: - facts['common']['use_dnsmasq'] = False + facts['common']['use_dnsmasq'] = bool('use_dnsmasq' not in facts['common'] and + safe_get_bool(facts['common']['version_gte_3_2_or_1_2'])) if 'master' in facts and 'dns_port' not in facts['master']: if safe_get_bool(facts['common']['use_dnsmasq']): facts['master']['dns_port'] = 8053 @@ -1143,7 +1142,7 @@ def get_openshift_version(facts): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) elif 'common' in facts and 'is_containerized' in facts['common']: - version = get_containerized_openshift_version(facts) + version = get_container_openshift_version(facts) # Handle containerized masters that have not yet been configured as a node. # This can be very slow and may get re-run multiple times, so we only use this @@ -1155,15 +1154,18 @@ def get_openshift_version(facts): return version -def get_containerized_openshift_version(facts): - # If containerized, see if we can determine the installed version via the systemd environment files: +def get_container_openshift_version(facts): + """ + If containerized, see if we can determine the installed version via the + systemd environment files. + """ for filename in ['/etc/sysconfig/%s-master', '/etc/sysconfig/%s-node']: - env_file = filename % facts['common']['service_type'] - if not os.path.exists(env_file): + env_path = filename % facts['common']['service_type'] + if not os.path.exists(env_path): continue - with open(env_file) as f: - for line in f: + with open(env_path) as env_file: + for line in env_file: if line.startswith("IMAGE_VERSION="): tag = line[len("IMAGE_VERSION="):].strip() # Remove leading "v" and any trailing release info, we just want @@ -1218,7 +1220,7 @@ def apply_provider_facts(facts, provider_facts): # Disabling pylint too many branches. This function needs refactored # but is a very core part of openshift_facts. -# pylint: disable=too-many-branches +# pylint: disable=too-many-branches,too-many-nested-blocks def merge_facts(orig, new, additive_facts_to_overwrite, protected_facts_to_overwrite): """ Recursively merge facts dicts @@ -1766,10 +1768,7 @@ class OpenShiftFacts(object): if 'clock' in roles: exit_code, _, _ = module.run_command(['rpm', '-q', 'chrony']) - if exit_code == 0: - chrony_installed = True - else: - chrony_installed = False + chrony_installed = bool(exit_code == 0) defaults['clock'] = dict( enabled=True, chrony_installed=chrony_installed) @@ -2153,7 +2152,7 @@ def main(): ansible_facts=openshift_facts.facts) # ignore pylint errors related to the module_utils import -# pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import +# pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import, wrong-import-position # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.facts import * diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index cd74ed233..71734e792 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -1,17 +1,17 @@ # TODO: Temporarily disabled due to importing old code into openshift-ansible # repo. We will work on these over time. -# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,no-value-for-parameter +# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,no-value-for-parameter,too-many-lines -import click import os import re import sys +from distutils.version import LooseVersion +import click from ooinstall import openshift_ansible from ooinstall import OOConfig from ooinstall.oo_config import OOConfigInvalidHostError from ooinstall.oo_config import Host from ooinstall.variants import find_variant, get_variant_version_combos -from distutils.version import LooseVersion DEFAULT_ANSIBLE_CONFIG = '/usr/share/atomic-openshift-utils/ansible.cfg' DEFAULT_PLAYBOOK_DIR = '/usr/share/ansible/openshift-ansible/' @@ -32,7 +32,7 @@ def is_valid_hostname(hostname): return all(allowed.match(x) for x in hostname.split(".")) def validate_prompt_hostname(hostname): - if '' == hostname or is_valid_hostname(hostname): + if hostname == '' or is_valid_hostname(hostname): return hostname raise click.BadParameter('Invalid hostname. Please double-check this value and re-enter it.') @@ -60,6 +60,7 @@ def list_hosts(hosts): for idx in hosts_idx: click.echo(' {}: {}'.format(idx, hosts[idx])) +# pylint: disable=redefined-variable-type def delete_hosts(hosts): while True: list_hosts(hosts) @@ -146,10 +147,7 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen if rpm_or_container == 'container': host_props['containerized'] = True - if existing_env: - host_props['new_host'] = True - else: - host_props['new_host'] = False + host_props['new_host'] = existing_env host = Host(**host_props) @@ -377,7 +375,7 @@ Notes: default_facts_lines = [] default_facts = {} for h in hosts: - if h.preconfigured == True: + if h.preconfigured: continue try: default_facts[h.connect_to] = {} @@ -824,6 +822,7 @@ def uninstall(ctx): @click.option('--latest-minor', '-l', is_flag=True, default=False) @click.option('--next-major', '-n', is_flag=True, default=False) @click.pass_context +#pylint: disable=bad-builtin,too-many-statements def upgrade(ctx, latest_minor, next_major): oo_cfg = ctx.obj['oo_cfg'] verbose = ctx.obj['verbose'] @@ -883,7 +882,7 @@ def upgrade(ctx, latest_minor, next_major): if next_major: if 'major_playbook' not in mapping: click.echo("No major upgrade supported for %s %s with this version "\ - "of atomic-openshift-utils." % (variant, version)) + "of atomic-openshift-utils." % (variant, old_version)) sys.exit(0) playbook = mapping['major_playbook'] new_version = mapping['major_version'] -- cgit v1.2.3 From 6bfa3dee1efb32f20dcdcb4c7964ffd02969d1f1 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 13 Jul 2016 15:11:49 -0300 Subject: Remove too recent pylint option keys. --- roles/openshift_facts/library/openshift_facts.py | 4 ++-- utils/src/ooinstall/cli_installer.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 3de8faace..226d707dc 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1220,7 +1220,7 @@ def apply_provider_facts(facts, provider_facts): # Disabling pylint too many branches. This function needs refactored # but is a very core part of openshift_facts. -# pylint: disable=too-many-branches,too-many-nested-blocks +# pylint: disable=too-many-branches def merge_facts(orig, new, additive_facts_to_overwrite, protected_facts_to_overwrite): """ Recursively merge facts dicts @@ -2152,7 +2152,7 @@ def main(): ansible_facts=openshift_facts.facts) # ignore pylint errors related to the module_utils import -# pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import, wrong-import-position +# pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.facts import * diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 71734e792..5a66c3592 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -60,7 +60,6 @@ def list_hosts(hosts): for idx in hosts_idx: click.echo(' {}: {}'.format(idx, hosts[idx])) -# pylint: disable=redefined-variable-type def delete_hosts(hosts): while True: list_hosts(hosts) -- cgit v1.2.3 From 3073846a8c9e02af06d4d56f0141766b2337424b Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 14 Jul 2016 14:09:59 -0300 Subject: Fix upgrade with docker_version set. --- roles/docker/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 545317890..89a248d9e 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -11,7 +11,7 @@ - name: Error out if Docker pre-installed but too old fail: msg: "Docker {{ curr_docker_version.stdout }} is installed, but >= 1.9.1 is required." - when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.9.1', '<') and not docker_version is defined + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.9.1', '<') and not docker_version is defined and not docker_protect_installed_version | bool - name: Error out if requested Docker is too old fail: @@ -31,14 +31,14 @@ - name: Fail if Docker version requested but downgrade is required fail: msg: "Docker {{ curr_docker_version.stdout }} is installed, but version {{ docker_version }} was requested." - when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and docker_version is defined and curr_docker_version.stdout | version_compare(docker_version, '>') + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and docker_version is defined and curr_docker_version.stdout | version_compare(docker_version, '>') and not docker_protect_installed_version | bool # This involves an extremely slow migration process, users should instead run the # Docker 1.10 upgrade playbook to accomplish this. - name: Error out if attempting to upgrade Docker across the 1.10 boundary fail: msg: "Cannot upgrade Docker to >= 1.10, please use the Docker upgrade playbook for this." - when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.10', '<') and docker_version is defined and docker_version | version_compare('1.10', '>=') + when: not curr_docker_version | skipped and curr_docker_version.stdout != '' and curr_docker_version.stdout | version_compare('1.10', '<') and docker_version is defined and docker_version | version_compare('1.10', '>=') and not docker_protect_installed_version | bool # Make sure Docker is installed, but does not update a running version. # Docker upgrades are handled by a separate playbook. -- cgit v1.2.3