-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpulp-artifact-upload.yml
174 lines (158 loc) · 6.08 KB
/
pulp-artifact-upload.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
- name: Upload and create a distribution for an artifact
hosts: seed
vars:
remote_pulp_url: "{{ stackhpc_release_pulp_url }}"
remote_pulp_username: "{{ stackhpc_release_pulp_username }}"
remote_pulp_password: "{{ stackhpc_release_pulp_password }}"
repository_name: "{{ artifact_type }}-{{ openstack_release }}-{{ os_distribution }}-{{ os_release }}"
pulp_base_path: "{{ artifact_type }}/{{ openstack_release }}/{{ os_distribution }}/{{ os_release }}"
upload_checksum: false
tasks:
- name: Print artifact tag
debug:
msg: "artifact tag: {{ artifact_tag }}"
- name: Get filename
find:
paths: "{{ artifact_path }}"
patterns: "{{ file_regex }}"
register: found_files
- name: Upload an artifact
pulp.squeezer.artifact:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
file: "{{ found_files.files[0].path }}"
state: present
register: upload_result
until: upload_result is success
retries: 3
delay: 60
- name: Get sha256 hash
ansible.builtin.stat:
path: "{{ found_files.files[0].path }}"
checksum_algorithm: sha256
register: file_stats
- name: Write checksum to file
ansible.builtin.copy:
content: "{{ file_stats.stat.checksum }}"
dest: "/tmp/{{ found_files.files[0].path | basename }}.sha256"
when: upload_checksum
- name: Get sha256 hash for checksum
ansible.builtin.stat:
path: "/tmp/{{ found_files.files[0].path | basename }}.sha256"
checksum_algorithm: sha256
register: checksum_stats
- name: Upload checksum artifact
pulp.squeezer.artifact:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
file: "/tmp/{{ found_files.files[0].path | basename }}.sha256"
state: present
register: checksum_upload_result
until: checksum_upload_result is success
retries: 3
delay: 60
when: upload_checksum
- name: Create file content from artifact
pulp.squeezer.file_content:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
sha256: "{{ file_stats.stat.checksum }}"
relative_path: "{{ found_files.files[0].path | basename }}"
state: present
register: file_content_result
until: file_content_result is success
retries: 3
delay: 5
- name: Create checksum content from artifact
pulp.squeezer.file_content:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
sha256: "{{ checksum_stats.stat.checksum }}"
relative_path: "{{ found_files.files[0].path | basename }}.sha256"
state: present
register: checksum_content_result
until: checksum_content_result is success
retries: 3
delay: 5
when: upload_checksum
- name: Ensure file repo exists
pulp.squeezer.file_repository:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
name: "{{ repository_name }}"
state: present
register: file_repo_result
until: file_repo_result is success
retries: 3
delay: 5
- name: Add content to file repo
pulp.squeezer.file_repository_content:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
repository: "{{ repository_name }}"
present_content:
- relative_path: "{{ found_files.files[0].path | basename }}"
sha256: "{{ file_stats.stat.checksum }}"
register: file_repo_content_result
until: file_repo_content_result is success
retries: 3
delay: 5
- name: Add checksum content to file repo
pulp.squeezer.file_repository_content:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
repository: "{{ repository_name }}"
present_content:
- relative_path: "{{ found_files.files[0].path | basename }}.sha256"
sha256: "{{ checksum_stats.stat.checksum }}"
register: checksum_repo_content_result
until: checksum_repo_content_result is success
retries: 3
delay: 5
when: upload_checksum
- name: Create a new publication to point to this version
pulp.squeezer.file_publication:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
repository: "{{ repository_name }}"
state: present
register: publication_details
until: publication_details is success
retries: 3
delay: 5
- name: Create distribution for given version
pulp.squeezer.file_distribution:
pulp_url: "{{ remote_pulp_url }}"
username: "{{ remote_pulp_username }}"
password: "{{ remote_pulp_password }}"
name: "{{ repository_name }}_{{ artifact_tag }}"
base_path: "{{ pulp_base_path }}/{{ artifact_tag }}"
publication: "{{ publication_details.publication.pulp_href }}"
content_guard: development
state: present
register: distribution_result
until: distribution_result is success
retries: 3
delay: 5
- name: Update new artifacts file with versioned path
lineinfile:
path: /tmp/updated_artifacts.txt
line: "{{ remote_pulp_url }}/pulp/content/{{ pulp_base_path }}/\
{{ artifact_tag }}/{{ found_files.files[0].path | basename }}"
create: true
- name: Print versioned path
debug:
msg: "New versioned path: {{ remote_pulp_url }}/pulp/content/{{ pulp_base_path }}/\
{{ artifact_tag }}/{{ found_files.files[0].path | basename }}"
- name: Print version tag
debug:
msg: "New tag: {{ artifact_tag }}"