validate-zone-db : add job and make more generic
There was a request in If3dc95d1348553e5b43683f6a36d324fb978fbed to make the role more generic so it could handle different layouts of zone.db files. Make it so the role can take a list of tuples (domain, path/to/zone.db) so that we can handle any layouts, and modify the default searching to build this from the source directory. Reviews in https://review.opendev.org/660888 suggested making this defined as a generic job, so a validate-zone-db job is added. Change-Id: I56cbc027f63787f90eef283eeb2fbb81486dcaf5
This commit is contained in:
parent
42b9c209ab
commit
e6ca2e7c84
@ -6,3 +6,4 @@ General Purpose Jobs
|
||||
.. zuul:autojob:: multinode
|
||||
.. zuul:autojob:: run-test-command
|
||||
.. zuul:autojob:: upload-git-mirror
|
||||
.. zuul:autojob:: validate-zone-db
|
||||
|
4
playbooks/validate-zone-db/run.yaml
Normal file
4
playbooks/validate-zone-db/run.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
- hosts: all
|
||||
name: Run zone.db check
|
||||
roles:
|
||||
- validate-zone-db
|
@ -9,4 +9,14 @@ This role uses ``named-checkzone`` to validate Bind ``zone.db`` files.
|
||||
|
||||
Look for ``zone.db`` files recursively in this directory. The
|
||||
layout should be ``domain.xyz/zone.db`` where a parent directory is
|
||||
named for the zone the child ``zone.db`` file describes.
|
||||
named for the zone the child ``zone.db`` file describes. This
|
||||
populates the ``zone_db_files`` variable. Will not be used if
|
||||
``zone_db_files`` is explicitly set per below.
|
||||
|
||||
.. zuul:rolevar:: zone_db_files
|
||||
:default: []
|
||||
|
||||
A list of ``zone.db`` files to check. Each entry is a list with
|
||||
the first element the domain, and the second element the path to
|
||||
the ``zone.db`` file. If this variable is set, automatic searching
|
||||
described by ``zone_files`` will not be performed.
|
||||
|
@ -1,2 +1,3 @@
|
||||
zone_files: '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}'
|
||||
zone_db_files: []
|
||||
|
||||
|
12
roles/validate-zone-db/tasks/find.yaml
Normal file
12
roles/validate-zone-db/tasks/find.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
- name: Find zone files
|
||||
find:
|
||||
paths: '{{ zone_files }}'
|
||||
patterns: 'zone.db'
|
||||
recurse: yes
|
||||
file_type: 'file'
|
||||
register: zone_db_found_files
|
||||
|
||||
- name: Build zone.db file list
|
||||
set_fact:
|
||||
zone_db_files: '{{ zone_db_files + [ [item.path.split("/")[-2], item.path] ] }}'
|
||||
loop: "{{ zone_db_found_files['files'] }}"
|
@ -4,14 +4,10 @@
|
||||
state: present
|
||||
become: yes
|
||||
|
||||
- name: Find zone files
|
||||
find:
|
||||
paths: '{{ zone_files }}'
|
||||
patterns: 'zone.db'
|
||||
recurse: yes
|
||||
file_type: 'file'
|
||||
register: zone_db_files
|
||||
- name: Build zone.db list
|
||||
include_tasks: find.yaml
|
||||
when: not zone_db_files
|
||||
|
||||
- name: 'Run checkzone'
|
||||
command: '/usr/sbin/named-checkzone {{ item.path.split("/")[-2] }} {{ item.path }}'
|
||||
loop: "{{ zone_db_files['files'] }}"
|
||||
command: '/usr/sbin/named-checkzone {{ item[0] }} {{ item[1] }}'
|
||||
loop: "{{ zone_db_files }}"
|
||||
|
22
zuul.yaml
22
zuul.yaml
@ -574,3 +574,25 @@
|
||||
run: playbooks/run-test-command/run.yaml
|
||||
vars:
|
||||
test_command: "exit 1"
|
||||
|
||||
- job:
|
||||
name: validate-zone-db
|
||||
parent: base
|
||||
description: |
|
||||
Validate zone.db files in project.
|
||||
|
||||
Responds to these variables:
|
||||
|
||||
.. zuul:jobvar:: zone_files
|
||||
:default: {{ ansible_user_dir }}/{{ zuul.project.src_dir }}
|
||||
|
||||
Search for zone.db files recursively in this directory.
|
||||
Format should be domain.xyz/zone.db, where the parent
|
||||
directory is named for the zone described.
|
||||
|
||||
.. zuul:jobvar:: zone_db_list
|
||||
:default: []
|
||||
|
||||
Override the default searching above with explicit
|
||||
domain/path references (see validate-zone-db role)
|
||||
run: playbooks/validate-zone-db/run.yaml
|
Loading…
Reference in New Issue
Block a user