Merge "Optional flag file for tripleo-transfer to prevent overwriting"
This commit is contained in:
commit
59356ff21c
|
@ -1,22 +0,0 @@
|
|||
tripleo-transfer
|
||||
================
|
||||
|
||||
An Ansible role to files from one overcloud node to another one.
|
||||
|
||||
Optional:
|
||||
|
||||
* `tripleo_transfer_storage_root_dir` -- directory on the Ansible host
|
||||
under which all data is temporarily stored
|
||||
(defaults to "/var/lib/mistral/tripleo-transfer")
|
||||
* `tripleo_transfer_storage_root_become` -- whether to use `become`
|
||||
when creating the storage root directory
|
||||
(defaults to false)
|
||||
* `tripleo_transfer_src_become` -- whether to use `become`
|
||||
on the source host
|
||||
(defaults to true)
|
||||
* `tripleo_transfer_dest_become` -- whether to use `become`
|
||||
on the destination host
|
||||
(defaults to true)
|
||||
* `tripleo_transfer_dest_wipe` -- whether to wipe the destination
|
||||
directory before transferring the content
|
||||
(defaults to true)
|
|
@ -29,3 +29,4 @@ tripleo_transfer_storage_root_become: false
|
|||
tripleo_transfer_src_become: true
|
||||
tripleo_transfer_dest_become: true
|
||||
tripleo_transfer_dest_wipe: true
|
||||
tripleo_transfer_flag_file: ~
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
# 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: check flag file existence in destination host
|
||||
stat:
|
||||
path: "{{ tripleo_transfer_flag_file }}"
|
||||
register: tripleo_transfer_flag_stat
|
||||
become: "{{ tripleo_transfer_dest_become }}"
|
||||
delegate_to: "{{ tripleo_transfer_dest_host }}"
|
||||
|
||||
- name: fail if flag file exists
|
||||
fail:
|
||||
msg: >
|
||||
Data transfer to '{{ tripleo_transfer_dest_dir }}' was prevented
|
||||
by flag file existence. This means the transfer was attempted
|
||||
before and another one would overwrite the data. If this is
|
||||
desired, remove the flag file at '{{ tripleo_transfer_flag_file }}'
|
||||
and re-run the data transfer.
|
||||
when:
|
||||
- tripleo_transfer_flag_stat.stat.exists
|
||||
delegate_to: "{{ tripleo_transfer_dest_host }}"
|
||||
|
||||
- name: ensure directory for flag file exists
|
||||
file:
|
||||
path: "{{ tripleo_transfer_flag_file|dirname }}"
|
||||
state: directory
|
||||
become: "{{ tripleo_transfer_dest_become }}"
|
||||
delegate_to: "{{ tripleo_transfer_dest_host }}"
|
||||
|
||||
- name: create the flag file
|
||||
file:
|
||||
path: "{{ tripleo_transfer_flag_file }}"
|
||||
state: touch
|
||||
become: "{{ tripleo_transfer_dest_become }}"
|
||||
delegate_to: "{{ tripleo_transfer_dest_host }}"
|
|
@ -70,6 +70,11 @@
|
|||
become: "{{ tripleo_transfer_src_become }}"
|
||||
delegate_to: "{{ tripleo_transfer_src_host }}"
|
||||
|
||||
- include_tasks: flag.yml
|
||||
when:
|
||||
- tripleo_transfer_flag_file != None
|
||||
- tripleo_transfer_flag_file|length > 0
|
||||
|
||||
- name: wipe the destination directory
|
||||
file:
|
||||
path: "{{ tripleo_transfer_dest_dir_safe }}"
|
||||
|
|
Loading…
Reference in New Issue