How to specify tag with molecule test #2449
Replies: 5 comments 2 replies
-
I'd like to see this added as well |
Beta Was this translation helpful? Give feedback.
-
I guess only molecule |
Beta Was this translation helpful? Give feedback.
-
Had the same issue and solved it by creating a separate scenario for which I define default tags. This is done by adding * links to Molecule v2 documentation, but is perfectly valid for current Molecule v3 (which's documentation is crap) as well provisioner:
name: ansible
# Either via config option
config_options:
tags:
run: tag1,tag2,tag3
# or env
env:
ANSIBLE_RUN_TAGS: tag1,tag2,tag3 Assuming your scenario is called ---
- name: Converge
hosts: all
tasks:
- debug:
msg: This message appears because of either tag1, tag2 or tag3
tags:
- tag1
- tag2
- tag3
- debug:
msg: This message should not appear
tags:
- tag-not-defined-in-default-tag-list
- debug:
var: ansible_run_tags
tags:
- always Then PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [instance]
TASK [debug] *******************************************************************
ok: [instance] => {
"msg": "This message appears because of either tag1, tag2 or tag3"
}
TASK [debug] *******************************************************************
ok: [instance] => {
"ansible_run_tags": [
"tag1",
"tag3",
"tag2"
]
}
PLAY RECAP *********************************************************************
instance : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Beta Was this translation helpful? Give feedback.
-
Tags are also applied to create which makes molecule-podman not work. |
Beta Was this translation helpful? Give feedback.
-
Hi This issue would be addressed in ansible-community/molecule-plugins#120 and #3866. |
Beta Was this translation helpful? Give feedback.
-
Hello,
is there a way to specify tag when executing molecule test ( ex molecule test -- --tags foo,bar ) ?
apparently, it works only with molecule converge ( molecule converge -- tags foo,bar )
Beta Was this translation helpful? Give feedback.
All reactions