Merge "Normalize role names when generating roles"

This commit is contained in:
Zuul 2020-01-21 22:28:29 +00:00 committed by Gerrit Code Review
commit 60851c8447
1 changed files with 16 additions and 11 deletions

View File

@ -26,13 +26,17 @@
when: when:
- role_name is undefined - role_name is undefined
- name: Normalize the role name
set_fact:
_role_name: "{{ role_name | replace('-', '_' ) }}"
- name: Create role - name: Create role
command: >- command: >-
ansible-galaxy init ansible-galaxy init
--role-skeleton=_skeleton_role_ --role-skeleton=_skeleton_role_
--init-path=roles {{ role_name }} --init-path=tripleo_validations/roles/{{ _role_name }}
args: args:
creates: "roles/{{ role_name }}" creates: "tripleo_validations/roles/{{ _role_name }}"
- name: Read zuul molecule file - name: Read zuul molecule file
slurp: slurp:
@ -45,7 +49,7 @@
--- ---
{% set items = molecule_yaml['content'] | b64decode | from_yaml %} {% set items = molecule_yaml['content'] | b64decode | from_yaml %}
{% set job_index = [] %} {% set job_index = [] %}
{% set new_job_name = "tripleo-validations-centos-7-molecule-" ~ role_name %} {% set new_job_name = "tripleo-validations-centos-7-molecule-" ~ _role_name %}
{% for item in items %} {% for item in items %}
{% if 'project-template' in item %} {% if 'project-template' in item %}
{% if item['project-template']['name'] == "tripleo-validations-molecule-jobs" %} {% if item['project-template']['name'] == "tripleo-validations-molecule-jobs" %}
@ -67,10 +71,10 @@
"name": new_job_name, "name": new_job_name,
"parent": "tripleo-validations-centos-7-base", "parent": "tripleo-validations-centos-7-base",
"files": [ "files": [
"^roles/" ~ role_name ~ "/.*" "^tripleo_validations/roles/" ~ _role_name ~ "/.*"
], ],
"vars": { "vars": {
"tripleo_validations_role_name": role_name "tripleo_role_name": _role_name
} }
} }
%} %}
@ -100,10 +104,11 @@
- name: Create role documentation - name: Create role documentation
copy: copy:
content: | content: |
{{ '=' * (role_name | length) }} {% set opening = 'Role - ' ~ _role_name %}
{{ role_name }} {{ '=' * (opening | length) }}
{{ '=' * (role_name | length) }} {{ opening }}
{{ '=' * (opening | length) }}
.. ansibleautoplugin:: .. ansibleautoplugin::
:role: roles/{{ role_name }} :role: tripleo_validations/roles/{{ _role_name }}
dest: "doc/source/roles/role-{{ role_name }}.rst" dest: "doc/source/roles/role-{{ _role_name }}.rst"