mirror of https://github.com/ansible/ansible.git
unarchive: handle content and size differences (#83454)
Consider content differs and size differs while unarchiving the same tar.gz file Fixes: #29610 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/83456/head
parent
c2c6005842
commit
c93af4e148
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- unarchive - trigger change when size and content differ when other
|
||||||
|
properties are unchanged (https://github.com/ansible/ansible/pull/83454).
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,56 @@
|
|||||||
|
- set_fact:
|
||||||
|
dest: '{{remote_tmp_dir}}/test-unarchive-tar-gz-content-differs'
|
||||||
|
|
||||||
|
- name: create our tar.gz unarchive destination
|
||||||
|
file:
|
||||||
|
path: "{{ dest }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file
|
||||||
|
unarchive:
|
||||||
|
src: 'content_differs.tar.gz'
|
||||||
|
dest: '{{ dest }}'
|
||||||
|
remote_src: no
|
||||||
|
register: unarchive_content_differs_01
|
||||||
|
|
||||||
|
- name: verify that the task was marked as changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unarchive_content_differs_01.changed
|
||||||
|
|
||||||
|
- name: checksum the file after first unarchive
|
||||||
|
stat:
|
||||||
|
path: '{{ dest }}/hello.txt'
|
||||||
|
checksum_algorithm: sha256
|
||||||
|
get_checksum: yes
|
||||||
|
register: first_unarchive_content
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file with same name, size but different content
|
||||||
|
unarchive:
|
||||||
|
src: 'content_differs_2.tar.gz'
|
||||||
|
dest: '{{ dest }}'
|
||||||
|
remote_src: no
|
||||||
|
register: unarchive_content_differs_01
|
||||||
|
|
||||||
|
- name: verify that the task was marked as changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unarchive_content_differs_01.changed
|
||||||
|
|
||||||
|
- name: checksum the file after second unarchive
|
||||||
|
stat:
|
||||||
|
path: '{{ dest }}/hello.txt'
|
||||||
|
checksum_algorithm: sha256
|
||||||
|
get_checksum: yes
|
||||||
|
register: second_unarchive_content
|
||||||
|
|
||||||
|
- name: verify that unarchive extracted file with new content
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- first_unarchive_content.stat.checksum != second_unarchive_content.stat.checksum
|
||||||
|
- first_unarchive_content.stat.size == second_unarchive_content.stat.size
|
||||||
|
|
||||||
|
- name: remove our tar.gz unarchive destination
|
||||||
|
file:
|
||||||
|
path: '{{ dest }}'
|
||||||
|
state: absent
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
- set_fact:
|
||||||
|
dest: '{{remote_tmp_dir}}/test-unarchive-tar-gz-size-differs'
|
||||||
|
|
||||||
|
- name: create our tar.gz unarchive destination
|
||||||
|
file:
|
||||||
|
path: "{{ dest }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file
|
||||||
|
unarchive:
|
||||||
|
src: 'size_differs.tar.gz'
|
||||||
|
dest: '{{ dest }}'
|
||||||
|
remote_src: no
|
||||||
|
register: unarchive_size_differs_01
|
||||||
|
|
||||||
|
- name: verify that the task was marked as changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unarchive_size_differs_01.changed
|
||||||
|
|
||||||
|
- name: Check size after first unarchive
|
||||||
|
stat:
|
||||||
|
path: '{{ dest }}/hello.txt'
|
||||||
|
register: first_unarchive
|
||||||
|
|
||||||
|
- name: unarchive a tar.gz file with same name but different size
|
||||||
|
unarchive:
|
||||||
|
src: 'size_differs_2.tar.gz'
|
||||||
|
dest: '{{ dest }}'
|
||||||
|
remote_src: no
|
||||||
|
register: unarchive_size_differs_02
|
||||||
|
|
||||||
|
- name: verify that the task was marked as changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- unarchive_size_differs_02.changed
|
||||||
|
|
||||||
|
- name: Check size after unarchive
|
||||||
|
stat:
|
||||||
|
path: '{{ dest }}/hello.txt'
|
||||||
|
register: second_unarchive
|
||||||
|
|
||||||
|
- name: verify that unarchive extracted new sized file
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- first_unarchive.stat.size != second_unarchive.stat.size
|
||||||
|
- first_unarchive.stat.size < second_unarchive.stat.size
|
||||||
|
|
||||||
|
- name: remove our tar.gz unarchive destination
|
||||||
|
file:
|
||||||
|
path: '{{ dest }}'
|
||||||
|
state: absent
|
||||||
Loading…
Reference in New Issue