summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/unarchive/tasks/test_tar_gz_keep_newer.yml
blob: aec94545631538ffd0addf31883da10e1f6ba90b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
- name: create our tar.gz unarchive destination for keep-newer
  file:
    path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
    state: directory

- name: Create a newer file that we would replace
  copy:
    dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt"
    content: boo
    mode: preserve

- name: unarchive a tar.gz file but avoid overwriting newer files (keep_newer=true)
  unarchive:
    src: "{{remote_tmp_dir}}/test-unarchive.tar.gz"
    dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
    remote_src: yes
    keep_newer: true
  register: unarchive02f

- name: Make sure the file still contains 'boo'
  shell: cat {{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt
  register: unarchive02f_cat

- name: remove our tar.gz unarchive destination
  file:
    path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
    state: absent

- name: create our tar.gz unarchive destination for keep-newer (take 2)
  file:
    path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
    state: directory

- name: unarchive a tar.gz file and overwrite newer files (keep_newer=false)
  unarchive:
    src: "{{remote_tmp_dir}}/test-unarchive.tar.gz"
    dest: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
    remote_src: yes
    keep_newer: false
  register: unarchive02g

- name: Make sure the file still contains 'boo'
  shell: cat {{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt
  register: unarchive02g_cat

- name: remove our tar.gz unarchive destination
  file:
    path: "{{remote_tmp_dir}}/test-unarchive-tar-gz"
    state: absent

- name: verify results
  assert:
    that:
    - unarchive02f is changed
    - unarchive02f_cat.stdout == 'boo'
    - unarchive02g is changed
    - unarchive02g_cat.stdout != 'boo'