Update the _skeleton_ role for proper file generation

This change updates the _skeleton_ role so that the files it generates are
properly formatted. When a new role is generated the resulting code will
now pass all linting checks by default. Before this change several files,
which were assumed to be needing modification by the developer, would fail
lint checks right after generation due to newline issues at the end of the
file.

A test has been added to ensure the role generation process produces
minimally functional role that is 100% compliant.

Change-Id: I28526b022b8c2b5281d2a536231ebcac3b0a7662
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2019-06-19 08:38:15 -05:00
parent eb3dd70fc9
commit 7ce3a92ff5
No known key found for this signature in database
GPG Key ID: CE94BD890A47B20A
7 changed files with 26 additions and 0 deletions

View File

@ -19,3 +19,4 @@
# All variables within this role should have a prefix of "{{ role_name }}"
{{ role_name }}_debug: false

View File

@ -42,3 +42,4 @@ galaxy_info:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@ -35,3 +35,4 @@ RUN easy_install {{ pkg }}
{% endraw %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

View File

@ -19,3 +19,4 @@
hosts: all
roles:
- role: "{{ role_name }}"

View File

@ -16,6 +16,7 @@
# "{{ role_name }}" will search for and load any operating system variable file
{% raw %}
# found within the "vars/" path. If no OS files are found the task will skip.
- name: Gather variables for each operating system
include_vars: "{{ item }}"
@ -30,3 +31,4 @@
- "{{ ansible_os_family | lower }}.yml"
tags:
- always
{% endraw %}

10
tox.ini
View File

@ -104,6 +104,16 @@ ignore = D001
[testenv:venv]
commands = {posargs}
[testenv:role-addition]
basepython={[testenv:mol]basepython}
deps=
{[testenv:mol]deps}
{[testenv:linters]deps}
commands =
bash -c "ansible-playbook -i localhost, role-addition.yml -e role_name=skeleton_test"
bash -c "pushd {toxinidir}/tripleo_ansible/roles/skeleton_test; molecule test --all; popd"
{[testenv:linters]commands}
[testenv:mol] # environment naming scheme "mol-$ROLE_NAME"
# basepython forces tox to use system python and avoid other
# python versions like pyenv ones

View File

@ -6,12 +6,14 @@
- tripleo-ansible-centos-7-molecule-test_deps
- tripleo-ansible-centos-7-molecule-test_package_action
- tripleo-ansible-centos-7-molecule-tuned
- tripleo-ansible-centos-7-role-addition
gate:
jobs:
- tripleo-ansible-centos-7-molecule-aide
- tripleo-ansible-centos-7-molecule-test_deps
- tripleo-ansible-centos-7-molecule-test_package_action
- tripleo-ansible-centos-7-molecule-tuned
- tripleo-ansible-centos-7-role-addition
name: tripleo-ansible-molecule-jobs
- job:
files:
@ -42,3 +44,11 @@
parent: tripleo-ansible-centos
vars:
tox_envlist: mol-tuned
- job:
files:
- ^_skeleton_role_/.*
- ^role-addition.yml
name: tripleo-ansible-centos-7-role-addition
parent: tripleo-ansible-centos
vars:
tox_envlist: role-addition