What is the easiest way to skip some role tasks when I perform functional testing using Ansible Molecule?
Asked
Active
Viewed 6,416 times
2 Answers
11
There are two tags you can use which are implicit when code is run by molecule notest
and molecule-notest
.
Example:
- name: my task
tags: notest
shell: sudo rm -rf /

sorin
- 161,544
- 178
- 535
- 806
-
And if you want to run the task only when testing with molecule and skip it otherwise you can have a conditional like this: `when: '"molecule-notest" in ansible_skip_tags'` – gardar Feb 24 '22 at 11:26
4
You can use the additional command line arguments to the ansible-playbook command to skip tags like this:
molecule converge -- --skip-tags="<your role>"
To use this option you have to tag your task first as https://stackoverflow.com/a/57216583/7066745 indicates
Source: https://molecule.readthedocs.io/en/latest/usage.html

Moises Barba Perez
- 51
- 7