On 11.06.2019 19:39, Douglas Thompson wrote:
> I'm working on an ansible role and instead of putting all tasks in
> tasks/main.yml, I'd like to have separate files and use them sort of like
> functions. One of my files has all the possible tasks for file manipulation
> in a separate file. The thought would be to use tags to execute one of the
> tasks in that file.
>
> In the example below I've put all the file manipulation tasks in a file
> called 'reboot_me_file.yml and would like to call just one task in main.yml
> when I need it. For example, 'reboot_me_file.yml' has three tagged tasks
> (create a file, stat a file, delete a file) and during the main.yml play,
> there will be a task, that includes say the 'create a file' task. I've
> looked at the following URL and it sounds like I can call a tagged task in
> the 'reboot_me_file.yml', but when I run the playbook, it executes all the
> tasks in 'reboot_me_file.yml'
>
>
https://docs.ansible.com/ansible/latest/modules/include_tasks_module.html#include-tasks-module
> (It says this should be available in ansible 2.7 but not which version of
> 2.7)
All tags in a file is always added to the task, at this level it is not a filter.