1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/archive/tests/remove.yml
Felix Fontein 7c43cc3faa
Improve CI (#3348)
* Remove superfluous test.

* Use remote_temp_dir instead of output_dir on remote.

* Read certificate from correct place.

* Adjust more places.

* Fix boolean.

* Improve cryptography setup.

* Fix java_keystore changes.

* Need to copy binary from remote.

* Use correct Python for serve script.

* Sleep before downloading.

* Use correct Python interpreter.

* Avoid failing shebang test.

* Fix permission error with macOS 11.1.

* Avoid shebang trouble.
2021-09-09 07:31:44 +02:00

207 lines
6.5 KiB
YAML

---
- name: Archive - remove source files ({{ format }})
archive:
path: "{{ remote_tmp_dir }}/*.txt"
dest: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}"
format: "{{ format }}"
remove: yes
register: archive_remove_source_files
- name: Verify archive exists - remove source files ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}"
state: file
- name: Verify all files were archived - remove source files ({{ format }})
assert:
that:
- archive_remove_source_files is changed
- "{{ archive_remove_source_files.archived | length }} == 3"
- name: Remove Archive - remove source files ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}"
state: absent
- name: Assert that source files were removed - remove source files ({{ format }})
assert:
that:
- "'{{ remote_tmp_dir }}/{{ item }}' is not exists"
with_items:
- foo.txt
- bar.txt
- empty.txt
- name: Copy source files - remove source directory ({{ format }})
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/{{ item }}"
with_items:
- foo.txt
- bar.txt
- empty.txt
- name: Create temporary directory - remove source directory ({{ format }})
file:
path: "{{ remote_tmp_dir }}/tmpdir"
state: directory
- name: Copy source files to temporary directory - remove source directory ({{ format }})
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
with_items:
- foo.txt
- bar.txt
- empty.txt
- name: Archive - remove source directory ({{ format }})
archive:
path: "{{ remote_tmp_dir }}/tmpdir"
dest: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}"
format: "{{ format }}"
remove: yes
register: archive_remove_source_directory
- name: Verify archive exists - remove source directory ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}"
state: file
- name: Verify archive contains all files - remove source directory ({{ format }})
assert:
that:
- archive_remove_source_directory is changed
- "{{ archive_remove_source_directory.archived | length }} == 3"
- name: Remove archive - remove source directory ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}"
state: absent
- name: Verify source directory was removed - remove source directory ({{ format }})
assert:
that:
- "'{{ remote_tmp_dir }}/tmpdir' is not exists"
- name: Create temporary directory - remove source excluding path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/tmpdir"
state: directory
- name: Copy source files to temporary directory - remove source excluding path ({{ format }})
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
with_items:
- foo.txt
- bar.txt
- empty.txt
- name: Archive - remove source excluding path ({{ format }})
archive:
path: "{{ remote_tmp_dir }}/tmpdir/*"
dest: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}"
format: "{{ format }}"
remove: yes
exclude_path: "{{ remote_tmp_dir }}/tmpdir/empty.txt"
register: archive_remove_source_excluding_path
- name: Verify archive exists - remove source excluding path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}"
state: file
- name: Verify all files except excluded are archived - remove source excluding path ({{ format }})
assert:
that:
- archive_remove_source_excluding_path is changed
- "{{ archive_remove_source_excluding_path.archived | length }} == 2"
- name: Remove archive - remove source excluding path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}"
state: absent
- name: Verify that excluded file still exists - remove source excluding path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/tmpdir/empty.txt"
state: file
- name: Copy source files to temporary directory - remove source excluding sub path ({{ format }})
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
with_items:
- foo.txt
- bar.txt
- empty.txt
- sub
- sub/subfile.txt
- name: Archive - remove source excluding sub path ({{ format }})
archive:
path:
- "{{ remote_tmp_dir }}/tmpdir/*.txt"
- "{{ remote_tmp_dir }}/tmpdir/sub/*"
dest: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
format: "{{ format }}"
remove: yes
exclude_path: "{{ remote_tmp_dir }}/tmpdir/sub/subfile.txt"
register: archive_remove_source_excluding_sub_path
- name: Verify archive exists - remove source excluding sub path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
state: file
- name: Remove archive - remove source excluding sub path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
state: absent
- name: Verify that sub path still exists - remove source excluding sub path ({{ format }})
file:
path: "{{ remote_tmp_dir }}/tmpdir/sub/subfile.txt"
state: file
- name: Copy source files to temporary directory - remove source with nested paths ({{ format }})
copy:
src: "{{ item }}"
dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
with_items:
- foo.txt
- bar.txt
- empty.txt
- sub
- sub/subfile.txt
- name: Archive - remove source with nested paths ({{ format }})
archive:
path: "{{ remote_tmp_dir }}/tmpdir/"
dest: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}"
format: "{{ format }}"
remove: yes
register: archive_remove_nested_paths
- name: Verify archive exists - remove source with nested paths ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}"
state: file
- name: Verify source files were removed - remove source with nested paths ({{ format }})
file:
path: "{{ remote_tmp_dir }}/tmpdir"
state: absent
register: archive_remove_nested_paths_status
- name: Assert tasks status - remove source with nested paths ({{ format }})
assert:
that:
- archive_remove_nested_paths is success
- archive_remove_nested_paths_status is not changed
- name: Remove archive - remove source with nested paths ({{ format }})
file:
path: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}"
state: absent