Add zuul-tenant-conf-check role/job
This performs static validation of Zuul tenant config files. Change-Id: I5d439d6cfb963e55d07b2a0058de76f030fe47b3
This commit is contained in:
parent
7761396303
commit
73bdf1f2df
@ -12,3 +12,4 @@ General Purpose Jobs
|
||||
.. zuul:autojob:: shake-build
|
||||
.. zuul:autojob:: upload-git-mirror
|
||||
.. zuul:autojob:: validate-zone-db
|
||||
.. zuul:autojob:: zuul-tenant-conf-check
|
||||
|
@ -59,3 +59,4 @@ General Purpose Roles
|
||||
.. zuul:autorole:: validate-zone-db
|
||||
.. zuul:autorole:: version-from-git
|
||||
.. zuul:autorole:: write-inventory
|
||||
.. zuul:autorole:: zuul-tenant-conf-check
|
||||
|
3
playbooks/zuul-tenant-conf-check/pre.yaml
Normal file
3
playbooks/zuul-tenant-conf-check/pre.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- ensure-docker
|
3
playbooks/zuul-tenant-conf-check/run.yaml
Normal file
3
playbooks/zuul-tenant-conf-check/run.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- zuul-tenant-conf-check
|
50
roles/zuul-tenant-conf-check/README.rst
Normal file
50
roles/zuul-tenant-conf-check/README.rst
Normal file
@ -0,0 +1,50 @@
|
||||
Run the zuul-admin tenant-conf-check command.
|
||||
|
||||
This requires a partial zuul.conf (it only needs the connection
|
||||
entries, and those without any credential information) and a tenant
|
||||
config file. It will validate the syntax of the tenant config file
|
||||
(but not the job configuration of any projects in the tenants).
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: zuul_tenant_conf_check_zuul_conf_path
|
||||
|
||||
The path to the partial zuul.conf to use. This must contain the
|
||||
connection entries, but no credentials are required. Any other
|
||||
sections are ignored.
|
||||
|
||||
.. zuul:rolevar:: zuul_tenant_conf_check_tenant_config_path
|
||||
|
||||
The path to the tenant config file to check.
|
||||
|
||||
.. zuul:rolevar:: zuul_tenant_conf_check_image
|
||||
:default: quay.io/zuul-ci/zuul-scheduler:latest
|
||||
|
||||
The Zuul scheduler container image which contains the zuul-admin
|
||||
command to run.
|
||||
|
||||
.. zuul:rolevar:: zuul_tenant_conf_check_registry_credentials
|
||||
|
||||
An optional value, expected in the form of a secret, that supplies
|
||||
credential information if zuul_tenant_conf_check_image is in a
|
||||
registry that requires authentication. The format is a dictionary
|
||||
keyed by the registry name. Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
zuul_tenant_conf_check_registry_credentials:
|
||||
docker.io:
|
||||
username: 'username'
|
||||
password: 'password'
|
||||
|
||||
.. zuul:rolevar:: [registry_name]
|
||||
|
||||
The dictionary key should be the name of the registry
|
||||
|
||||
.. zuul:rolevar:: username
|
||||
|
||||
The registry username.
|
||||
|
||||
.. zuul:rolevar:: password
|
||||
|
||||
The registry password.
|
1
roles/zuul-tenant-conf-check/defaults/main.yaml
Normal file
1
roles/zuul-tenant-conf-check/defaults/main.yaml
Normal file
@ -0,0 +1 @@
|
||||
zuul_tenant_conf_check_image: quay.io/zuul-ci/zuul-scheduler:latest
|
53
roles/zuul-tenant-conf-check/tasks/main.yaml
Normal file
53
roles/zuul-tenant-conf-check/tasks/main.yaml
Normal file
@ -0,0 +1,53 @@
|
||||
- name: Create temporary directory
|
||||
tempfile:
|
||||
state: directory
|
||||
register: zj_zuul_tenant_conf_check_tempdir
|
||||
|
||||
- name: Copy zuul.conf to temporary directory
|
||||
copy:
|
||||
src: "{{ zuul_tenant_conf_check_zuul_conf_path }}"
|
||||
dest: "{{ zj_zuul_tenant_conf_check_tempdir.path }}/zuul.conf"
|
||||
|
||||
- name: Copy tenant config to temporary directory
|
||||
copy:
|
||||
src: "{{ zuul_tenant_conf_check_tenant_config_path }}"
|
||||
dest: "{{ zj_zuul_tenant_conf_check_tempdir.path }}/main.yaml"
|
||||
|
||||
- name: Update zuul.conf with tenant config path
|
||||
ini_file:
|
||||
path: "{{ zj_zuul_tenant_conf_check_tempdir.path }}/zuul.conf"
|
||||
section: scheduler
|
||||
option: tenant_config
|
||||
value: "/work/main.yaml"
|
||||
state: present
|
||||
|
||||
- name: Identify container registry for authentication
|
||||
when: zuul_tenant_conf_check_registry_credentials is defined
|
||||
set_fact:
|
||||
_registry: "{{ (zuul_tenant_conf_check_image | split('/', 1)).0 }}"
|
||||
_repopath: "{{ (zuul_tenant_conf_check_image | split('/', 1)).1 }}"
|
||||
|
||||
- name: Log into container registry
|
||||
when: zuul_tenant_conf_check_registry_credentials is defined
|
||||
command: >-
|
||||
docker login
|
||||
-u "{{ zuul_tenant_conf_check_registry_credentials[_registry].username }}"
|
||||
-p "{{ zuul_tenant_conf_check_registry_credentials[_registry].password }}"
|
||||
{{ _registry }}
|
||||
|
||||
- name: Run tenant-conf-check
|
||||
block:
|
||||
- name: Run tenant-conf-check
|
||||
command: >-
|
||||
docker run --rm -t
|
||||
-v "{{ zj_zuul_tenant_conf_check_tempdir.path }}:/work"
|
||||
{{ zuul_tenant_conf_check_image }}
|
||||
zuul-admin -c /work/zuul.conf tenant-conf-check
|
||||
always:
|
||||
- name: Remove temporary directory
|
||||
file:
|
||||
path: "{{ zj_zuul_tenant_conf_check_tempdir.path }}"
|
||||
state: absent
|
||||
- name: Log out of container registry
|
||||
when: zuul_tenant_conf_check_registry_credentials is defined
|
||||
command: docker logout
|
8
test-playbooks/zuul-tenant-conf-check/main.yaml
Normal file
8
test-playbooks/zuul-tenant-conf-check/main.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
- tenant:
|
||||
name: opendev
|
||||
max-nodes-per-job: 10
|
||||
source:
|
||||
gerrit:
|
||||
config-projects:
|
||||
- opendev/project-config
|
||||
- opendev/base-jobs
|
22
test-playbooks/zuul-tenant-conf-check/zuul.conf
Normal file
22
test-playbooks/zuul-tenant-conf-check/zuul.conf
Normal file
@ -0,0 +1,22 @@
|
||||
[connection "smtp"]
|
||||
driver=smtp
|
||||
server=localhost
|
||||
port=25
|
||||
|
||||
[connection "gerrit"]
|
||||
driver=gerrit
|
||||
server=review.opendev.org
|
||||
user=openstack-zuul
|
||||
|
||||
[connection "opendaylight"]
|
||||
driver=gerrit
|
||||
server=git.opendaylight.org
|
||||
user=openstack-zuul
|
||||
|
||||
[connection "github"]
|
||||
driver=github
|
||||
|
||||
[connection "googlesource"]
|
||||
driver=gerrit
|
||||
server=gerrit-review.googlesource.com
|
||||
user=git-infra-root.openstack.org
|
@ -925,6 +925,18 @@
|
||||
vars:
|
||||
zuul_use_fetch_output: false
|
||||
|
||||
- job:
|
||||
name: zuul-jobs-test-zuul-tenant-conf-check
|
||||
description: Test the zuul-tenant-conf-check role
|
||||
parent: zuul-tenant-conf-check
|
||||
files:
|
||||
- roles/zuul-tenant-conf-check/.*
|
||||
vars:
|
||||
zuul_tenant_conf_check_zuul_conf_path: '{{ zuul.executor.work_root }}/{{ zuul.project.src_dir
|
||||
}}/test-playbooks/zuul-tenant-conf-check/zuul.conf'
|
||||
zuul_tenant_conf_check_tenant_config_path: '{{ zuul.executor.work_root }}/{{
|
||||
zuul.project.src_dir }}/test-playbooks/zuul-tenant-conf-check/main.yaml'
|
||||
|
||||
# -* AUTOGENERATED *-
|
||||
# The following project section is autogenerated by
|
||||
# tox -e update-test-platforms
|
||||
@ -1001,6 +1013,7 @@
|
||||
- zuul-jobs-test-stage-output
|
||||
- zuul-jobs-test-fetch-translation-output
|
||||
- zuul-jobs-test-fetch-translation-output-synchronize
|
||||
- zuul-jobs-test-zuul-tenant-conf-check
|
||||
gate:
|
||||
jobs: *id001
|
||||
periodic-weekly:
|
||||
|
@ -152,3 +152,58 @@
|
||||
|
||||
pre-run: playbooks/shake/pre.yaml
|
||||
run: playbooks/shake/run.yaml
|
||||
|
||||
- job:
|
||||
name: zuul-tenant-conf-check
|
||||
description: |
|
||||
Run the zuul-admin tenant-conf-check command.
|
||||
|
||||
This requires a partial zuul.conf (it only needs the connection
|
||||
entries, and those without any credential information) and a
|
||||
tenant config file. It will validate the syntax of the tenant
|
||||
config file (but not the job configuration of any projects in
|
||||
the tenants).
|
||||
|
||||
.. zuul:jobvar:: zuul_tenant_conf_check_zuul_conf_path
|
||||
|
||||
The path to the partial zuul.conf to use. This must contain the
|
||||
connection entries, but no credentials are required. Any other
|
||||
sections are ignored.
|
||||
|
||||
.. zuul:jobvar:: zuul_tenant_conf_check_tenant_config_path
|
||||
|
||||
The path to the tenant config file to check.
|
||||
|
||||
.. zuul:jobvar:: zuul_tenant_conf_check_image
|
||||
:default: quay.io/zuul-ci/zuul-scheduler:latest
|
||||
|
||||
The Zuul scheduler container image which contains the zuul-admin
|
||||
command to run.
|
||||
|
||||
.. zuul:jobvar:: zuul_tenant_conf_check_registry_credentials
|
||||
|
||||
An optional value, expected in the form of a secret, that supplies
|
||||
credential information if zuul_tenant_conf_check_image is in a
|
||||
registry that requires authentication. The format is a dictionary
|
||||
keyed by the registry name. Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
zuul_tenant_conf_check_registry_credentials:
|
||||
docker.io:
|
||||
username: 'username'
|
||||
password: 'password'
|
||||
|
||||
.. zuul:jobvar:: [registry_name]
|
||||
|
||||
The dictionary key should be the name of the registry
|
||||
|
||||
.. zuul:jobvar:: username
|
||||
|
||||
The registry username.
|
||||
|
||||
.. zuul:jobvar:: password
|
||||
|
||||
The registry password.
|
||||
pre-run: playbooks/zuul-tenant-conf-check/pre.yaml
|
||||
run: playbooks/zuul-tenant-conf-check/run.yaml
|
||||
|
Loading…
Reference in New Issue
Block a user