Files
tripleo-ansible/doc/source/contributing.rst
Kevin Carter 26ba107082 Add helper playbook to create new roles
A playbook has been added to the root of the project which will assist
developers in adding new roles to the project. The playbook will generate
a new role, create a tox entry, and setup zuul for independent CI.

This new playbook capability has been added to the contributing docs.

Change-Id: I726740e1c95b2f38fe7bae2e9a8f1e35feb5a7bf
Signed-off-by: Kevin Carter <kecarter@redhat.com>
2019-06-11 22:34:58 -05:00

1.9 KiB

Contributing

Adding roles into this project is easy and starts with a compatible skeleton.

From with the project root, creating a skeleton for the new role:

$ ansible-galaxy init --role-skeleton=_skeleton_role_ --init-path=tripleo_ansible/roles ${NEWROLENAME}

Once the new role has been created, and is ready for testing add the role into the tox.ini file as an test scenario.

[testenv:mol-${NEWROLENAME}]
basepython={[testenv:mol]basepython}
deps={[testenv:mol]deps}
changedir = {toxinidir}/tripleo_ansible/roles/${NEWROLENAME}
envdir = {toxworkdir}/mol
commands =
  python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py

When the role is ready for CI add a jobs entry into the `zuul.d/jobs.yaml`:

- job:
    name: tripleo-ansible-centos:mol-${NEWROLENAME}
    parent: tripleo-ansible-centos
    files:
    - ^tripleo_ansible/roles/${NEWROLENAME}/.*
    vars:
    tox_envlist: mol-${NEWROLENAME}

And finally add the job into the zuul.d/layout.yaml file:

- project:
    check:
    jobs:
        - tripleo-ansible-centos:mol-${NEWROLENAME}

The role addition process is also automated using ansible. If ansible is available on the development workstation change directory to the root of the tripleo-ansible repository and run the the following command which will perform all of the tasks noted above.

$ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME}

If this playbook is being executed from a virtual-environment be sure to activate the virtual environment before running the playbook.

$ . ~/bin/venvs/ansible/bin/activate
(ansible)$ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME}