/
run.yaml
119 lines (114 loc) · 3.92 KB
/
run.yaml
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
---
# Zuul executor has some limitations that prevents from running the role
# directly there so we have to generate a playbook and run it at the
# node
- hosts: primary
vars:
repro_role_path: >-
{{ ansible_user_dir }}/{{ zuul.projects[
'review.rdoproject.org/rdo-infra/ansible-role-tripleo-ci-reproducer'
].src_dir }}
tasks:
- name: Set facts for mirrors
set_fact:
mirror_fqdn: "mirror.{{ nodepool.region | lower }}.{{ nodepool.cloud | lower }}.rdoproject.org"
when: mirror_fqdn is not defined
- name: Set facts for zuul site mirror fqdn
set_fact:
zuul_site_mirror_fqdn: "{{ mirror_fqdn }}"
when: zuul_site_mirror_fqdn is not defined
- name: Set facts for pypi fqdn
set_fact:
pypi_fqdn: "{{ mirror_fqdn }}"
when: pypi_fqdn is not defined
- name: Use RDO docker registry at RDO cloud
when:
- "'rdo-cloud' in nodepool.cloud"
- container_mode == 'docker'
vars:
docker_registry: "http://{{ mirror_fqdn }}:8081/registry-1.docker/"
block:
- name: Read docker daemon configuration
become: true
slurp:
src: /etc/docker/daemon.json
register: docker
- name: Compose docker registry mirror config
set_fact:
mirrored_docker_registry: "{{
docker.content | b64decode | from_json | combine({
'registry-mirrors': [docker_registry]
}) }}"
- name: Write modified docker daemon config
become: true
copy:
content: "{{ mirrored_docker_registry | default({}) | to_nice_json }}"
dest: /etc/docker/daemon.json
- name: Reload docker to set mirrors
become: true
service:
name: docker
state: reloaded
- name: Use RDO container registry at RDO cloud
become: true
ini_file:
path: /etc/containers/registries.conf
section: registries.search
option: registries
value: ["docker.io"]
backup: true
when:
- "'rdo-cloud' in nodepool.cloud"
- container_mode == 'podman'
- name: Create roles directory
file:
path: "{{ ansible_user_dir }}/roles"
state: directory
- name: Link role
file:
src: "{{ repro_role_path }}"
dest: "{{ ansible_user_dir }}/roles/tripleo-ci-reproducer"
state: link
- name: Generate reproducer playbook
template:
src: run.yaml.j2
dest: "{{ ansible_user_dir }}/start.yaml"
- name: Load variables from defaults of tripleo-ci-reproducer
include_vars: "ci_jobs_config.yaml"
- name: Generate jobs config
blockinfile:
content: |
{{ ci_jobs_config[ci_job] | default({}) | to_nice_yaml }}
path: "{{ ansible_user_dir }}/ci-job.yaml"
create: true
- name: Prepare zuul variables from job context
set_fact:
zuul_config:
zuul: "{{ zuul }}"
- name: Pass zuul variables
blockinfile:
content: |
{{ zuul_config | default({}) | to_nice_yaml }}
path: "{{ ansible_user_dir }}/zuul_vars.yaml"
create: true
- name: Dump hostvars with job variables
set_fact:
local_hostvars: "{{ {'job': hostvars[inventory_hostname]} }}"
- name: Dump hostvars on the host to pass it to inner ansible
copy:
content: "{{ local_hostvars|to_nice_yaml }}"
dest: "{{ ansible_user_dir }}/hostvars-variables.yaml"
- name: Pass override config for reproducer
blockinfile:
content: |
{{ override | default({}) | to_nice_yaml }}
path: "{{ ansible_user_dir }}/override.yaml"
create: true
- name: Generate run script
template:
src: run.sh.j2
dest: "{{ ansible_user_dir }}/run.sh"
mode: 0755
- name: Run reproducer
command: "{{ ansible_user_dir }}/run.sh"
changed_when: true