Debian Codegraph @

test/integration/targets/git/tasks/archive.yml

raw
1 - name: ARCHIVE | Clear checkout_dir
2 file:
3 state: absent
4 path: "{{ checkout_dir }}"
5
6 - name: ARCHIVE | Archive repo using various archival format
7 git:
8 repo: '{{ repo_format1 }}'
9 dest: '{{ checkout_dir }}'
10 archive: '{{ checkout_dir }}/test_role.{{ item }}'
11 register: git_archive
12 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
13
14 - name: ARCHIVE | Assert that archives were downloaded
15 assert:
16 that: (git_archive.results | map(attribute='changed') | unique | list)[0]
17
18 - name: ARCHIVE | Check if archive file is created or not
19 stat:
20 path: '{{ checkout_dir }}/test_role.{{ item }}'
21 register: archive_check
22 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
23
24 - name: ARCHIVE | Assert that archive files exist
25 assert:
26 that: (archive_check.results | map(attribute='stat.exists') | unique | list)[0]
27 when: ansible_os_family == 'RedHat'
28
29 - name: ARCHIVE | Clear checkout_dir
30 file:
31 state: absent
32 path: "{{ checkout_dir }}"
33
34 - name: ARCHIVE | Clone clean repo
35 git:
36 repo: '{{ repo_format1 }}'
37 dest: '{{ checkout_dir }}'
38
39 # Check git archive functionality without update
40 - name: ARCHIVE | Archive repo using various archival format and without update
41 git:
42 repo: '{{ repo_format1 }}'
43 dest: '{{ checkout_dir }}'
44 update: no
45 archive: '{{ checkout_dir }}/test_role.{{ item }}'
46 register: git_archive
47 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
48
49 - name: ARCHIVE | Assert that archives were downloaded
50 assert:
51 that: (git_archive.results | map(attribute='changed') | unique | list)[0]
52
53 - name: ARCHIVE | Check if archive file is created or not
54 stat:
55 path: '{{ checkout_dir }}/test_role.{{ item }}'
56 register: archive_check
57 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
58
59 - name: ARCHIVE | Assert that archive files exist
60 assert:
61 that: (archive_check.results | map(attribute='stat.exists') | unique | list)[0]
62 when: ansible_os_family == 'RedHat'
63
64 - name: ARCHIVE | Inspect archive file
65 command:
66 cmd: "{{ git_list_commands[item] }} {{ checkout_dir }}/test_role.{{ item }}"
67 register: archive_content
68 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
69
70 - name: ARCHIVE | Ensure archive content is correct
71 assert:
72 that:
73 - item.stdout_lines | sort | first == 'defaults/'
74 with_items: "{{ archive_content.results }}"
75
76 - name: ARCHIVE | Clear checkout_dir
77 file:
78 state: absent
79 path: "{{ checkout_dir }}"
80
81 - name: ARCHIVE | Generate an archive prefix
82 set_fact:
83 git_archive_prefix: "{{ lookup('ansible.builtin.password', '/dev/null', length=10, chars=['digits']) }}" # Generate some random archive prefix
84
85 - name: ARCHIVE | Archive repo using various archival format and with an archive prefix
86 git:
87 repo: '{{ repo_format1 }}'
88 dest: '{{ checkout_dir }}'
89 archive: '{{ checkout_dir }}/test_role.{{ item }}'
90 archive_prefix: '{{ git_archive_prefix }}/'
91 register: git_archive
92 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
93
94 - name: ARCHIVE | Prepare the target for archive(s) extraction
95 file:
96 state: directory
97 path: '{{ checkout_dir }}/{{ git_archive_prefix }}.{{ item }}'
98 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
99
100 - name: ARCHIVE | Extract the archive(s) into that target
101 unarchive:
102 src: '{{ checkout_dir }}/test_role.{{ item }}'
103 dest: '{{ checkout_dir }}/{{ git_archive_prefix }}.{{ item }}'
104 remote_src: yes
105 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
106
107 - name: ARCHIVE | Check if prefix directory exists in what's extracted
108 find:
109 path: '{{ checkout_dir }}/{{ git_archive_prefix }}.{{ item }}'
110 patterns: '{{ git_archive_prefix }}'
111 file_type: directory
112 register: archive_check
113 with_items: "{{ git_archive_extensions[ansible_os_family ~ ansible_distribution_major_version | default('default') ] | default(git_archive_extensions.default) }}"
114
115 - name: ARCHIVE | Assert that prefix directory is found
116 assert:
117 that: item.matched == 1
118 with_items: "{{ archive_check.results }}"