a7f54163cf
If a host is unreachable, the default behaviour for ansible is to ignore that and execute all the tasks in the hosts that are reachable. This is unwanted behaviour for B&R, as we need the whole controller cluster to be healthy and reachable before we take a backup from it. This patch introduces a mechanism to abort execution if there is one or more unreachable hosts. Change-Id: I3820875e72a8d805d71c7981468398bbcec0bf04
65 lines
2.2 KiB
YAML
65 lines
2.2 KiB
YAML
---
|
|
# Copyright 2020 Red Hat, Inc.
|
|
#
|
|
# 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.
|
|
|
|
- name: Stop executing if one of the hosts is unreachable
|
|
hosts: '{{ tripleo_controller_group_name }}'
|
|
become: true
|
|
vars_files:
|
|
../roles/backup_and_restore/defaults/main.yml
|
|
tasks:
|
|
- name: Check ALL hosts are reacheable
|
|
fail:
|
|
msg: >
|
|
[REQUIRED] ALL hosts to be reachable, so flagging {{ inventory_hostname }} as failed,
|
|
because host {{ item }} has no facts, meaning it is UNREACHABLE.
|
|
when: "hostvars[item].ansible_facts|list|length == 0"
|
|
with_items: "{{ groups[tripleo_controller_group_name] }}"
|
|
run_once: true
|
|
|
|
- name: Backup ceph authentication
|
|
hosts: ceph_mon
|
|
become: true
|
|
tasks:
|
|
- name: Backup ceph authentication role
|
|
include_role:
|
|
name: backup_and_restore
|
|
tasks_from: ceph_authentication
|
|
tags:
|
|
- bar_create_recover_image
|
|
|
|
- name: Check Controller group
|
|
hosts: localhost
|
|
vars_files:
|
|
../roles/backup_and_restore/defaults/main.yml
|
|
tasks:
|
|
- assert:
|
|
that:
|
|
- item in groups
|
|
- ( groups[item] | length ) > 0
|
|
fail_msg: "There is no server on {{ item }} groups"
|
|
with_items: "{{ tripleo_controller_group_name }}"
|
|
tags:
|
|
- bar_create_recover_image
|
|
|
|
- name: TripleO Controller backup
|
|
hosts: '{{ tripleo_controller_group_name }}'
|
|
remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
|
|
serial: "{{ (tripleo_controller_group_name|length > 1) or (tripleo_backup_and_restore_enable_snapshots|bool) | ternary(1, groups[tripleo_controller_group_name]|length) }}"
|
|
vars_files:
|
|
../roles/backup_and_restore/defaults/main.yml
|
|
become: true
|
|
roles:
|
|
- role: backup_and_restore
|