This patch migrates the new role addition playbook into a proper Ansible role with proper molecule tests. This new role will be responsible for creating a new validation. It is good to mention that the process won't change and it will be fully transparent for the user. To create a new role in tripleo-validations: $ cd tripleo-validations/ $ export ANSIBLE_ROLES_PATH="${PWD}/roles" $ ansible-playbook -i localhost, role-addition.yml -e validation_init_role_name=${NEWROLENAME} Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com> Change-Id: I219f4054e6b854306719b9c91a0738c526f07666changes/77/791977/15
parent
b2986a111b
commit
83ba5e32fd
@ -0,0 +1,8 @@
|
||||
===============
|
||||
validation_init
|
||||
===============
|
||||
|
||||
.. literalinclude:: ../../../roles/validation_init/README.md
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:role: roles/validation_init
|
@ -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
|
@ -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
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2020 Red Hat, Inc.
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2020 Red Hat, Inc.
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2020 Red Hat, Inc.
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
@ -1,6 +1,3 @@
|
||||
---
|
||||
# inherits tripleo-validations/.config/molecule/config.yml
|
||||
# To override default values, please take a look at the config.yml.
|
||||
|
||||
driver:
|
||||
name: podman
|
@ -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).
|
@ -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
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2020 Red Hat, Inc.
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# Copyright 2020 Red Hat, Inc.
|
||||
# Copyright 2021 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
@ -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!
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
# inherits tripleo-validations/.config/molecule/config.yml
|
||||
# To override default values, please take a look at the config.yml.
|
@ -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
|
@ -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)
|
@ -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"
|
@ -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>
|
Loading…
Reference in new issue