diff --git a/roles/tripleo-persist/tasks/persist.yml b/roles/tripleo-persist/tasks/persist.yml index d53fa38fa..67f8ea8ba 100644 --- a/roles/tripleo-persist/tasks/persist.yml +++ b/roles/tripleo-persist/tasks/persist.yml @@ -13,17 +13,22 @@ prefix: ansible.tripleo-persist. register: tripleo_persist_tempfile +- name: make sure we don't have a trailing forward slash + set_fact: + tripleo_persist_dir_safe: "{{tripleo_persist_dir|regex_replace('\\/$', '')}}" + cacheable: no + # Using the "archive" module lists lists all tarred files in module # output, if there's too many files, it can crash ansible even with # "no_log: true". - name: create the archive shell: | - tar -czf "{{tripleo_persist_tempfile.path}}" -C "{{tripleo_persist_dir|dirname}}" "{{tripleo_persist_dir|basename}}" + tar -czf "{{tripleo_persist_tempfile.path}}" -C "{{tripleo_persist_dir_safe|dirname}}" "{{tripleo_persist_dir_safe|basename}}" - name: fetch the archive fetch: src: "{{tripleo_persist_tempfile.path}}" - dest: "{{tripleo_persist_storage_root_dir}}/{{inventory_hostname}}{{tripleo_persist_dir}}.tar.gz" + dest: "{{tripleo_persist_storage_root_dir}}/{{inventory_hostname}}{{tripleo_persist_dir_safe}}.tar.gz" flat: yes - name: remove tempfile diff --git a/roles/tripleo-persist/tasks/restore.yml b/roles/tripleo-persist/tasks/restore.yml index 156c7dc4b..6951154be 100644 --- a/roles/tripleo-persist/tasks/restore.yml +++ b/roles/tripleo-persist/tasks/restore.yml @@ -1,9 +1,14 @@ +- name: make sure we don't have a trailing forward slash + set_fact: + tripleo_persist_dir_safe: "{{tripleo_persist_dir|regex_replace('\\/$', '')}}" + cacheable: no + - name: make sure the parent directory is present file: - path: "{{tripleo_persist_dir|dirname}}" + path: "{{tripleo_persist_dir_safe|dirname}}" state: directory - name: push and extract the archive unarchive: - src: "{{tripleo_persist_storage_root_dir}}/{{inventory_hostname}}{{tripleo_persist_dir}}.tar.gz" - dest: "{{tripleo_persist_dir|dirname}}" + src: "{{tripleo_persist_storage_root_dir}}/{{inventory_hostname}}{{tripleo_persist_dir_safe}}.tar.gz" + dest: "{{tripleo_persist_dir_safe|dirname}}" diff --git a/roles/tripleo-transfer/tasks/main.yml b/roles/tripleo-transfer/tasks/main.yml index 4e8742a0e..d33329951 100644 --- a/roles/tripleo-transfer/tasks/main.yml +++ b/roles/tripleo-transfer/tasks/main.yml @@ -1,3 +1,13 @@ +- name: make sure we don't have a trailing forward slash in the src + set_fact: + tripleo_transfer_src_dir_safe: "{{tripleo_transfer_src_dir|regex_replace('\\/$', '')}}" + cacheable: no + +- name: make sure we don't have a trailing forward slash in the dst + set_fact: + tripleo_transfer_dest_dir_safe: "{{tripleo_transfer_dest_dir|regex_replace('\\/$', '')}}" + cacheable: no + - name: ensure local storage directory exists and has correct permissions file: path: "{{tripleo_transfer_storage_root_dir}}" @@ -20,14 +30,14 @@ # "no_log: true". - name: create the archive shell: | - tar --transform "s|^{{tripleo_transfer_src_dir|basename}}|{{tripleo_transfer_dest_dir|basename}}|" -czf "{{tripleo_transfer_tempfile.path}}" -C "{{tripleo_transfer_src_dir|dirname}}" "{{tripleo_transfer_src_dir|basename}}" + tar --transform "s|^{{tripleo_transfer_src_dir_safe|basename}}|{{tripleo_transfer_dest_dir_safe|basename}}|" -czf "{{tripleo_transfer_tempfile.path}}" -C "{{tripleo_transfer_src_dir_safe|dirname}}" "{{tripleo_transfer_src_dir_safe|basename}}" become: "{{tripleo_transfer_src_become}}" delegate_to: "{{tripleo_transfer_src_host}}" - name: fetch the archive fetch: src: "{{tripleo_transfer_tempfile.path}}" - dest: "{{tripleo_transfer_storage_root_dir}}/{{tripleo_transfer_dest_host}}{{tripleo_transfer_dest_dir}}.tar.gz" + dest: "{{tripleo_transfer_storage_root_dir}}/{{tripleo_transfer_dest_host}}{{tripleo_transfer_dest_dir_safe}}.tar.gz" flat: yes become: "{{tripleo_transfer_src_become}}" delegate_to: "{{tripleo_transfer_src_host}}" @@ -41,7 +51,7 @@ - name: wipe the destination directory file: - path: "{{tripleo_transfer_dest_dir}}" + path: "{{tripleo_transfer_dest_dir_safe}}" state: absent become: "{{tripleo_transfer_dest_become}}" delegate_to: "{{tripleo_transfer_dest_host}}" @@ -49,19 +59,19 @@ - name: make sure the destination parent directory is present file: - path: "{{tripleo_transfer_dest_dir|dirname}}" + path: "{{tripleo_transfer_dest_dir_safe|dirname}}" state: directory become: "{{tripleo_transfer_dest_become}}" delegate_to: "{{tripleo_transfer_dest_host}}" - name: push and extract the archive unarchive: - src: "{{tripleo_transfer_storage_root_dir}}/{{tripleo_transfer_dest_host}}{{tripleo_transfer_dest_dir}}.tar.gz" - dest: "{{tripleo_transfer_dest_dir|dirname}}" + src: "{{tripleo_transfer_storage_root_dir}}/{{tripleo_transfer_dest_host}}{{tripleo_transfer_dest_dir_safe}}.tar.gz" + dest: "{{tripleo_transfer_dest_dir_safe|dirname}}" become: "{{tripleo_transfer_dest_become}}" delegate_to: "{{tripleo_transfer_dest_host}}" - name: remove the local archive file: - path: "{{tripleo_transfer_storage_root_dir}}/{{tripleo_transfer_dest_host}}{{tripleo_transfer_dest_dir}}.tar.gz" + path: "{{tripleo_transfer_storage_root_dir}}/{{tripleo_transfer_dest_host}}{{tripleo_transfer_dest_dir_safe}}.tar.gz" state: absent