I am using ansible-runner with a Click CLI application. I am using the run function to execute my playbooks in the project directory.
I am using some skip-tags to execute specific tasks and skips some other.
Programatically,
from ansible_runner import run
conf = {
'private_data_dir': '.', # in root dir
'playbook': 'some_playbook.yml',
}
if some_click_option:
conf['cmdline'] = '--skip-tags=tagA'
out, rc = run(**conf)
The core logic is sound and works, however the root directory creates the env/cmdline file.
Since he env/cmdline contains the --skip-tags=tagA persists the playbook seems to skips the tasks upon execution even when my CLI doesn’t set the specific option.
Any smart way to purge the env/cmdline post execution?
The only way I can come around is remove the file based on the return code rc value.