
These two roles no longer need the delegation variable used in testing, so it is removed. Role execution now happens on the executor. Since the remote servers are still on the worker node, we open the firewall on the remote node in both cases. In the artifactory role, the ensure-docker role is moved to a "roles" section for simplicity. Additionally, one of the artifactory API calls is wrapped in retries as a precaution since I saw that fail in local testing. Change-Id: Ia4409edc217e1935775a5aece2e7d9bcfd935762
100 lines
3.5 KiB
YAML
100 lines
3.5 KiB
YAML
- name: Fail if artifactory instance is not defined
|
|
fail:
|
|
msg: "Instance {{ zj_artifact.instance }} is not defined."
|
|
when: zj_artifact.instance not in upload_artifactory_instances
|
|
|
|
- name: Make sure artifact exists on the executor
|
|
stat:
|
|
path: "{{ zuul.executor.work_root }}/artifacts/{{ zj_artifact.src }}"
|
|
register: artifact
|
|
delegate_to: "localhost"
|
|
failed_when: not artifact.stat.exists
|
|
|
|
- name: Get sha256 checksum
|
|
stat:
|
|
path: "{{ zuul.executor.work_root }}/artifacts/{{ zj_artifact.src }}"
|
|
checksum_algorithm: sha256
|
|
delegate_to: "localhost"
|
|
register: artifact_sha256_checksum
|
|
|
|
- name: Set request header fact
|
|
set_fact:
|
|
request_header:
|
|
X-Checksum-Sha1: "{{ artifact.stat.checksum }}"
|
|
X-Checksum-Sha256: "{{ artifact_sha256_checksum.stat.checksum }}"
|
|
|
|
- name: Add artifact headers
|
|
set_fact:
|
|
request_header: "{{ request_header | combine(zj_artifact.headers | default({})) }}"
|
|
|
|
- name: Add api key to header
|
|
when: "'api_key' in upload_artifactory_instances[zj_artifact.instance]"
|
|
no_log: true
|
|
set_fact:
|
|
request_header: "{{ request_header |
|
|
combine({'X-JFrog-Art-Api': upload_artifactory_instances[zj_artifact.instance].api_key}) }}"
|
|
|
|
- name: Set artifactory password
|
|
no_log: true
|
|
set_fact:
|
|
_artifactory_password: "{{ upload_artifactory_instances[zj_artifact.instance].password }}"
|
|
when:
|
|
- "'api_key' not in upload_artifactory_instances[zj_artifact.instance]"
|
|
- "'password' in upload_artifactory_instances[zj_artifact.instance]"
|
|
|
|
- name: Set artifactory backend url fact
|
|
set_fact:
|
|
_artifactory_backend_url: "\
|
|
{{ upload_artifactory_instances[zj_artifact.instance].transport | default('https') }}://\
|
|
{{ upload_artifactory_instances[zj_artifact.instance].fqdn }}/\
|
|
artifactory/\
|
|
{{ zj_artifact.dest }}"
|
|
|
|
- name: Set artifact properties
|
|
set_fact:
|
|
zj_artifact_properties: >-
|
|
{%- set zj_properties = [] -%}
|
|
{%- for zj_p in (zj_aps) -%}
|
|
{%- if zj_p.value is string -%}
|
|
{%- set _ = zj_properties.append(zj_p.key + '=' + zj_p.value) -%}
|
|
{%- elif zj_p.value is iterable and zj_p.value is not mapping -%}
|
|
{%- set _ = zj_properties.append(zj_p.key + '=' + zj_p.value | join(',')) -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{{ zj_properties | join(';') }}
|
|
vars:
|
|
zj_aps: "{{ zj_artifact.properties | default({}) | dict2items }}"
|
|
|
|
- name: Set upload url
|
|
set_fact:
|
|
_artifactory_upload_url: "\
|
|
{%- if zj_artifact_properties | length -%}
|
|
{{ _artifactory_backend_url }};{{ zj_artifact_properties | default('') }}\
|
|
{%- else -%}
|
|
{{ _artifactory_backend_url }}\
|
|
{%- endif -%}"
|
|
|
|
- name: Upload artifact
|
|
no_log: true
|
|
uri:
|
|
user: "{{ upload_artifactory_instances[zj_artifact.instance].user }}"
|
|
password: "{{ _artifactory_password | default(omit) }}"
|
|
url: "{{ _artifactory_upload_url }}"
|
|
src: "{{ zuul.executor.work_root }}/artifacts/{{ zj_artifact.src }}"
|
|
headers: "{{ request_header }}"
|
|
status_code: 201
|
|
method: PUT
|
|
force_basic_auth: "{{ upload_artifactory_instances[zj_artifact.instance].force_basic_auth |
|
|
default(false) | bool }}"
|
|
remote_src: yes # To not unecessarily copy artifact to a tempfile
|
|
delegate_to: "localhost"
|
|
|
|
- name: Add artifact link to build page
|
|
zuul_return:
|
|
data:
|
|
zuul:
|
|
artifacts:
|
|
- name: "{{ zj_artifact.name }}"
|
|
url: "{{ _artifactory_backend_url }}"
|
|
metadata: "{{ zj_artifact.metadata | default(omit) }}"
|