Skip to content

Commit

Permalink
docs: add hint for verify playbook (#3222)
Browse files Browse the repository at this point in the history
* docs: add hint for verify playbook

As discussed in #3045, since the `verify.yml` playbook does not run the tested role, the `library` and `module_utils` provided by the tested role are not be available there [1].

Usually, one does not want to re-run the role in the `verify.yml` playbook since it was already run twice before.
One workaround suggested by @tadeboro is to add an empty task list to the role and then to restrict tasks of the role to this file when including it in the `verify.yml` playbook.
This PR adds a note regarding this to the docs.

[1]  (the `library` actually *is* currently available, but [this is an oversight](#3045 (comment)); the `module_utils` are not available.

* Update docs/getting-started.rst

* try fixing linter

* fix linter 2
  • Loading branch information
ltalirz committed Sep 2, 2021
1 parent 37bc4d8 commit b621839
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ directories:
allows you to write specific tests against the state of the container after
your role has finished executing. Other verifier tools are available (Note that :std:doc:`TestInfra <testinfra:index>` was the default verifier prior to molecule version 3).

.. note::

If the ``verify.yml`` playbook does not explicitly ``include_role`` your role, the ``library`` and ``module_utils``
provided by your role are not available in the playbook by default.
If you need those for testing but would like to avoid re-running your role, consider adding
an empty task file ``init.yml`` to your role and use ``tasks_from`` to include your role in the ``verify.yml`` playbook:

.. code-block:: yaml
- name: Verify
hosts: all
become: true
tasks:
- name: Initialize role without actually running it
include_role:
name: my_role
tasks_from: init
# Start testing: can use role library now
.. _Jinja2: http://jinja.pocoo.org/

Inspecting the ``molecule.yml``
Expand Down

0 comments on commit b621839

Please sign in to comment.