Normalize role names when generating roles
Roles can no longer have a "-" in them according to the upstream ansible documentation[0]. This change ensures that we're no longer generating roles that have a "-" within them. The role-addition.yml playbook will now normalize the name and replace any "-" with an "_". [0] https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#roles-directory Change-Id: Id36a15da4cf83697250c81e1650a9639f590b87f Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
b45d4c6d21
commit
c3d86e2a93
@ -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=tripleo_ansible/roles {{ role_name }}
|
--init-path=tripleo_ansible/roles {{ _role_name }}
|
||||||
args:
|
args:
|
||||||
creates: "tripleo_ansible/roles/{{ role_name }}"
|
creates: "tripleo_ansible/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-ansible-centos-7-molecule-" ~ role_name %}
|
{% set new_job_name = "tripleo-ansible-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-ansible-molecule-jobs" %}
|
{% if item['project-template']['name'] == "tripleo-ansible-molecule-jobs" %}
|
||||||
@ -71,10 +75,10 @@
|
|||||||
"name": new_job_name,
|
"name": new_job_name,
|
||||||
"parent": "tripleo-ansible-centos-7-base",
|
"parent": "tripleo-ansible-centos-7-base",
|
||||||
"files": [
|
"files": [
|
||||||
"^tripleo_ansible/roles/" ~ role_name ~ "/.*"
|
"^tripleo_ansible/roles/" ~ _role_name ~ "/.*"
|
||||||
],
|
],
|
||||||
"vars": {
|
"vars": {
|
||||||
"tripleo_role_name": role_name
|
"tripleo_role_name": _role_name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
@ -89,11 +93,11 @@
|
|||||||
- name: Create role documentation
|
- name: Create role documentation
|
||||||
copy:
|
copy:
|
||||||
content: |
|
content: |
|
||||||
{% set opening = 'Role - ' ~ role_name %}
|
{% set opening = 'Role - ' ~ _role_name %}
|
||||||
{{ '=' * (opening | length) }}
|
{{ '=' * (opening | length) }}
|
||||||
{{ opening }}
|
{{ opening }}
|
||||||
{{ '=' * (opening | length) }}
|
{{ '=' * (opening | length) }}
|
||||||
|
|
||||||
.. ansibleautoplugin::
|
.. ansibleautoplugin::
|
||||||
:role: tripleo_ansible/roles/{{ role_name }}
|
:role: tripleo_ansible/roles/{{ _role_name }}
|
||||||
dest: "doc/source/roles/role-{{ role_name }}.rst"
|
dest: "doc/source/roles/role-{{ _role_name }}.rst"
|
||||||
|
Loading…
Reference in New Issue
Block a user