Browse Source

Add generic base and base-test jobs/playbooks

Start with a stripped-down fork of the base job from project-config,
omitting any OpenStack-specific roles and variables. Also include a
duplicate base-test job intended for testing out potential changes
to the base job.

Extend the linters env for tox to check the included playbooks with
ansible-lint, and add Sphinx integration for autodocumenting the new
playbooks.

Change-Id: I575be518c3e549a51c0c94deb295061dcf8be0b5
changes/40/526140/6
Jeremy Stanley 1 year ago
parent
commit
ab5c4064e7

+ 1
- 0
doc/source/conf.py View File

@@ -22,6 +22,7 @@ import sys
22 22
 extensions = [
23 23
     'sphinx.ext.autodoc',
24 24
     #'sphinx.ext.intersphinx',
25
+    'zuul_sphinx',
25 26
 ]
26 27
 
27 28
 # autodoc generation is a bit aggressive and a nuisance when doing heavy

+ 2
- 0
doc/source/index.rst View File

@@ -4,6 +4,8 @@
4 4
 .. toctree::
5 5
    :maxdepth: 2
6 6
 
7
+   jobs
8
+
7 9
 Indices and tables
8 10
 ==================
9 11
 

+ 5
- 0
doc/source/jobs.rst View File

@@ -0,0 +1,5 @@
1
+Jobs
2
+=====
3
+
4
+.. zuul:autojobs::
5
+

+ 3
- 0
playbooks/base-test/post-ssh.yaml View File

@@ -0,0 +1,3 @@
1
+- hosts: all
2
+  roles:
3
+    - remove-build-sshkey

+ 4
- 0
playbooks/base-test/pre.yaml View File

@@ -0,0 +1,4 @@
1
+- hosts: all
2
+  roles:
3
+    - add-build-sshkey
4
+    - prepare-workspace

+ 3
- 0
playbooks/base/post-ssh.yaml View File

@@ -0,0 +1,3 @@
1
+- hosts: all
2
+  roles:
3
+    - remove-build-sshkey

+ 4
- 0
playbooks/base/pre.yaml View File

@@ -0,0 +1,4 @@
1
+- hosts: all
2
+  roles:
3
+    - add-build-sshkey
4
+    - prepare-workspace

+ 26
- 0
tox.ini View File

@@ -22,8 +22,34 @@ commands = bindep test
22 22
 commands = python setup.py build_sphinx
23 23
 
24 24
 [testenv:linters]
25
+basepython = python3
26
+whitelist_externals = bash
27
+setenv =
28
+   ANSIBLE_LIBRARY= {envdir}/src/zuul/zuul/ansible/library
29
+passenv =
30
+  # NOTE(pabelanger): if you'd like to run tox -elinters locally, you'll need
31
+  # to export ANSIBLE_ROLES_PATH pointing to the currect repos.
32
+  # see infra-zuul-jobs-linters job for more information.
33
+  ANSIBLE_ROLES_PATH
34
+# Add dependencies here since other jobs use python2 and zuul requires
35
+# python3.
36
+deps =
37
+  # Zuul is required to supply the zuul ansible modules for ansible-lint
38
+  -egit+https://git.openstack.org/openstack-infra/zuul@feature/zuulv3#egg=zuul
39
+  ansible<2.4.0
40
+  ansible-lint
41
+  hacking>=0.10,<0.11
42
+  bashate>=0.2
25 43
 commands =
26 44
   flake8 {posargs}
45
+  # Ansible lint
46
+  # [ANSIBLE0012] Commands should not change things if nothing needs doing
47
+  bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
48
+    xargs -t -n1 -0 ansible-lint -xANSIBLE0012"
49
+  # Ansible Syntax Check
50
+  bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
51
+    ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \
52
+    \{\} + > /dev/null"
27 53
 
28 54
 [testenv:venv]
29 55
 commands = {posargs}

+ 28
- 0
zuul.yaml View File

@@ -0,0 +1,28 @@
1
+- job:
2
+    name: base
3
+    parent: null
4
+    description: |
5
+      The recommended base job.
6
+
7
+      All jobs ultimately inherit from this.  It runs a pre-playbook
8
+      which copies all of the job's prepared git repos on to all of
9
+      the nodes in the nodeset.
10
+
11
+      It also sets a default timeout value (which may be overidden).
12
+    pre-run: playbooks/base/pre.yaml
13
+    post-run: playbooks/base/post-ssh.yaml
14
+    roles:
15
+      - zuul: openstack-infra/zuul-jobs
16
+    timeout: 1800
17
+
18
+- job:
19
+    name: base-test
20
+    parent: null
21
+    description: |
22
+      A job to test changes to the base job without disturbing the
23
+      main job in production.  Not for general use.
24
+    pre-run: playbooks/base-test/pre.yaml
25
+    post-run: playbooks/base-test/post-ssh.yaml
26
+    roles:
27
+      - zuul: openstack-infra/zuul-jobs
28
+    timeout: 1800

Loading…
Cancel
Save