Browse Source

Merge pull request #1862 from abutcher/v2-vars-files-upgrade

Remove vars_files on play includes for upgrade playbooks.
Jason DeTiberus 9 years ago
parent
commit
891e38c6e0

+ 22 - 7
playbooks/byo/openshift-cluster/upgrades/v3_0_minor/upgrade.yml

@@ -1,13 +1,28 @@
 ---
+- 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_files:
-  - "{{lookup('file', '../../../../byo/openshift-cluster/cluster_hosts.yml')}}"
   vars:
-    g_etcd_hosts: "{{ groups.etcd | default([]) }}"
-    g_master_hosts: "{{ groups.masters | default([]) }}"
+    # Do not allow adding hosts during upgrade.
     g_new_master_hosts: []
-    g_nfs_hosts: "{{ groups.nfs | default([]) }}"
-    g_node_hosts: "{{ groups.nodes | default([]) }}"
-    g_lb_hosts: "{{ groups.lb | default([]) }}"
+    g_new_node_hosts: []
     openshift_cluster_id: "{{ cluster_id | default('default') }}"
     openshift_deployment_type: "{{ deployment_type }}"

+ 22 - 7
playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml

@@ -1,13 +1,28 @@
 ---
+- 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_files:
-  - "{{lookup('file', '../../../../byo/openshift-cluster/cluster_hosts.yml')}}"
   vars:
-    g_etcd_hosts: "{{ groups.etcd | default([]) }}"
-    g_master_hosts: "{{ groups.masters | default([]) }}"
+    # Do not allow adding hosts during upgrade.
     g_new_master_hosts: []
-    g_nfs_hosts: "{{ groups.nfs | default([]) }}"
-    g_node_hosts: "{{ groups.nodes | default([]) }}"
-    g_lb_hosts: "{{ groups.lb | default([]) }}"
+    g_new_node_hosts: []
     openshift_cluster_id: "{{ cluster_id | default('default') }}"
     openshift_deployment_type: "{{ deployment_type }}"

+ 22 - 5
playbooks/byo/openshift-cluster/upgrades/v3_1_minor/upgrade.yml

@@ -1,12 +1,29 @@
 ---
+- 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:
-    g_etcd_hosts: "{{ groups.etcd | default([]) }}"
-    g_master_hosts: "{{ groups.masters | default([]) }}"
+    # Do not allow adding hosts during upgrade.
     g_new_master_hosts: []
-    g_nfs_hosts: "{{ groups.nfs | default([]) }}"
-    g_node_hosts: "{{ groups.nodes | default([]) }}"
-    g_lb_hosts: "{{ groups.lb | default([]) }}"
+    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

+ 22 - 7
playbooks/byo/openshift-cluster/upgrades/v3_1_to_v3_2/upgrade.yml

@@ -1,14 +1,29 @@
 ---
+- 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 | 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:
-    g_etcd_hosts: "{{ groups.etcd | default([]) }}"
-    g_master_hosts: "{{ groups.masters | default([]) }}"
+    # Do not allow adding hosts during upgrade.
     g_new_master_hosts: []
-    g_nfs_hosts: "{{ groups.nfs | default([]) }}"
-    g_node_hosts: "{{ groups.nodes | default([]) }}"
-    g_lb_hosts: "{{ groups.lb | default([]) }}"
-    g_all_hosts: "{{ groups.masters | default([]) | union(groups.nodes | default([])) | union(groups.etcd | default([]))
-                    | union(groups.lb | default([])) | union(groups.nfs | default([])) }}"
+    g_new_node_hosts: []
     openshift_cluster_id: "{{ cluster_id | default('default') }}"
     openshift_deployment_type: "{{ deployment_type }}"
 

+ 2 - 1
playbooks/common/openshift-cluster/upgrades/v3_0_minor/upgrade.yml

@@ -36,7 +36,8 @@
 - name: Ensure AOS 3.0.2 or Origin 1.0.6
   hosts: oo_first_master
   tasks:
-    fail: This playbook requires Origin 1.0.6 or Atomic OpenShift 3.0.2 or later
+  - 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

+ 1 - 0
playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/atomic-openshift-master.j2

@@ -0,0 +1 @@
+../../../../../roles/openshift_master/templates/atomic-openshift-master.j2

+ 1 - 0
playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/docker

@@ -0,0 +1 @@
+../../../../../roles/openshift_master/templates/docker

+ 1 - 0
playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/docker-cluster

@@ -0,0 +1 @@
+../../../../../roles/openshift_master/templates/docker-cluster

+ 1 - 0
playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/native-cluster

@@ -0,0 +1 @@
+../../../../../roles/openshift_master/templates/native-cluster

+ 4 - 4
roles/openshift_facts/library/openshift_facts.py

@@ -19,8 +19,8 @@ EXAMPLES = '''
 
 import ConfigParser
 import copy
+import io
 import os
-import StringIO
 import yaml
 from distutils.util import strtobool
 from distutils.version import LooseVersion
@@ -689,7 +689,7 @@ def set_etcd_facts_if_unset(facts):
 
     If anything goes wrong parsing these, the fact will not be set.
     """
-    if 'master' in facts and facts['master']['embedded_etcd']:
+    if 'master' in facts and safe_get_bool(facts['master']['embedded_etcd']):
         etcd_facts = facts['etcd'] if 'etcd' in facts else dict()
 
         if 'etcd_data_dir' not in etcd_facts:
@@ -716,8 +716,8 @@ def set_etcd_facts_if_unset(facts):
         # Read ETCD_DATA_DIR from /etc/etcd/etcd.conf:
         try:
             # Add a fake section for parsing:
-            ini_str = '[root]\n' + open('/etc/etcd/etcd.conf', 'r').read()
-            ini_fp = StringIO.StringIO(ini_str)
+            ini_str = unicode('[root]\n' + open('/etc/etcd/etcd.conf', 'r').read(), 'utf-8')
+            ini_fp = io.StringIO(ini_str)
             config = ConfigParser.RawConfigParser()
             config.readfp(ini_fp)
             etcd_data_dir = config.get('root', 'ETCD_DATA_DIR')