which tags are being used in runtime?

363 views
Skip to first unread message

Mauricio Castro

unread,
Aug 21, 2018, 11:11:28 AM8/21/18
to Ansible Project
Hello all, is there a way to know during playbook execution which tags it was called with in command line with -t ?

I mean given ansible-playbook -t x,y,z how do I know inside the playbook I am only executing tasks with those tags?


Thanks

Jonathan Lozada De La Matta

unread,
Aug 21, 2018, 11:27:15 AM8/21/18
to ansible...@googlegroups.com
either there's a tag: name in the playbook or in the tasks.

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e69261c8-44d6-4366-ae11-c258095af5b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan lozada de la matta

AUTOMATION CONSULTANT - AUTOMATION PRACTICE

Red Hat Consulting Services

jloz...@redhat.com   



 

Brian Coca

unread,
Aug 21, 2018, 4:40:25 PM8/21/18
to Ansible Project
ansible_run_tags


--
----------
Brian Coca

Mauricio Castro

unread,
Aug 23, 2018, 8:37:37 AM8/23/18
to Ansible Project
great! thanks a lot!

On Tuesday, August 21, 2018 at 5:40:25 PM UTC-3, Brian Coca wrote:
ansible_run_tags


--
----------
Brian Coca

Mauricio Castro

unread,
Aug 23, 2018, 8:46:51 AM8/23/18
to Ansible Project
- debug: var=ansible_run_tags
  tags: ['always']

is not giving me anything.

are you sure Brian?

thanks for the help.

Brian Coca

unread,
Aug 23, 2018, 8:50:08 AM8/23/18
to Ansible Project
it reflects tags used at runtime, not those defined on the task.

Mauricio Castro

unread,
Aug 23, 2018, 8:56:43 AM8/23/18
to ansible...@googlegroups.com
hummm, that's it:

I tried:

- debug: var=ansible_run_tags
tags: ['delete']

and I run:

ansible-playbook -t delete pb.yml

and I get:

TASK [debug] *************************************************************************************************************
ok: [localhost] => {
    "ansible_run_tags": "VARIABLE IS NOT DEFINED!"
}

wrong?

thanks.

Kai Stian Olstad

unread,
Aug 23, 2018, 9:30:04 AM8/23/18
to ansible...@googlegroups.com
On 23.08.2018 14:56, Mauricio Castro wrote:
> hummm, that's it:
>
> I tried:
>
> - debug: var=ansible_run_tags
> tags: ['delete']

Indentation of tags if off, you should add two spaces.


> and I run:
>
> ansible-playbook -t delete pb.yml
>
> and I get:
>
> TASK [debug]
> *************************************************************************************************************
> ok: [localhost] => {
> "ansible_run_tags": "VARIABLE IS NOT DEFINED!"
> }
>
> wrong?

It work an Ansible 2.6.3

--
Kai Stian Olstad

Mauricio Castro

unread,
Aug 23, 2018, 9:32:50 AM8/23/18
to ansible...@googlegroups.com
Identation was a e-mail body problem.

I think it should be my version. I will try to update it.

Thanks a lot.

Mauricio Castro

unread,
Aug 23, 2018, 9:45:03 AM8/23/18
to ansible...@googlegroups.com
Kai, thanks, it was my version 2.4.2, updated to 2.6.3.

Working now.

Thanks a lot to all.

Kai Stian Olstad

unread,
Aug 23, 2018, 9:48:43 AM8/23/18
to ansible...@googlegroups.com
On Thursday, 23 August 2018 15.32.37 CEST Mauricio Castro wrote:
> I think it should be my version. I will try to update it.

ansible_run_tags was added in 2.5.


--
Kai Stian Olstad


Reply all
Reply to author
Forward
0 new messages