On 06/12/2013 05:09, Gonzalo Servat wrote:
> I actually ran into this requirement today. For example:
>
> roles:
> - { role: network_config, tags: netconf }
>
> Inside that role, I might have a bunch of tasks defined that I want to
> run only for a particular tag so ideally I'd like to be able to specify:
>
> ansible-playbook .... -t netconf:ifcfg -t netconf:routes
>
> ... to run all tasks tagged with 'ifcfg' or 'routes', or I can choose to
> run all tasks in the network_config role:
>
> ansible-playbook .... -t netconf
>
> Can't do that with the current state of Ansible, right?
AFAIK no. As a workaround, in 'foo' role, I define tag 'foo' everywhere,
then 'foo:install', 'foo:config', 'foo:bar', 'install', 'config', 'bar'
... where appropriate, so I can execute a '-t config' to configure
roles only, or '-t foo:config' to configure foo role only, etc...
This is tedious but I don't think there is another way.
Set operations other than the current 'union' could be great (run all
tasks with tag X and Y, run all tasks except those with tags X) :
install only some roles, run only configuration steps for all roles
(skipping not apt/yum long operations), ...
Another neat feature would be to tag all tasks for a role (e.g. set the
tag 'foo' for all plays in role foo). I don't think this is actually
possible (?), something like (tasks/main.yml) :
- { include: install.yml, set_tags: [ 'foo', 'install' ] }
- { include: config.yml, set_tags: [ 'foo', 'config' ] }
M
--
Michel Blanc
{ :github => "@leucos", :twitter => "@b9m", :gpg => "0X24B35C22" }