summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplaybooks/adhoc/upgrades/library/openshift_upgrade_config.py53
-rw-r--r--playbooks/adhoc/upgrades/upgrade.yml25
-rw-r--r--utils/src/ooinstall/install_transactions.py2
3 files changed, 67 insertions, 13 deletions
diff --git a/playbooks/adhoc/upgrades/library/openshift_upgrade_config.py b/playbooks/adhoc/upgrades/library/openshift_upgrade_config.py
index 157fbc5c2..f41c6fb59 100755
--- a/playbooks/adhoc/upgrades/library/openshift_upgrade_config.py
+++ b/playbooks/adhoc/upgrades/library/openshift_upgrade_config.py
@@ -2,6 +2,12 @@
# -*- coding: utf-8 -*-
# vim: expandtab:tabstop=4:shiftwidth=4
+import os
+import shutil
+import yaml
+
+from datetime import datetime
+
"""Ansible module for modifying OpenShift configs during an upgrade"""
DOCUMENTATION = '''
@@ -14,14 +20,53 @@ requirements: [ ]
EXAMPLES = '''
'''
+def get_cfg_dir():
+ cfg_path = '/etc/origin/'
+ if not os.path.exists(cfg_path):
+ cfg_path = '/etc/openshift/'
+ return cfg_path
+
def upgrade_master_3_0_to_3_1(backup):
- pass
+ changed = False
+
+ # Facts do not get transferred to the hosts where custom modules run,
+ # need to make some assumptions here.
+ master_config = os.path.join(get_cfg_dir(), 'master/master-config.yaml')
+
+ f = open(master_config, 'r')
+ config = yaml.safe_load(f.read())
+ f.close()
+
+ # Remove v1beta3 from apiLevels:
+ if 'apiLevels' in config and \
+ 'v1beta3' in config['apiLevels']:
+ config['apiLevels'].remove('v1beta3')
+ changed = True
+ if 'kubernetesMasterConfig' in config and \
+ 'apiLevels' in config['kubernetesMasterConfig'] and \
+ 'v1beta3' in config['kubernetesMasterConfig']['apiLevels']:
+ config['kubernetesMasterConfig']['apiLevels'].remove('v1beta3')
+ changed = True
+
+ if changed:
+ if backup:
+ timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
+ basedir = os.path.split(master_config)[0]
+ backup_file = os.path.join(basedir, 'master-config.yaml.bak-%s'
+ % timestamp)
+ shutil.copyfile(master_config, backup_file)
+ # Write the modified config:
+ out_file = open(master_config, 'w')
+ out_file.write(yaml.safe_dump(config, default_flow_style=False))
+ out_file.close()
+
+ return changed
def upgrade_master(from_version, to_version, backup):
if from_version == '3.0':
if to_version == '3.1':
- upgrade_master_3_0_to_3_1(backup)
+ return upgrade_master_3_0_to_3_1(backup)
def main():
@@ -41,15 +86,15 @@ def main():
supports_check_mode=True,
)
- changed = False
from_version = module.params['from_version']
to_version = module.params['to_version']
role = module.params['role']
backup = module.params['backup']
+ changed = False
if role == 'master':
- upgrade_master(from_version, to_version, backup)
+ changed = upgrade_master(from_version, to_version, backup)
return module.exit_json(changed=changed)
diff --git a/playbooks/adhoc/upgrades/upgrade.yml b/playbooks/adhoc/upgrades/upgrade.yml
index e55f1536f..6cb6803a9 100644
--- a/playbooks/adhoc/upgrades/upgrade.yml
+++ b/playbooks/adhoc/upgrades/upgrade.yml
@@ -40,6 +40,15 @@
- name: Generate etcd backup
command: etcdctl backup --data-dir={{ openshift.master.etcd_data_dir }} --backup-dir={{ openshift.common.data_dir }}/etcd-backup-{{ timestamp }}
+- name: Update 3.0 configuration to 3.1
+ hosts: masters
+ tasks:
+ tasks:
+ - debug: var=openshift_master_config_dir
+ - name: Upgrade configuration.
+ openshift_upgrade_config: from_version=3.0 to_version=3.1 role=master
+ - fail: All done for now.
+
- name: Upgrade base package on masters
hosts: masters
roles:
@@ -50,14 +59,14 @@
- name: Upgrade base package
yum: pkg={{ openshift.common.service_type }}{{ openshift_version }} state=latest
-- name: Re-Run cluster configuration to apply latest configuration changes
- include: ../../common/openshift-cluster/config.yml
- vars:
- g_etcd_group: "{{ 'etcd' }}"
- g_masters_group: "{{ 'masters' }}"
- g_nodes_group: "{{ 'nodes' }}"
- openshift_cluster_id: "{{ cluster_id | default('default') }}"
- openshift_deployment_type: "{{ deployment_type }}"
+ #- name: Re-Run cluster configuration to apply latest configuration changes
+ # include: ../../common/openshift-cluster/config.yml
+ # vars:
+ # g_etcd_group: "{{ 'etcd' }}"
+ # g_masters_group: "{{ 'masters' }}"
+ # g_nodes_group: "{{ 'nodes' }}"
+ # openshift_cluster_id: "{{ cluster_id | default('default') }}"
+ # openshift_deployment_type: "{{ deployment_type }}"
- name: Upgrade masters
hosts: masters
diff --git a/utils/src/ooinstall/install_transactions.py b/utils/src/ooinstall/install_transactions.py
index 0754b8ab6..e71bc183b 100644
--- a/utils/src/ooinstall/install_transactions.py
+++ b/utils/src/ooinstall/install_transactions.py
@@ -127,7 +127,7 @@ def run_main_playbook(hosts, hosts_to_run_on):
def run_ansible(playbook, inventory, env_vars):
- return subprocess.call(['ansible-playbook',
+ return subprocess.call(['ansible-playbook', '-v',
'--inventory-file={}'.format(inventory),
playbook],
env=env_vars)