Merge "BnR: managed ceph properly to take a backup of the node" into stable/train

This commit is contained in:
Zuul 2021-08-31 17:14:44 +00:00 committed by Gerrit Code Review
commit ff4a479d75
8 changed files with 221 additions and 9 deletions

View File

@ -44,7 +44,7 @@ tripleo_backup_and_restore_nfs_clients_nets: ['192.168.24.0/24', '10.0.0.0/24',
tripleo_backup_and_restore_rear_simulate: false
tripleo_backup_and_restore_using_uefi_bootloader: 0
tripleo_backup_and_restore_exclude_paths_common: ['/data/*', '/tmp/*', '{{ tripleo_backup_and_restore_nfs_storage_folder }}/*']
tripleo_backup_and_restore_exclude_paths_controller_non_bootrapnode: true
tripleo_backup_and_restore_exclude_paths_controller_non_bootstrapnode: false
tripleo_backup_and_restore_exclude_paths_controller: ['/var/lib/mysql/*']
tripleo_backup_and_restore_exclude_paths_compute: ['/var/lib/nova/instances/*']
tripleo_backup_and_restore_hiera_config_file: "/etc/puppet/hiera.yaml"
@ -99,3 +99,9 @@ tripleo_backup_and_restore_cron_user: "stack"
# Any extra parameters that will be added to the backup command when it is executed by cron
tripleo_backup_and_restore_cron_extra: ""
# The role which handles the ceph on the controllers
tripleo_backup_and_restore_ceph_mon_role: "ceph_mon"
# The cephadm path
tripleo_backup_and_restore_cephadm_path: "/usr/sbin/cephadm"

View File

@ -77,7 +77,7 @@
- "{{ (tripleo_backup_and_restore_bootstrap_nodeid.stdout != tripleo_backup_and_restore_hostname.stdout and
tripleo_backup_and_restore_enabled_services.stdout is search('pacemaker') and
tripleo_backup_and_restore_enabled_services.stdout is search('mysql') and
tripleo_backup_and_restore_exclude_paths_controller_non_bootrapnode|bool) |
tripleo_backup_and_restore_exclude_paths_controller_non_bootstrapnode|bool) |
ternary(tripleo_backup_and_restore_exclude_paths_controller, []) }}"
tags:
- bar_setup_rear

View File

@ -0,0 +1,53 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Ceph installed with ceph ansible
tags: bar_create_recover_image
when:
- cephadm_ls.stdout is not defined or cephadm_ls.stdout == "[]"
block:
- name: Set ceph monitor {{ ceph_systemd_state }}
systemd:
state: "{{ ceph_systemd_state }}"
name: "ceph-mon@{{ inventory_hostname }}"
- name: Set ceph management {{ ceph_systemd_state }}
systemd:
state: "{{ ceph_systemd_state }}"
name: "ceph-mgr@{{ inventory_hostname }}"
- name: Get the node names of the mds nodes
command: hiera -c '{{ tripleo_backup_and_restore_hiera_config_file }}' 'ceph_mds_short_node_names'
register: bar_ceph_mds_nodes
- name: Set ceph mds {{ ceph_systemd_state }}
systemd:
state: "{{ ceph_systemd_state }}"
name: "ceph-mds@{{ inventory_hostname }}"
when:
- bar_ceph_mds_nodes.stdout != "nil"
- inventory_hostname in bar_ceph_mds_nodes.stdout
- name: Get the node names of the rgw nodes
command: hiera -c '{{ tripleo_backup_and_restore_hiera_config_file }}' 'ceph_rgw_short_node_names'
register: bar_ceph_rgw_nodes
- name: Set ceph rgw {{ ceph_systemd_state }}
command: systemctl start "ceph-radosgw@rgw.{{ inventory_hostname }}.*"
when:
- bar_ceph_rgw_nodes != "nil"
- inventory_hostname in bar_ceph_rgw_nodes.stdout

View File

@ -32,15 +32,50 @@
tags:
- always
- name: Ensure cephmon container is running
command: "{{ tripleo_container_cli }} unpause ceph-mon-{{ ansible_facts['hostname'] }}"
failed_when: false
- name: Stat cephadm file
stat:
path: "{{ tripleo_backup_and_restore_cephadm_path }}"
register: stat_cephadm
become: true
ignore_errors: true
tags:
- bar_create_recover_image
- name: Export ceph authentication
shell: |
set -o pipefail
{{ tripleo_container_cli }} exec ceph-mon-{{ ansible_facts['hostname'] }} bash -c "ceph auth export" > {{ tripleo_backup_and_restore_ceph_auth_file }}
- name: List Ceph daemon instances on this host
shell: "{{ tripleo_backup_and_restore_cephadm_path }} ls --no-detail"
register: cephadm_ls
become: true
when: stat_cephadm.stat.exists
tags:
- bar_create_recover_image
- name: Ceph installed with ceph ansible
when:
- cephadm_ls.stdout is not defined or cephadm_ls.stdout == "[]"
tags: bar_create_recover_image
block:
- name: Ensure cephmon container is running
command: "{{ tripleo_container_cli }} unpause ceph-mon-{{ inventory_hostname }}"
failed_when: false
- name: Export ceph authentication
shell: |
set -o pipefail
{{ tripleo_container_cli }} exec ceph-mon-{{ inventory_hostname }} bash -c "ceph auth export"
register: bar_ceph_authentication_content
- name: Ceph installed with cephadm
when:
- cephadm_ls.stdout is defined
- cephadm_ls.stdout != '[]'
tags: bar_create_recover_image
block:
- name: Export ceph authentication
command: cephadm shell -- ceph auth export
register: bar_ceph_authentication_content
- name: Save ceph authentication at {{ tripleo_backup_and_restore_ceph_auth_file }}
copy:
dest: "{{ tripleo_backup_and_restore_ceph_auth_file }}"
content: |
{{ bar_ceph_authentication_content.stdout }}

View File

@ -0,0 +1,36 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Stat cephadm file
import_tasks: cephadm_stat.yml
- name: Start ceph with ceph-ansible
import_tasks: ceph.yml
vars:
ceph_systemd_state: started
- name: Ceph installed with cephadm
when:
- cephadm_ls.stdout is defined
- cephadm_ls.stdout != "[]"
tags: bar_create_recover_image
block:
- name: Start ceph
systemd:
state: started
name: "ceph.target"
become: true

View File

@ -0,0 +1,38 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Stat cephadm file
import_tasks: cephadm_stat.yml
- name: Stop ceph with ceph-ansible
import_tasks: ceph.yml
vars:
ceph_systemd_state: stopped
- name: Ceph installed with cephadm
when:
- cephadm_ls.stdout is defined
- cephadm_ls.stdout != "[]"
tags: bar_create_recover_image
block:
- name: Stop ceph\*.service
command: systemctl stop ceph\*.service
become: true
- name: Stop ceph\*.target
command: systemctl stop ceph\*.target
become: true

View File

@ -0,0 +1,32 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Stat cephadm file
stat:
path: "{{ tripleo_backup_and_restore_cephadm_path }}"
register: stat_cephadm
become: true
ignore_errors: true
tags:
- bar_create_recover_image
- name: List Ceph daemon instances on this host
shell: "{{ tripleo_backup_and_restore_cephadm_path }} ls --no-detail"
register: cephadm_ls
become: true
when: stat_cephadm.stat.exists
tags:
- bar_create_recover_image

View File

@ -52,6 +52,12 @@
- name: Perform backup
block:
- name: Stop ceph services
import_tasks: ceph_stop.yml
when:
- tripleo_backup_and_restore_ceph_mon_role in groups
- inventory_hostname in groups[tripleo_backup_and_restore_ceph_mon_role]
- name: Create recovery images with ReaR
import_tasks: ../backup/tasks/main.yml
always:
@ -66,3 +72,9 @@
when:
- pacemaker_enabled
- tripleo_backup_and_restore_enable_snapshots|bool
- name: Start ceph services
import_tasks: ceph_start.yml
when:
- tripleo_backup_and_restore_ceph_mon_role in groups
- inventory_hostname in groups[tripleo_backup_and_restore_ceph_mon_role]