Thanks for the input, but that is something that would solve my
requirement only partially.

What I wanted to do was more along the lines of (as someone has
already pointed out, tags do not seem to be exposed in a run):

- name: Run this only and only if the tag was defined
  debug: msg="I am tagged, therefore I run"
  when: myspecialtag in ansible_tags
  tags:
    - myspecialtag

For now I think I would need to stick to the --extra-vars in combination
with --tags.

Perhaps a better description of what I want to do is to be able to
rerun handlers only as needed in order to have a way to clean-up
certain broken runs ("meta"-code provided below):

- name: Run handlers only
  include: ../handlers/main.yml
  when: handlers in ansible_tags
  tags:
    - handlers

Best regards

On Tue, 15 Mar 2016 18:15:32 +0100
Jean-Yves LENHOF <[email protected]> wrote:

> If I understand correctly what you want...
> 
> ansible-playbook myplaybook.yml --tags=myspecialtag is what you're 
> looking for...
> 
> A tag can be use in more than one task...
> 
> The doc :
> http://docs.ansible.com/ansible/playbooks_tags.html
> 
> 
> Regards,
> 
> 
> Le 2016-03-15 13:08, Branko Majic a écrit :
> > Hello folks,
> > 
> > Is it possible to use tags as a variable inside of playbook?
> > 
> > Specifically, I would like to have a condition to execute certain task
> > only if a tag has been defined.
> > 
> > I am aware this can be done with an --extra-vars option + checking for
> > variable instead, but I wanted to see if I could abuse the tags system
> > a bit to make the syntax less verbose/clearer.
> > 
> > Best regards
> > 
> > --
> > Branko Majic
> > Jabber: [email protected]
> > Please use only Free formats when sending attachments to me.
> > 
> > Бранко Мајић
> > Џабер: [email protected]
> > Молим вас да додатке шаљете искључиво у слободним форматима.
> 



-- 
Branko Majic
Jabber: [email protected]
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: [email protected]
Молим вас да додатке шаљете искључиво у слободним форматима.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20160315182328.0ec0508b%40zetkin.primekey.se.
For more options, visit https://groups.google.com/d/optout.

Reply via email to