tripleo-ansible/playbooks/update_cloud.yml
Clint Byrum 41a43feb43 Only attempt service_facts on active instances
SSH fails otherwise.

Change-Id: I3e29ab21e6a3ca383a7df8b162804222e35e9b0a
2014-08-28 16:15:25 -07:00

246 lines
10 KiB
YAML

# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- hosts: all
gather_facts: no
tasks:
- include: disable_os_collect_config.yml
when: instance_status == "ACTIVE"
- hosts: undercloud
name: Disable Undercloud
sudo: yes
gather_facts: no
tasks:
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=no state=stopped
with_items: helion_undercloud_services
when: helion is defined and instance_status == "ACTIVE" and item in existing_services
- service: name={{ item }} enabled=no state=stopped
with_items: undercloud_services
when: helion is not defined and instance_status == "ACTIVE" and item in existing_services
- hosts: nova-compute
name: Disable Overcloud Compute
sudo: yes
gather_facts: no
tasks:
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=no state=stopped
with_items: helion_overcloud_compute_services
when: helion is defined and instance_status == "ACTIVE" and item in existing_services
- service: name={{ item }} enabled=no state=stopped
with_items: overcloud_compute_services
when: helion is not defined and instance_status == "ACTIVE" and item in existing_services
- hosts: swift-storage
name: swift-storage
sudo: yes
gather_facts: no
tasks:
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=no state=stopped
with_items: helion_overcloud_swift_services
when: helion is defined and instance_status == "ACTIVE" and item in existing_services
- service: name={{ item }} enabled=no state=stopped
with_items: overcloud_swift_services
when: helion is not defined and instance_status == "ACTIVE" and item in existing_services
- hosts: controller
name: Disable Overcloud Controller
sudo: yes
gather_facts: no
tasks:
- service_facts:
- service: name={{ item }} enabled=no state=stopped
with_items: helion_overcloud_controller_services
when: helion is defined and instance_status == "ACTIVE" and item in existing_services
- service: name={{ item }} enabled=no state=stopped
with_items: overcloud_controller_services
when: helion is not defined and instance_status == "ACTIVE" and item in existing_services
- hosts: controllermgmt
name: Disable Overcloud Controller Mgmt node
sudo: yes
gather_facts: no
tasks:
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=no state=stopped
with_items: helion_overcloudmgmt_controller_services
when: helion is defined and instance_status == "ACTIVE" and item in existing_services
# Critically, we need to select a single node of the galera cluster to
# be the 'last'. So controllermgmt fits that bill for now. We will have
# to select one to be the "special" node eventually, we can do that with
# host facts and conditionals. The last to go down must have the
# Galera bootstrap run on it, or none of them will come up.
- hosts: controller
name: Stop MySQL on controller nodes
sudo: yes
gather_facts: no
tasks:
- include: galera_status.yml
when: instance_status == "ACTIVE"
- service: name=mysql enabled=no state=stopped
when: instance_status == "ACTIVE" and galera_status == 'Synced'
- fail: msg="Galera Replication is out of sync - cannot safely proceed"
when: instance_status == "ACTIVE" and galera_status != 'Synced'
- hosts: controllermgmt
name: Stop MySQL on Overcloud Controller Mgmt node
sudo: yes
gather_facts: no
tasks:
- include: galera_status.yml
when: instance_status == "ACTIVE"
- fail: msg="Galera Replication is out of sync - cannot safely proceed"
when: galera_status == 'Out of Sync' and instance_status == "ACTIVE"
- service: name=mysql enabled=no state=stopped
when: instance_status == "ACTIVE"
- hosts: undercloud
name: Rebuild and Refresh Undercloud
gather_facts: no
tasks:
- include: preserve_ssh_host_keys.yml
when: instance_status == "ACTIVE"
- include: cleanup_cinder_volumes.yml
when: instance_status == "ACTIVE"
- include: remount-ro.yml
when: instance_status == "ACTIVE"
- { include: rebuild.yml, instance_id: "{{ instance_id }}", rebuild_image_id: "{{ undercloud_rebuild_image_id }}", when: instance_status != "REBUILD" }
- local_action: wait_for port=22 timeout=600 host="{{ inventory_hostname }}" search_regex=OpenSSH delay=10
- include: refresh_config.yml
- hosts: undercloud
name: Enable Undercloud
sudo: yes
tasks:
- include: disable_os_collect_config.yml
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=yes state=started
with_items: helion_undercloud_services
when: helion is defined and item in existing_services
- service: name={{ item }} enabled=yes state=started
with_items: undercloud_services
when: helion is not defined and item in existing_services
- hosts: controllermgmt
name: Rebuild and Refresh ControllerMgmt
gather_facts: no
tasks:
- include: preserve_ssh_host_keys.yml
when: instance_status == "ACTIVE"
- include: cleanup_cinder_volumes.yml
when: instance_status == "ACTIVE"
- { include: rebuild.yml, instance_id: "{{ instance_id }}", rebuild_image_id: "{{ controllermgmt_rebuild_image_id }}", when: instance_status != "REBUILD" }
- local_action: wait_for port=22 timeout=600 host="{{ inventory_hostname }}" search_regex=OpenSSH delay=10
- hosts: controllermgmt
name: Start initial Galera cluster node
tasks:
- command: /etc/init.d/mysql bootstrap-pxc
- service: name=mysql enabled=yes state=started
- hosts: controller
name: Rebuild and Refresh Controller
gather_facts: no
tasks:
- include: preserve_ssh_host_keys.yml
when: instance_status == "ACTIVE"
- include: cleanup_cinder_volumes.yml
when: instance_status == "ACTIVE"
- { include: rebuild.yml, instance_id: "{{ instance_id }}", rebuild_image_id: "{{ controller_rebuild_image_id }}", when: instance_status != "REBUILD" }
- local_action: wait_for port=22 timeout=600 host="{{ inventory_hostname }}" search_regex=OpenSSH delay=10
- hosts: controller:controllermgmt
name: Re-Refresh Controller
tasks:
- include: refresh_config.yml
- name: Disable os-collect-config on control nodes.
include: disable_os_collect_config.yml
- name: "Work around apache2 starting up at boot w/o config..."
sudo: yes
service: name=apache2 enabled=no state=stopped
- name: "Run os-collect-config"
sudo: yes
command: os-collect-config --force --one
- name: Re-run os-collect-config in case first one failed due to a race condition
sudo: yes
command: os-collect-config --noforce --one
- hosts: controllermgmt
name: Enable Overcloud ControllerMgmt
sudo: yes
tasks:
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=yes state=started
with_items: helion_overcloudmgmt_controller_service
when: helion is defined and item in existing_services
- hosts: controller
name: Enable Overcloud Controller
sudo: yes
tasks:
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=yes state=started
with_items: helion_overcloud_controller_services
when: helion is defined and item in existing_services
- service: name={{ item }} enabled=yes state=started
with_items: overcloud_controller_services
when: helion is not defined and item in existing_servies
- hosts: swift-storage
name: Rebuild and Refresh swift-storage
gather_facts: no
tasks:
- include: preserve_ssh_host_keys.yml
when: instance_status == "ACTIVE"
- { include: rebuild.yml, instance_id: "{{ instance_id }}", rebuild_image_id: "{{ swift_storage_rebuild_image_id }}", when: instance_status != "REBUILD" }
- local_action: wait_for port=22 timeout=600 host="{{ inventory_hostname }}" search_regex=OpenSSH delay=10
- include: refresh_config.yml
- hosts: swift-storage
name: Enable Swift Storage
sudo: yes
tasks:
- include: disable_os_collect_config.yml
- name: "Run os-collect-config"
sudo: yes
command: os-collect-config --force --one
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=yes state=started
with_items: helion_overcloud_swift_services
when: helion is defined and item in existing_services
- service: name={{ item }} enabled=yes state=started
with_items: overcloud_swift_services
when: helion is not defined and item in existing_servies
- hosts: nova-compute
name: Rebuild and Refresh Nova Compute
gather_facts: no
tasks:
- include: preserve_ssh_host_keys.yml
when: instance_status == "ACTIVE"
- { include: rebuild.yml, instance_id: "{{ instance_id }}", rebuild_image_id: "{{ nova_compute_rebuild_image_id }}", when: instance_status != "REBUILD" }
- local_action: wait_for port=22 timeout=600 host="{{ inventory_hostname }}" search_regex=OpenSSH delay=10
- include: refresh_config.yml
- hosts: nova-compute
name: Enable Overcloud Compute
sudo: yes
tasks:
- include: disable_os_collect_config.yml
- name: "Run os-collect-config"
sudo: yes
command: os-collect-config --force --one
- service_facts:
when: instance_status == "ACTIVE"
- service: name={{ item }} enabled=yes state=started
with_items: helion_overcloud_compute_services
when: helion is defined and item in existing_services
- service: name={{ item }} enabled=yes state=started
with_items: overcloud_compute_services
when: helion is not defined and item in existing_services