Is there a plan to have 'only_if' at includes within tasks ?
I am passing the --extra-vars="product=theproduct" to the playbook. So
it makes it resuable for each product.
My tasks i have broken up completely into multiple incudes, which do
read the product specific tasks - which works great now btw. !
tasks:
...
- include: tasks/${product}.yml
...
There is a product i might like to skip one or more of theses include
statements:
Choices to achieve that would be:
- Give no tasks/theproduct.yml file.
=> brings directly a parser error: ERROR: file not found: tasks/
theproduct.yml
- place an empty file tasks/theproduct.yml
=> you get this error:
Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 108, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/bin/ansible-playbook", line 89, in main
pb.run()
File "/usr/lib/python2.6/site-packages/ansible/playbook/
__init__.py", line 152, in run
self._run_play(Play(self,play_ds))
File "/usr/lib/python2.6/site-packages/ansible/playbook/play.py",
line 81, in __init__
self._tasks = self._load_tasks(self._ds, 'tasks')
File "/usr/lib/python2.6/site-packages/ansible/playbook/play.py",
line 115, in _load_tasks
for y in data:
TypeError: 'NoneType' object is not iterable
- Use tags=theproduct
That would need to be the negative way to directly exclude the
'include' statement.
Otherwise everything else would need to be tagged positively which
isnt possible afaik.
- Have an 'only_if' attached to the include statement in tasks.
- Have a separate playbook - which is not the goal...
- Place a tasks/theproduct.yml file with action: echo foo (that
works btw.)