/
rdoinfra.yaml
547 lines (511 loc) · 16.9 KB
/
rdoinfra.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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
- job:
name: 'tox-jjb'
defaults: rdo-global
builders:
- rdo-prepare-workspace
- shell: |
set +e -o pipefail
cd $ZUUL_PROJECT
# Copy file containing token for weirdo into the jobs folder
cp -f $WEIRDO_TOKEN_FILE ./jenkins/jobs/weirdo_token
# lines containing authtoken must not be shown in output
tox -e jjb |grep -v -i -e authtoken -e auth-token
triggers:
- zuul
node: rdo-centos-7
wrappers:
- credentials-binding:
- file:
credential-id: 2b9107c5-c511-41e4-9012-a97af25bd295
variable: WEIRDO_TOKEN_FILE
- job:
name: 'publish-cico-jjb'
defaults: rdo-global
concurrent: false
builders:
- rdo-prepare-workspace
- shell: |
set +e -o pipefail
cd $ZUUL_PROJECT
# Copy file containing token for weirdo into the jobs folder
cp -f $WEIRDO_TOKEN_FILE ./jenkins/jobs/weirdo_token
# Ensure that there's no failure before pushing
tox -e jjb |grep -v -i -e authtoken -e auth-token
# Update jobs
source .tox/jjb/bin/activate
pushd jenkins
jenkins-jobs --conf $JJB_CONFIG update jobs |grep -v -i -e authtoken -e auth-token
popd
triggers:
- zuul
node: rdo-centos-7
wrappers:
- credentials-binding:
- file:
credential-id: b578a3ee-cf49-4250-899a-0bc7f84363c2
variable: JJB_CONFIG
- file:
credential-id: 2b9107c5-c511-41e4-9012-a97af25bd295
variable: WEIRDO_TOKEN_FILE
- job:
name: rdo-infra-ansible-lint
defaults: rdo-global
builders:
- rdo-prepare-workspace
- shell: |
set -e
virtualenv $WORKSPACE/ansible-lint
source $WORKSPACE/ansible-lint/bin/activate
pip install ansible-lint
find $WORKSPACE/$ZUUL_PROJECT -type f -not -name '*vault.yml' -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 ansible-lint -x ANSIBLE0006,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0014
triggers:
- zuul
node: rdo-centos-7
- builder:
name: checkout-rdo-kolla-build
builders:
- shell: |
set -ex
if [[ "${ZUUL_PROJECT}" != "rdo-infra/ansible-role-rdo-kolla-build" ]]; then
mkdir -p $WORKSPACE/rdo-infra/ansible-role-rdo-kolla-build
git clone https://github.com/rdo-infra/ansible-role-rdo-kolla-build rdo-infra/ansible-role-rdo-kolla-build
fi
- builder:
name: rdo-kolla-build-images
builders:
- shell: |
set -ex
mkdir -p $WORKSPACE/roles
ln -s $WORKSPACE/rdo-infra/ansible-role-rdo-kolla-build $WORKSPACE/roles/kolla-build
sudo yum -y install libselinux-python
# Need to inherit system-site-packages for libselinux-python and python-yum
virtualenv --system-site-packages $WORKSPACE/ansible
source $WORKSPACE/ansible/bin/activate
pip install ansible==2.5.2 ara
export ara_location=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")
export ANSIBLE_CALLBACK_PLUGINS=$ara_location/plugins/callbacks
export ANSIBLE_ACTION_PLUGINS=$ara_location/plugins/actions
export ANSIBLE_LIBRARY=$ara_location/plugins/modules
export ANSIBLE_ROLES_PATH=$WORKSPACE/roles
export ARA_DATABASE="sqlite:///$WORKSPACE/ara.sqlite"
cat << EOF > ${WORKSPACE}/playbook.yml
---
- name: Build Kolla images
hosts: localhost
become: yes
become_user: root
roles:
- kolla-build
EOF
ansible-playbook -i localhost $WORKSPACE/playbook.yml --tags "setup,build"
- job:
name: 'rdo-kolla-build-integration'
defaults: rdo-global
builders:
- rdo-prepare-workspace
- rdo-log-setup
- dlrn-gate-repository
- checkout-rdo-kolla-build
- rdo-kolla-build-images
triggers:
- zuul
publishers:
- postbuildscript:
builders:
- shell: |
mkdir $WORKSPACE/logs
cp -a /tmp/kolla $WORKSPACE/logs/
export ARA_DATABASE="sqlite:///$WORKSPACE/ara.sqlite"
sudo -E $WORKSPACE/ansible/bin/ara generate html $WORKSPACE/logs/ara
# Ensure permissions allow artifact uploading
sudo chown -R "$(id -u).$(id -g)" $WORKSPACE/logs
script-only-if-succeeded: False
script-only-if-failed: False
- rdo-rsync-logs
node: rdo-centos-7
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
- job:
name: gate-rdo-kolla-build-containers
defaults: rdo-global
builders:
- rdo-prepare-workspace
- rdo-log-setup
- checkout-rdo-kolla-build
- rdo-kolla-build-images
triggers:
- zuul
publishers:
- postbuildscript:
builders:
- shell: |
mkdir $WORKSPACE/logs
cp -a /tmp/kolla $WORKSPACE/logs/
export ARA_DATABASE="sqlite:///$WORKSPACE/ara.sqlite"
sudo -E $WORKSPACE/ansible/bin/ara generate html $WORKSPACE/logs/ara
# Ensure permissions allow artifact uploading
sudo chown -R "$(id -u).$(id -g)" $WORKSPACE/logs
script-only-if-succeeded: False
script-only-if-failed: False
- rdo-rsync-logs
node: rdo-centos-7
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
- builder:
name: rdo-infra-playbooks-prepare
builders:
- shell: |
CLONEMAP=$(mktemp)
function cleanup {
rm -f $CLONEMAP
}
trap cleanup EXIT
cat > $CLONEMAP << EOF
clonemap:
- name: 'rdo-infra/rdo-infra-playbooks'
dest: 'rdo-infra-playbooks'
- name: 'rdo-infra/ansible-role-rdo-(.*)'
dest: 'rdo-infra-playbooks/roles/rdo-infra/\1'
- name: 'centos-opstools/opstools-ansible'
dest: 'rdo-infra-playbooks/roles/opstools-ansible'
EOF
# Zuul clone rdo-infra-playbooks and it's roles at their expected location
zuul-cloner -m $CLONEMAP \
https://review.rdoproject.org/r \
rdo-infra/rdo-infra-playbooks \
rdo-infra/ansible-role-rdo-base \
rdo-infra/ansible-role-rdo-bot \
centos-opstools/opstools-ansible
- builder:
name: rdo-infra-playbooks-integration
builders:
- shell: |
set -e
# Need to inherit system-site-packages for libselinux-python and python-yum
virtualenv --system-site-packages $WORKSPACE/ansible
source $WORKSPACE/ansible/bin/activate
pip install ansible==2.4.2.0 ara
export ara_location=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")
export ANSIBLE_CALLBACK_PLUGINS=$ara_location/plugins/callbacks
export ANSIBLE_ACTION_PLUGINS=$ara_location/plugins/actions
export ANSIBLE_LIBRARY=$ara_location/plugins/modules
# ANSIBLE_ASK_VAULT_PASS and ANSIBLE_VAULT_PASSWORD_FILE are mutually
# exclusive. We default ANSIBLE_ASK_VAULT_PASS to true in ansible.cfg.
export ANSIBLE_ASK_VAULT_PASS=false
export ARA_DATABASE="sqlite:///$WORKSPACE/ara.sqlite"
export ANSIBLE_HOSTS="$WORKSPACE/integration-hosts.yml"
# This is an empty version of hosts.yml from rdo-infra-playbooks
# so that we are easily and safely able to run everything against localhost
cat > $ANSIBLE_HOSTS << EOF
all:
vars:
public_address: 0.0.0.0
hosts:
localhost:
ansible_connection: local
children:
standard:
hosts:
localhost:
review:
hosts:
localhost:
dlrn:
hosts:
localhost:
backup:
hosts:
localhost:
cico:
hosts:
localhost:
monitoring:
hosts:
localhost:
logserver:
hosts:
localhost:
# TODO: Fix this
# rabbit_hosts is expected by opstools-ansible
rabbit_hosts:
children:
monitoring
monitoring_clients:
children:
standard:
review:
dlrn:
cico:
monitoring:
EOF
pushd rdo-infra-playbooks
# Use test data for the runs
if [ -f samples/secrets.vault.yml ]; then
cat samples/secrets.vault.yml > playbooks/group_vars/all/secrets.vault.yml
fi
ansible-playbook -i $ANSIBLE_HOSTS playbooks/{playbook}.yml \
-e "rdobot_nickname=not_rdobot" \
-e "sensu_rabbitmq_server=localhost"
echo "Re-running for idempotency"
ansible-playbook -i $ANSIBLE_HOSTS playbooks/{playbook}.yml \
-e "rdobot_nickname=not_rdobot" \
-e "sensu_rabbitmq_server=localhost"
popd
- builder:
name: fedora-stable-sync-repoclosure
builders:
- shell: |
set -e
mkdir -p $WORKSPACE/logs
# cachedir configuration added by dib breaks running some dnf
# commands with non-root users.
sudo sed -i '/^cachedir.*/d' /etc/dnf/dnf.conf
# diskimage builder excludes some packages from repos as pip
# and virtualenb what breaks synchronization.
sudo sed -i '/^exclude.*/d' /etc/dnf/dnf.conf
sudo dnf remove -y yum-utils
sudo dnf install -y createrepo_c dnf-utils fedora-packager
git clone https://review.rdoproject.org/r/rdo-infra/sinkhole
virtualenv -p python3 --system-site-packages .venv
source .venv/bin/activate
pushd sinkhole
pip install .
popd
cd $ZUUL_PROJECT
OUTPUT_DIR=$(grep output_dir fedora_config | cut -d= -f2 | tr -d '[:space:]')
sudo mkdir -p $OUTPUT_DIR
sudo chown ${USER} $OUTPUT_DIR
if [ -f comps*xml ];then
cp comps*xml $OUTPUT_DIR
fi
echo "INFO: Running synchronization using sinkhole"
sinkhole --config fedora_config
echo "INFO: Running repoclosure"
dnf clean all
repoquery --repofrompath=temp,file://${OUTPUT_DIR} --disablerepo='*' --enablerepo=temp -q -a > $WORKSPACE/logs/repoquery_output.txt
repoclosure --repofrompath=temp,file://${OUTPUT_DIR} --disablerepo='*' --enablerepo=temp
if [ -f $OUTPUT_DIR/comps*xml ];then
rm $OUTPUT_DIR/comps*xml
fi
- builder:
name: fedora-stable-imagefactory
builders:
- shell: |
set -e
mkdir -p $WORKSPACE/logs
cd $ZUUL_PROJECT
OUTPUT_DIR=$(grep output_dir fedora_config | cut -d= -f2 | tr -d '[:space:]')
if [ -d imagefactory ]; then
cd imagefactory
sudo bash -x build-image.sh $OUTPUT_DIR
fi
- job-template:
name: 'rdo-infra-playbooks-integration-{playbook}{suffix}'
defaults: rdo-global
builders:
- rdo-prepare-workspace
- rdo-infra-playbooks-prepare
- rdo-log-setup
- rdo-infra-playbooks-integration:
playbook: '{playbook}'
triggers:
- zuul
publishers:
- postbuildscript:
builders:
- shell: |
mkdir $WORKSPACE/logs
export ARA_DATABASE="sqlite:///$WORKSPACE/ara.sqlite"
sudo -E $WORKSPACE/ansible/bin/ara generate html $WORKSPACE/logs/ara
# Ensure permissions allow artifact uploading
sudo chown -R "$(id -u).$(id -g)" $WORKSPACE/logs
script-only-if-succeeded: False
script-only-if-failed: False
- rdo-rsync-logs
node: '{image}'
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
- project:
name: rdo-infra-playbooks-integration
jobs:
- 'rdo-infra-playbooks-integration-{playbook}{suffix}':
playbook:
- base
- sensu-client
- sensu-server
- logserver
suffix:
- ''
- '-nv'
image: 'rdo-centos-7'
- 'rdo-infra-playbooks-integration-{playbook}{suffix}':
playbook:
- base
- sensu-client
suffix:
- '-fedora-nv'
image: 'rdo-fedora-26'
- job:
name: 'tox-flake8'
defaults: rdo-global
builders:
- rdo-prepare-workspace
- shell: |
set +e
cd $ZUUL_PROJECT
tox -e flake8
triggers:
- zuul
node: rdo-centos-7
- job:
name: gate-tox-ansible-lint
defaults: rdo-global
builders:
- rdo-prepare-workspace
- shell: |
set +e
cd $ZUUL_PROJECT
tox -e ansible-lint
triggers:
- zuul
node: rdo-centos-7
- job:
name: gate-tox-docs
defaults: rdo-global
builders:
- rdo-prepare-workspace
- rdo-log-setup
- shell: |
set +e
pushd $ZUUL_PROJECT
tox -e docs
popd
mkdir logs
sudo cp -a $ZUUL_PROJECT/doc/build/html logs/
# Ensure permissions allow artifact uploading
sudo chown -R "$(id -u).$(id -g)" logs
triggers:
- zuul
publishers:
- rdo-rsync-logs
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
node: rdo-centos-7
- job:
name: rdo-registry-integration
defaults: rdo-global
builders:
- rdo-prepare-workspace
- rdo-log-setup
- shell: |
set +e
cd $ZUUL_PROJECT
./run_tests.sh
triggers:
- zuul
publishers:
- postbuildscript:
builders:
- shell: |
mkdir $WORKSPACE/logs
$WORKSPACE/$ZUUL_PROJECT/.tox/ansible-playbook/bin/ara generate html $WORKSPACE/logs/ara
# Copy database (experimental)
mkdir $WORKSPACE/logs/ara-database
cp $HOME/.ara/ansible.sqlite $WORKSPACE/logs/ara-database/ansible.sqlite
# Ensure permissions allow artifact uploading
sudo chown -R "$(id -u).$(id -g)" $WORKSPACE/logs
script-only-if-succeeded: False
script-only-if-failed: False
- rdo-rsync-logs
node: rdo-centos-7
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
- job:
name: test-logs
defaults: rdo-global
builders:
- rdo-prepare-workspace
- rdo-log-setup
- shell: |
set +e
cd $ZUUL_PROJECT
./run_tests.sh
triggers:
- zuul
publishers:
- postbuildscript:
builders:
- shell: |
mkdir $WORKSPACE/logs
echo "noop" >$WORKSPACE/logs/test.txt
# Ensure permissions allow artifact uploading
sudo chown -R "$(id -u).$(id -g)" $WORKSPACE/logs
script-only-if-succeeded: False
script-only-if-failed: False
- rdo-rsync-logs
node: rdo-centos-7
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
- job:
name: 'fedora-stable-repoclosure'
defaults: rdo-global
concurrent: false
builders:
- rdo-prepare-workspace
- rdo-log-setup
- fedora-stable-sync-repoclosure
triggers:
- zuul
publishers:
- rdo-rsync-logs
node: rdo-fedora-26
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY
- job:
name: 'fedora-stable-image-build-nv'
defaults: rdo-global
concurrent: false
builders:
- rdo-prepare-workspace
- rdo-log-setup
- fedora-stable-sync-repoclosure
- fedora-stable-imagefactory
triggers:
- zuul
publishers:
- rdo-rsync-logs
node: rdo-fedora-26
wrappers:
- timestamps
- credentials-binding:
- file:
credential-id: 4b4632bd-f44b-446d-a8ca-b57eabef0a7c
variable: LOG_SSH_KEY