summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/unarchive/tasks/test_mode.yml
blob: c69e3bd2b23da4ae6509aa8aac31a14154ec4729 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
- name: create our unarchive destination
  file:
    path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
    state: directory

- name: unarchive and set mode to 0600, directories 0700
  unarchive:
    src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz"
    dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
    remote_src: yes
    mode: "u+rwX,g-rwx,o-rwx"
    list_files: True
  register: unarchive06

- name: Test that the file modes were changed
  stat:
    path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt"
  register: unarchive06_stat

- name: Test that the file modes were changed
  assert:
    that:
      - "unarchive06.changed == true"
      - "unarchive06_stat.stat.mode == '0600'"
      # Verify that file list is generated
      - "'files' in unarchive06"
      - "{{unarchive06['files']| length}} == 1"
      - "'foo-unarchive.txt' in unarchive06['files']"

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

- name: create our unarchive destination
  file:
    path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
    state: directory

- name: unarchive over existing extraction and set mode to 0644
  unarchive:
    src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz"
    dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
    remote_src: yes
    mode: "u+rwX,g-wx,o-wx,g+r,o+r"
  register: unarchive06_2

- name: Test that the file modes were changed
  stat:
    path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt"
  register: unarchive06_2_stat

- debug:
    var: unarchive06_2_stat.stat.mode

- name: Test that the files were changed
  assert:
    that:
      - "unarchive06_2.changed == true"
      - "unarchive06_2_stat.stat.mode == '0644'"

- name: Repeat the last request to verify no changes
  unarchive:
    src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz"
    dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
    remote_src: yes
    mode: "u+rwX-x,g-wx,o-wx,g+r,o+r"
    list_files: True
  register: unarchive07

- name: Test that the files were not changed
  assert:
    that:
      - "unarchive07.changed == false"
      # Verify that file list is generated
      - "'files' in unarchive07"
      - "{{unarchive07['files']| length}} == 1"
      - "'foo-unarchive.txt' in unarchive07['files']"

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

- name: create our unarchive destination
  file:
    path: '{{remote_tmp_dir}}/test-unarchive-zip'
    state: directory

- name: unarchive and set mode to 0601, directories 0700
  unarchive:
    src: "{{ remote_tmp_dir }}/test-unarchive.zip"
    dest: "{{ remote_tmp_dir }}/test-unarchive-zip"
    remote_src: yes
    mode: "u+rwX-x,g-rwx,o=x"
    list_files: True
  register: unarchive08

- name: Test that the file modes were changed
  stat:
    path: "{{ remote_tmp_dir }}/test-unarchive-zip/foo-unarchive.txt"
  register: unarchive08_stat

- name: Test that the file modes were changed
  assert:
    that:
      - "unarchive08.changed == true"
      - "unarchive08_stat.stat.mode == '0601'"
      # Verify that file list is generated
      - "'files' in unarchive08"
      - "{{unarchive08['files']| length}} == 3"
      - "'foo-unarchive.txt' in unarchive08['files']"
      - "'foo-unarchive-777.txt' in unarchive08['files']"
      - "'FOO-UNAR.TXT' in unarchive08['files']"

- name: unarchive zipfile a second time and set mode to 0601, directories 0700
  unarchive:
    src: "{{ remote_tmp_dir }}/test-unarchive.zip"
    dest: "{{ remote_tmp_dir }}/test-unarchive-zip"
    remote_src: yes
    mode: "u+rwX-x,g-rwx,o=x"
    list_files: True
  register: unarchive08

- name: Test that the file modes were not changed
  stat:
    path: "{{ remote_tmp_dir }}/test-unarchive-zip/foo-unarchive.txt"
  register: unarchive08_stat

- debug:
    var: unarchive08

- debug:
    var: unarchive08_stat

- name: Test that the files did not change
  assert:
    that:
      - "unarchive08.changed == false"
      - "unarchive08_stat.stat.mode == '0601'"
      # Verify that file list is generated
      - "'files' in unarchive08"
      - "{{unarchive08['files']| length}} == 3"
      - "'foo-unarchive.txt' in unarchive08['files']"
      - "'foo-unarchive-777.txt' in unarchive08['files']"
      - "'FOO-UNAR.TXT' in unarchive08['files']"

- name: remove our zip unarchive destination
  file:
    path: '{{ remote_tmp_dir }}/test-unarchive-zip'
    state: absent