diff --git a/tripleo_ansible/roles/tripleo-transfer/README.md b/tripleo_ansible/roles/tripleo-transfer/README.md deleted file mode 100644 index 258c9e3b4..000000000 --- a/tripleo_ansible/roles/tripleo-transfer/README.md +++ /dev/null @@ -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) diff --git a/tripleo_ansible/roles/tripleo-transfer/defaults/main.yml b/tripleo_ansible/roles/tripleo-transfer/defaults/main.yml index 6b2e7df64..20886a49b 100644 --- a/tripleo_ansible/roles/tripleo-transfer/defaults/main.yml +++ b/tripleo_ansible/roles/tripleo-transfer/defaults/main.yml @@ -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: ~ diff --git a/tripleo_ansible/roles/tripleo-transfer/tasks/flag.yml b/tripleo_ansible/roles/tripleo-transfer/tasks/flag.yml new file mode 100644 index 000000000..c1ce261f3 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-transfer/tasks/flag.yml @@ -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 }}" diff --git a/tripleo_ansible/roles/tripleo-transfer/tasks/main.yml b/tripleo_ansible/roles/tripleo-transfer/tasks/main.yml index 0c98b038f..672023c57 100644 --- a/tripleo_ansible/roles/tripleo-transfer/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-transfer/tasks/main.yml @@ -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 }}"