forked from redhat-cip/dci-openshift-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdci-openshift-agent.yml
197 lines (171 loc) · 5.05 KB
/
dci-openshift-agent.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
# Initial step
- hosts: localhost
tags:
- job
tasks:
- name: Read credentials from env vars
set_fact:
dci_client_id="{{ lookup('env','DCI_CLIENT_ID') }}"
dci_api_secret="{{ lookup('env','DCI_API_SECRET') }}"
dci_cs_url="{{ lookup('env','DCI_CS_URL') }}"
no_log: true
# Schedule a new job only if not passed via pipeline
- name: Schedule a new job
dci_job:
components: "{{ dci_components }}"
components_by_query: "{{ dci_components_by_query }}"
topic: "{{ dci_topic }}"
register: job_info
when: job_info is not defined
- name: set job id
set_fact:
job_id: '{{ job_info.job.id }}'
- name: 'Set DCI tags for the current job'
dci_job:
id: '{{ job_id }}'
tags: '{{ dci_tags }}'
when: dci_tags
# Step 1 : state "New job"
- name: Prepare host
hosts: localhost
vars:
dci_status: 'new'
tasks:
- block:
# Prepare host
- name: Configure jumpbox
include_tasks: plays/configure.yml
# Download Openshift from DCI
- name: Import Openshift files from DCI
include_tasks: plays/fetch_bits.yml
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
tags:
- configure
# Step 2 : state "Pre-run"
- name: 'Launch pre-run to deploy installer'
hosts: localhost
tags:
- pre-run
vars:
dci_status: 'pre-run'
tasks:
- block:
# Deploy infrastructure
- name: Run the pre-run hook
include_tasks: '{{ dci_config_dir }}/hooks/pre-run.yml'
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Step 3 : state "configure"
- name: 'Launch configure'
hosts: provisioner
tags:
- running
vars:
dci_status: 'running'
tasks:
- block:
- name: Launch configure
include_tasks: '{{ dci_config_dir }}/hooks/configure.yml'
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Step 4 : state "running"
- name: 'Launch install'
hosts: provisioner
tags:
- running
vars:
dci_status: 'running'
tasks:
- block:
# Launch installer
- name: Launch installer
include_tasks: '{{ dci_config_dir }}/hooks/running.yml'
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Step 5 : state "post-run"
- name: 'Launch post-run tests'
hosts: localhost
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
# Launch DCI tests
- name: Run the post-run ose tests
include_tasks: plays/dci-tests.yml
- name: Run post-run cnf tests setup
include_tasks: plays/cnf-tests-setup.yaml
- name: Run post-run cnf tests
include_tasks: plays/cnf-tests-run.yaml
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Step 6 : state "post-run"
- name: 'Launch post-run tests'
hosts: localhost
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
# Launch user tests
- name: Run the post-run hook
include_tasks: '{{ dci_config_dir }}/hooks/user-tests.yml'
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Step 7 : Upload logs
- name: Upload logs to DCI Control server
hosts: localhost
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
- include_tasks: plays/upload_logs.yml
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Step 8 : state "success"
- name: 'Success'
hosts: localhost
tags:
- success
vars:
dci_status: 'success'
tasks:
- name: Run the post-run hook
include_tasks: '{{ dci_config_dir }}/hooks/success.yml'
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool