2020-01-31 03:59:46 +01:00
|
|
|
---
|
|
|
|
- name: create test directory
|
|
|
|
win_file:
|
|
|
|
path: '{{ win_unzip_dir }}\output'
|
|
|
|
state: directory
|
2017-07-19 01:54:57 +02:00
|
|
|
|
2020-01-31 03:59:46 +01:00
|
|
|
- name: create local zip file with non-ascii chars
|
|
|
|
script: create_zip.py {{ output_dir + '/win_unzip.zip' | quote }}
|
|
|
|
delegate_to: localhost
|
2017-07-19 01:54:57 +02:00
|
|
|
|
2020-01-31 03:59:46 +01:00
|
|
|
- name: copy across zip to Windows host
|
|
|
|
win_copy:
|
|
|
|
src: '{{ output_dir }}/win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\win_unzip.zip'
|
2017-07-19 01:54:57 +02:00
|
|
|
|
2020-01-31 03:59:46 +01:00
|
|
|
- name: unarchive zip (check)
|
|
|
|
win_unzip:
|
|
|
|
src: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\output'
|
|
|
|
register: unzip_check
|
2017-07-19 01:54:57 +02:00
|
|
|
check_mode: yes
|
2020-01-31 03:59:46 +01:00
|
|
|
|
|
|
|
- name: get result of unarchive zip (check)
|
|
|
|
win_stat:
|
|
|
|
path: '{{ win_unzip_dir }}\output\café.txt'
|
|
|
|
register: unzip_actual_check
|
|
|
|
|
|
|
|
- name: assert result of unarchive zip (check)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- unzip_check is changed
|
|
|
|
- not unzip_check.removed
|
|
|
|
- not unzip_actual_check.stat.exists
|
|
|
|
|
|
|
|
- name: unarchive zip
|
|
|
|
win_unzip:
|
|
|
|
src: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\output'
|
|
|
|
register: unzip
|
|
|
|
|
|
|
|
- name: get result of unarchive zip
|
|
|
|
slurp:
|
|
|
|
path: '{{ win_unzip_dir }}\output\café.txt'
|
|
|
|
register: unzip_actual
|
|
|
|
|
|
|
|
- name: assert result of unarchive zip
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- unzip is changed
|
|
|
|
- not unzip.removed
|
|
|
|
- unzip_actual.content | b64decode == 'café.txt'
|
|
|
|
|
|
|
|
# Module is not idempotent, will always change without creates
|
|
|
|
- name: unarchive zip again without creates
|
|
|
|
win_unzip:
|
|
|
|
src: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\output'
|
|
|
|
register: unzip_again
|
|
|
|
|
|
|
|
- name: assert unarchive zip again without creates
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- unzip_again is changed
|
|
|
|
- not unzip_again.removed
|
|
|
|
|
|
|
|
- name: unarchive zip with creates
|
|
|
|
win_unzip:
|
|
|
|
src: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\outout'
|
|
|
|
creates: '{{ win_unzip_dir }}\output\café.txt'
|
|
|
|
register: unzip_again_creates
|
|
|
|
|
|
|
|
- name: assert unarchive zip with creates
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not unzip_again_creates is changed
|
|
|
|
- not unzip_again_creates.removed
|
|
|
|
|
|
|
|
- name: unarchive zip with delete (check)
|
|
|
|
win_unzip:
|
|
|
|
src: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\output'
|
|
|
|
delete_archive: yes
|
|
|
|
register: unzip_delete_check
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- name: get result of unarchive zip with delete (check)
|
|
|
|
win_stat:
|
|
|
|
path: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
register: unzip_delete_actual_check
|
|
|
|
|
|
|
|
- name: assert unarchive zip with delete (check)
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- unzip_delete_check is changed
|
|
|
|
- unzip_delete_check.removed
|
|
|
|
- unzip_delete_actual_check.stat.exists
|
|
|
|
|
|
|
|
- name: unarchive zip with delete
|
|
|
|
win_unzip:
|
|
|
|
src: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
dest: '{{ win_unzip_dir }}\output'
|
|
|
|
delete_archive: yes
|
|
|
|
register: unzip_delete
|
|
|
|
|
|
|
|
- name: get result of unarchive zip with delete
|
|
|
|
win_stat:
|
|
|
|
path: '{{ win_unzip_dir }}\win_unzip.zip'
|
|
|
|
register: unzip_delete_actual
|
|
|
|
|
|
|
|
- name: assert unarchive zip with delete
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- unzip_delete is changed
|
|
|
|
- unzip_delete.removed
|
|
|
|
- not unzip_delete_actual.stat.exists
|