Browse Source

Merge "Introduce new Ansible validation_init role."

changes/06/790806/30
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
26159d9d78
21 changed files with 681 additions and 158 deletions
  1. +1
    -1
      .config/molecule/config.yml
  2. +10
    -5
      doc/source/contributing/developer_guide.rst
  3. +8
    -0
      doc/source/roles/role-validation_init.rst
  4. +3
    -144
      role-addition.yml
  5. +47
    -0
      roles/validation_init/README.md
  6. +28
    -0
      roles/validation_init/defaults/main.yml
  7. +1
    -1
      roles/validation_init/files/_skeleton_role_/defaults/main.yml.j2
  8. +1
    -1
      roles/validation_init/files/_skeleton_role_/handlers/main.yml
  9. +1
    -1
      roles/validation_init/files/_skeleton_role_/molecule/default/converge.yml.j2
  10. +0
    -3
      roles/validation_init/files/_skeleton_role_/molecule/default/molecule.yml
  11. +25
    -0
      roles/validation_init/files/_skeleton_role_/molecule/default/prepare.yml
  12. +24
    -0
      roles/validation_init/files/_skeleton_role_/molecule/default/verify.yml
  13. +1
    -1
      roles/validation_init/files/_skeleton_role_/tasks/main.yml.j2
  14. +1
    -1
      roles/validation_init/files/_skeleton_role_/vars/main.yml.j2
  15. +62
    -0
      roles/validation_init/molecule/default/converge.yml
  16. +3
    -0
      roles/validation_init/molecule/default/molecule.yml
  17. +96
    -0
      roles/validation_init/molecule/default/prepare.yml
  18. +137
    -0
      roles/validation_init/molecule/default/verify.yml
  19. +180
    -0
      roles/validation_init/tasks/main.yml
  20. +39
    -0
      roles/validation_init/templates/README.md.j2
  21. +13
    -0
      zuul.d/molecule.yaml

+ 1
- 1
.config/molecule/config.yml View File

@ -67,4 +67,4 @@ scenario:
- destroy
verifier:
name: testinfra
name: ansible

+ 10
- 5
doc/source/contributing/developer_guide.rst View File

@ -439,10 +439,13 @@ will perform the basic tasks noted above.
.. code-block:: console
$ cd tripleo-validations/
$ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME}
$ export ANSIBLE_ROLES_PATH="${PWD}/roles"
$ ansible-playbook -i localhost, role-addition.yml -e validation_init_role_name=${NEWROLENAME}
The new role will be created in `tripleo-validations/roles/` from a skeleton and one playbook
will be added in `tripleo-validations/playbooks/`.
When the role is ready for CI, add a **job** entry into the
`zuul.d/molecule.yaml`.
It will also add a new **job** entry into the `zuul.d/molecule.yaml`.
.. code-block:: yaml
@ -455,7 +458,7 @@ When the role is ready for CI, add a **job** entry into the
tripleo_validations_role_name: ${NEWROLENAME}
Make sure to add the **job** name into the check and gate section at the top
And the **job** name will be added into the check and gate section at the top
of the `molecule.yaml` file.
.. code-block:: yaml
@ -469,12 +472,14 @@ of the `molecule.yaml` file.
- tripleo-validations-centos-8-molecule-${NEWROLENAME}
Finally add a role documentation file at
Finally it will add a role documentation file at
`doc/source/roles/role-${NEWROLENAME}.rst`. This file will need to contain
a title, a literal include of the defaults yaml and a literal include of
the molecule playbook, or playbooks, used to test the role, which is noted
as an "example" playbook.
You will now be able to develop your new validation!
Local testing of new roles
--------------------------


+ 8
- 0
doc/source/roles/role-validation_init.rst View File

@ -0,0 +1,8 @@
===============
validation_init
===============
.. literalinclude:: ../../../roles/validation_init/README.md
.. ansibleautoplugin::
:role: roles/validation_init

+ 3
- 144
role-addition.yml View File

@ -1,5 +1,5 @@
---
# Copyright 2019 Red Hat, Inc.
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -18,146 +18,5 @@
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Check for role name
fail:
msg: >-
The required variable `role_name` is undefined. Check your settings.
when:
- role_name is undefined
- name: Ensure role name is not empty
fail:
msg: >-
The required variable `role_name` is empty. Check your settings.
when:
- role_name is defined
- role_name == ''
- name: Normalize the role name
set_fact:
_role_name: "{{ role_name | replace('-', '_' ) }}"
dashed_role_name: "{{ role_name | replace('_', '-') }}"
- name: Create role
command: >-
ansible-galaxy init
--role-skeleton=_skeleton_role_
--init-path=roles/
validation_{{ _role_name }}
args:
creates: "roles/validation_{{ _role_name }}"
- name: Create link to the common Dockerfile
file:
src: ../../../../.config/molecule/Dockerfile
dest: roles/validation_{{ _role_name }}/molecule/default/Dockerfile
state: link
- name: Read zuul molecule file
slurp:
src: zuul.d/molecule.yaml
register: molecule_yaml
- name: Create molecule entry
copy:
content: |-
---
{% set items = molecule_yaml['content'] | b64decode | from_yaml %}
{% set job_index = [] %}
{% set new_job_name = "tripleo-validations-centos-8-molecule-" ~ _role_name %}
{% for item in items %}
{% if 'project-template' in item %}
{% if item['project-template']['name'] == "tripleo-validations-molecule-jobs" %}
{% if not (new_job_name in item['project-template']['check']['jobs']) %}
{% set _ = item['project-template']['check']['jobs'].append(new_job_name) %}
{% set check_jobs = (item['project-template']['check']['jobs'] | sort) %}
{% set _ = item['project-template']['check'].update({'jobs': check_jobs}) %}
{% endif %}
{% if not (new_job_name in item['project-template']['gate']['jobs']) %}
{% set _ = item['project-template']['gate']['jobs'].append(new_job_name) %}
{% set gate_jobs = (item['project-template']['gate']['jobs'] | sort) %}
{% set _ = item['project-template']['gate'].update({'jobs': gate_jobs}) %}
{% endif %}
{% endif %}
{% else %}
{% if item['job']['name'] == new_job_name %}
{% set _ = job_index.append(new_job_name) %}
{% endif %}
{% endif %}
{% endfor %}
{% if (job_index | length) < 1 %}
{% set new_job = {
"name": new_job_name,
"parent": "tripleo-validations-centos-8-base",
"files": [
"^roles/validation_" ~ _role_name ~ "/.*",
"^tests/prepare-test-host.yml",
"^ci/playbooks/pre.yml",
"^ci/playbooks/run.yml"
],
"vars": {
"tripleo_validations_role_name": "validation_" ~ _role_name
}
}
%}
{% set _ = items.append({"job": new_job}) %}
{% endif %}
{{ items | to_nice_yaml(indent=2, width=1337) }}
dest: zuul.d/molecule.yaml
- name: Create the playbook
copy:
content: |
---
- hosts: undercloud
gather_facts: false
vars:
metadata:
name: The Validation name goes here
description: |
Write a description of your validations
groups:
- backup-and-restore
- no-op
- prep
- pre-introspection
- pre-deployment
- post-deployment
- openshift-on-openstack
- pre-upgrade
- post-upgrade
- pre-system-upgrade
- post-system-upgrade
- pre-undercloud-upgrade
- post-undercloud-upgrade
- pre-overcloud-prepare
- post-overcloud-prepare
- pre-overcloud-upgrade
- post-overcloud-upgrade
- pre-overcloud-converge
- post-overcloud-converge
- pre-ceph
- post-ceph
- pre-update
- pre-update-prepare
- pre-update-run
- pre-update-converge
- post-update
validation_{{ _role_name }}_debug: false
roles:
- validation_{{ _role_name }}
dest: "playbooks/{{ dashed_role_name }}.yaml"
- name: Create role documentation
copy:
content: |
{% set opening = 'Role - ' ~ _role_name %}
{{ '=' * (opening | length) }}
{{ opening }}
{{ '=' * (opening | length) }}
.. ansibleautoplugin::
:role: roles/validation_{{ _role_name }}
dest: "doc/source/roles/role-validation_{{ _role_name }}.rst"
roles:
- validation_init

+ 47
- 0
roles/validation_init/README.md View File

@ -0,0 +1,47 @@
Validation_init
===============
The purpose of this `validation_init` role is to create new validation from a skeleton.
Requirements
------------
None.
Role Variables
--------------
* `validation_init_debug`: <'false'> -- Debugging mode.
* `validation_init_role_name`: <'Undefined'> -- New role name, undefined by default!
* `validation_init_prefix`: <'tripleo'> -- New role prefix
* `validation_init_skeleton_role_dir`: <'/tmp'> -- Absolute path of the directory where the skeleton will be deployed
* `validation_init_roles_dir`: <'roles'> -- Absolute/Relative path to the roles directory where the new roles will be created
* `validation_init_zuuld_molecule`: <'zuul.d/molecule.yaml'> -- Relative path to the CI molecule yaml file
* `validation_init_playbooks_dir`: <'playbooks'> -- Relative path to the playbooks directory where the new playbook will be created
* `validation_init_roles_doc_dir`: <'doc/source/roles'> -- Relative path to documentation roles directory
* `validation_init_enabling_ci`: <'true'> -- If 'true', documentation and CI configuration will be done, otherwise not
Dependencies
------------
None.
Example Playbook
----------------
- name: Create my new role
hosts: localhost
connection: local
gather_facts: false
roles:
- { role: validation_init, validation_init_role_name: "mynewrolename"}
License
-------
Apache
Author Information
------------------
Red hat TripleO DFG:DF Squad:VF

+ 28
- 0
roles/validation_init/defaults/main.yml View File

@ -0,0 +1,28 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# All variables intended for modification should place placed in this file.
# All variables within this role should have a prefix of "validation_init"
validation_init_debug: false
validation_init_prefix: "tripleo"
validation_init_skeleton_role_dir: "/tmp"
validation_init_roles_dir: "roles"
validation_init_zuuld_molecule: "zuul.d/molecule.yaml"
validation_init_playbooks_dir: "playbooks"
validation_init_roles_doc_dir: "doc/source/roles"
validation_init_enabling_ci: true

_skeleton_role_/defaults/main.yml.j2 → roles/validation_init/files/_skeleton_role_/defaults/main.yml.j2 View File


_skeleton_role_/handlers/main.yml → roles/validation_init/files/_skeleton_role_/handlers/main.yml View File


_skeleton_role_/molecule/default/converge.yml.j2 → roles/validation_init/files/_skeleton_role_/molecule/default/converge.yml.j2 View File


_skeleton_role_/molecule/default/molecule.yml → roles/validation_init/files/_skeleton_role_/molecule/default/molecule.yml View File


+ 25
- 0
roles/validation_init/files/_skeleton_role_/molecule/default/prepare.yml View File

@ -0,0 +1,25 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Add you own tasks to prepare the hosts for your tests
debug:
msg: >-
Installing package(s), create file(s), whatever you need here
in this file to prepare your test(s).

+ 24
- 0
roles/validation_init/files/_skeleton_role_/molecule/default/verify.yml View File

@ -0,0 +1,24 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Verify
hosts: all
gather_facts: false
tasks:
# This is an example playbook to execute your ansible tests.
- name: Example assertion
assert:
that: true

_skeleton_role_/tasks/main.yml.j2 → roles/validation_init/files/_skeleton_role_/tasks/main.yml.j2 View File


_skeleton_role_/vars/main.yml.j2 → roles/validation_init/files/_skeleton_role_/vars/main.yml.j2 View File


+ 62
- 0
roles/validation_init/molecule/default/converge.yml View File

@ -0,0 +1,62 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
gather_facts: false
tasks:
- name: Create new role
include_role:
name: validation_init
vars:
validation_init_role_name: skeleton_test
validation_init_prefix: "tripleo"
validation_init_skeleton_role_dir: "/tmp"
validation_init_roles_dir: "/tmp/roles"
validation_init_zuuld_molecule: "/tmp/zuul.d/molecule.yaml"
validation_init_playbooks_dir: "/tmp/playbooks"
validation_init_roles_doc_dir: "/tmp/doc/source/roles"
- name: Create a new role with the same name
block:
- name: Run the validation_init role again
include_role:
name: validation_init
vars:
validation_init_role_name: skeleton_test
validation_init_prefix: "tripleo"
validation_init_skeleton_role_dir: "/tmp"
validation_init_roles_dir: "/tmp/roles"
validation_init_zuuld_molecule: "/tmp/zuul.d/molecule.yaml"
validation_init_playbooks_dir: "/tmp/playbooks"
validation_init_roles_doc_dir: "/tmp/doc/source/roles"
rescue:
- name: Clear host error
meta: clear_host_errors
- name: Role addition output
debug:
msg: The Role works! End the playbook run
- name: End play
meta: end_play
- name: Fail the test
fail:
msg: |
The validation_init role didn't properly detect that the role name was
already been taken!

+ 3
- 0
roles/validation_init/molecule/default/molecule.yml View File

@ -0,0 +1,3 @@
---
# inherits tripleo-validations/.config/molecule/config.yml
# To override default values, please take a look at the config.yml.

+ 96
- 0
roles/validation_init/molecule/default/prepare.yml View File

@ -0,0 +1,96 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Install Ansible for getting ansible-galaxy
package:
name: ansible
state: installed
- name: Create roles directory
file:
path: /tmp/roles
state: directory
mode: '0755'
- name: Create playbooks directory
file:
path: /tmp/playbooks
state: directory
mode: '0755'
- name: Create roles doc directory
file:
path: /tmp/doc/source/roles
state: directory
mode: '0755'
- name: Create zuul.d directory
file:
path: /tmp/zuul.d/
state: directory
mode: '0755'
- name: Copy zuul.d/molecule.yaml
copy:
dest: /tmp/zuul.d/molecule.yaml
content: |
---
- project-template:
check:
jobs:
- tripleo-validations-centos-8-molecule-role_one
- tripleo-validations-centos-8-molecule-role_two
- tripleo-validations-centos-8-molecule-tripleo_undercloud_conf
gate:
jobs:
- tripleo-validations-centos-8-molecule-role_one
- tripleo-validations-centos-8-molecule-role_two
- tripleo-validations-centos-8-molecule-tripleo_undercloud_conf
name: tripleo-validations-molecule-jobs
- job:
files:
- ^roles/role_one/.*
- ^tests/prepare-test-host.yml
- ^ci/playbooks/pre.yml
- ^ci/playbooks/run.yml
name: tripleo-validations-centos-8-molecule-role_one
parent: tripleo-validations-centos-8-base
vars:
tripleo_validations_role_name: role_one
- job:
files:
- ^roles/role_two/.*
- ^tests/prepare-test-host.yml
- ^ci/playbooks/pre.yml
- ^ci/playbooks/run.yml
name: tripleo-validations-centos-8-molecule-role_two
parent: tripleo-validations-centos-8-base
vars:
tripleo_validations_role_name: role_two
- job:
files:
- ^roles/tripleo_undercloud_conf/.*
- ^tests/prepare-test-host.yml
- ^ci/playbooks/pre.yml
- ^ci/playbooks/run.yml
name: tripleo-validations-centos-8-molecule-tripleo_undercloud_conf
parent: tripleo-validations-centos-8-base
vars:
tripleo_validations_role_name: tripleo_undercloud_conf

+ 137
- 0
roles/validation_init/molecule/default/verify.yml View File

@ -0,0 +1,137 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Verify
hosts: all
gather_facts: false
vars:
new_role_path: "/tmp/roles/tripleo_skeleton_test"
new_zmol_path: "/tmp/zuul.d/molecule.yaml"
new_play_path: "/tmp/playbooks/tripleo-skeleton-test.yaml"
new_role_doc: "/tmp/doc/source/roles/role-tripleo_skeleton_test.rst"
tasks:
- name: Check new role directory is present
stat:
path: "{{ new_role_path }}"
register: roles_name_dir
- assert:
that:
- roles_name_dir.stat.exists
- roles_name_dir.stat.isdir
fail_msg: |
{{ new_role_path }} role directory doesn't exist.
success_msg: |
{{ new_role_path }} role directory does exist.
- name: Read zuul molecule file
slurp:
src: "{{ new_zmol_path }}"
register: molecule_yaml
- name: Print returned information
debug:
msg: "{{ molecule_yaml['content'] | b64decode }}"
- name: Check zuul molecule file content (gate/check definition)
lineinfile:
path: "{{ new_zmol_path }}"
regexp: '^.*- tripleo-validations-centos-8-molecule-skeleton'
insertbefore: '^.*name: tripleo-validations-molecule-tripleo_undercloud_conf'
line: ' - tripleo-validations-centos-8-molecule-skeleton_test'
state: present
check_mode: true
register: zuul_def
failed_when: (zuul_def is changed) or (zuul_def is failed)
- name: Check zuul molecule file content (job definition)
lineinfile:
path: "{{ new_zmol_path }}"
regexp: '^.*name: tripleo-validations-centos-8-molecule-skeleton'
insertbefore: '^.*parent: tripleo-validations-centos-8-base$'
line: ' name: tripleo-validations-centos-8-molecule-skeleton_test'
state: present
check_mode: true
register: zuul_job_def
failed_when: (zuul_job_def is changed) or (zuul_job_def is failed)
- name: Check new validation playbook is present
stat:
path: "{{ new_play_path }}"
register: play_name_path
- assert:
that:
- play_name_path.stat.exists
- play_name_path.stat.isreg
fail_msg: |
{{ new_play_path }} playbook doesn't exist.
success_msg: |
{{ new_play_path }} playbook directory does exist.
- name: Read new playbook file
slurp:
src: "{{ new_play_path }}"
register: playbook_yaml
- name: Check playbook content for new role
lineinfile:
path: "{{ new_play_path }}"
regexp: '.*- tripleo_skeleton: '
insertafter: '^.*roles:$'
line: ' - tripleo_skeleton_test'
state: present
check_mode: true
register: include_role
failed_when: (include_role is changed) or (include_role is failed)
- name: Print returned information
debug:
msg: "{{ playbook_yaml['content'] | b64decode }}"
- name: Check new role doc is present
stat:
path: "{{ new_role_doc }}"
register: role_doc_file
- assert:
that:
- role_doc_file.stat.exists
- role_doc_file.stat.isreg
fail_msg: |
{{ new_role_doc }} playbook doesn't exist.
success_msg: |
{{ new_role_doc }} playbook directory does exist.
- name: Read new role documentation file
slurp:
src: "{{ new_role_doc }}"
register: doc_file
- name: Print returned information
debug:
msg: "{{ doc_file['content'] | b64decode }}"
- name: Check role documentation content
lineinfile:
path: "{{ new_role_doc }}"
regexp: '.*:role: '
insertafter: '^\.\. ansibleautoplugin::$'
line: ' :role: /tmp/roles/tripleo_skeleton_test'
state: present
check_mode: true
register: doc
failed_when: (doc is changed) or (doc is failed)

+ 180
- 0
roles/validation_init/tasks/main.yml View File

@ -0,0 +1,180 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Check for role name
fail:
msg: >-
The required variable `role_name` is undefined. Check your settings.
when:
- validation_init_role_name is undefined
- name: Ensure role name is not empty
fail:
msg: >-
The required variable `role_name` is empty. Check your settings.
when:
- validation_init_role_name is defined
- validation_init_role_name == ''
- name: Normalize the role name
set_fact:
_role_name: "{{ validation_init_role_name | replace('-', '_' ) }}"
dashed_role_name: "{{ validation_init_role_name | replace('_', '-') }}"
- name: Copy Skeleton role directory
copy:
src: _skeleton_role_
dest: "{{ validation_init_skeleton_role_dir }}/"
mode: '0755'
- name: Check if the role name is available
stat:
path: "{{ validation_init_roles_dir }}/{{ validation_init_prefix }}_{{ _role_name }}"
register: new_roles_name_dir
- name: Fail if the new role name already exists in roles directory
assert:
that:
- not new_roles_name_dir.stat.exists|bool
fail_msg: |
{{ validation_init_prefix }}_{{ _role_name }} role does already exist :(
success_msg: |
{{ validation_init_prefix }}_{{ _role_name }} role doesn't exist! :)
- name: Create role
command: >-
ansible-galaxy init
--role-skeleton={{ validation_init_skeleton_role_dir }}/_skeleton_role_
--init-path="{{ validation_init_roles_dir }}/"
{{ validation_init_prefix }}_{{ _role_name }}
args:
creates: "{{ validation_init_roles_dir }}/{{ validation_init_prefix }}_{{ _role_name }}"
- name: Create overcloud deploy script
template:
src: README.md.j2
dest: "{{ validation_init_roles_dir }}/{{ validation_init_prefix }}_{{_role_name }}/README.md"
- name: Create the playbook
copy:
content: |
---
- hosts: undercloud
gather_facts: false
vars:
metadata:
name: Brief and general description of the validation
description: |
The complete description of this validation should be here
groups:
- backup-and-restore
- no-op
- prep
- pre-introspection
- pre-deployment
- post-deployment
- openshift-on-openstack
- pre-upgrade
- post-upgrade
- pre-system-upgrade
- post-system-upgrade
- pre-undercloud-upgrade
- post-undercloud-upgrade
- pre-overcloud-prepare
- post-overcloud-prepare
- pre-overcloud-upgrade
- post-overcloud-upgrade
- pre-overcloud-converge
- post-overcloud-converge
- pre-ceph
- post-ceph
- pre-update
- pre-update-prepare
- pre-update-run
- pre-update-converge
- post-update
{{ validation_init_prefix }}_{{ _role_name }}_debug: false
roles:
- {{ validation_init_prefix }}_{{ _role_name }}
dest: "{{ validation_init_playbooks_dir }}/{{ validation_init_prefix }}-{{ dashed_role_name }}.yaml"
- when: validation_init_enabling_ci | default(true) | bool
block:
- name: Read zuul molecule file
slurp:
src: "{{ validation_init_zuuld_molecule }}"
register: molecule_yaml
- name: Create molecule entry
copy:
content: |-
---
{% set items = molecule_yaml['content'] | b64decode | from_yaml %}
{% set job_index = [] %}
{% set new_job_name = "tripleo-validations-centos-8-molecule-" ~ _role_name %}
{% for item in items %}
{% if 'project-template' in item %}
{% if item['project-template']['name'] == "tripleo-validations-molecule-jobs" %}
{% if not (new_job_name in item['project-template']['check']['jobs']) %}
{% set _ = item['project-template']['check']['jobs'].append(new_job_name) %}
{% set check_jobs = (item['project-template']['check']['jobs'] | sort) %}
{% set _ = item['project-template']['check'].update({'jobs': check_jobs}) %}
{% endif %}
{% if not (new_job_name in item['project-template']['gate']['jobs']) %}
{% set _ = item['project-template']['gate']['jobs'].append(new_job_name) %}
{% set gate_jobs = (item['project-template']['gate']['jobs'] | sort) %}
{% set _ = item['project-template']['gate'].update({'jobs': gate_jobs}) %}
{% endif %}
{% endif %}
{% else %}
{% if item['job']['name'] == new_job_name %}
{% set _ = job_index.append(new_job_name) %}
{% endif %}
{% endif %}
{% endfor %}
{% if (job_index | length) < 1 %}
{% set new_job = {
"name": new_job_name,
"parent": "tripleo-validations-centos-8-base",
"files": [
"^roles/" ~ validation_init_prefix ~ "_" ~ _role_name ~ "/.*",
"^tests/prepare-test-host.yml",
"^ci/playbooks/pre.yml",
"^ci/playbooks/run.yml",
"^molecule-requirements.txt"
],
"vars": {
"tripleo_validations_role_name": validation_init_prefix ~ "_" ~ _role_name
}
}
%}
{% set _ = items.append({"job": new_job}) %}
{% endif %}
{{ items | to_nice_yaml(indent=2, width=1337) }}
dest: "{{ validation_init_zuuld_molecule }}"
- name: Create role documentation
copy:
content: |
{% set opening = _role_name %}
{{ '=' * (opening | length) }}
{{ opening }}
{{ '=' * (opening | length) }}
.. literalinclude:: ../../../roles/{{ validation_init_prefix }}_{{ _role_name}}/README.md
.. ansibleautoplugin::
:role: {{ validation_init_roles_dir }}/{{ validation_init_prefix }}_{{ _role_name }}
dest: "{{ validation_init_roles_doc_dir }}/role-{{ validation_init_prefix }}_{{ _role_name }}.rst"

+ 39
- 0
roles/validation_init/templates/README.md.j2 View File

@ -0,0 +1,39 @@
{{ role_name | replace('-', '_') | capitalize }}
{{ "%s" | format((role_name | replace('-', '_') | length) * "=") }}
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
* `{{ role_name | replace('-', '_') }}_debug`: <'false'> -- Debugging mode.
* ...
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: localhost
roles:
- { role: {{ role_name | replace('-', '_') }}, x: 42 }
License
-------
Apache
Author Information
------------------
Red hat TripleO DFG:<dfg_name> Squad:<squad_name>

+ 13
- 0
zuul.d/molecule.yaml View File

@ -26,6 +26,7 @@
- tripleo-validations-centos-8-molecule-undercloud_debug
- tripleo-validations-centos-8-molecule-undercloud_heat_purge_deleted
- tripleo-validations-centos-8-molecule-undercloud_tokenflush
- tripleo-validations-centos-8-molecule-validation_init
gate:
jobs:
- tripleo-validations-centos-8-molecule-ceph
@ -51,6 +52,7 @@
- tripleo-validations-centos-8-molecule-undercloud_debug
- tripleo-validations-centos-8-molecule-undercloud_heat_purge_deleted
- tripleo-validations-centos-8-molecule-undercloud_tokenflush
- tripleo-validations-centos-8-molecule-validation_init
name: tripleo-validations-molecule-jobs
- job:
files:
@ -534,3 +536,14 @@
parent: tripleo-validations-centos-8-base
vars:
tripleo_validations_role_name: check_for_dangling_images
- job:
files:
- ^roles/validation_init/.*
- ^tests/prepare-test-host.yml
- ^ci/playbooks/pre.yml
- ^ci/playbooks/run.yml
- ^molecule-requirements.txt
name: tripleo-validations-centos-8-molecule-validation_init
parent: tripleo-validations-centos-8-base
vars:
tripleo_validations_role_name: validation_init

Loading…
Cancel
Save