# How to get the ansible command line information like current tags, skip-tags, limit, etc?

**URL:** <https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453>\
**Category:** Ansible Project\
**Created:** [September 1, 2016, 3:40pm UTC](https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453 "2016-09-01T15:40:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jordan\_Cohen](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@Jordan\_Cohen](https://forum.ansible.com/u/Jordan_Cohen)\
**Post date:** [September 1, 2016, 3:40pm UTC](https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453/1 "2016-09-01T15:40:00Z")

</div>

I am integrating some automated slack messaging in ansible to inform on ansible runs and it would be useful to display information such as:

Current tags in push  
Current skip-tags in push  
Current limit (though I know i can use play\_hosts for listing the servers)

To be honest, the whole ansible command would be helpful. I am doing this with a local action shell now:

shell ps aux | grep ‘ansible-playbook’ | grep -v grep

…but besides it being very janky, this is unpredictable if there are multiple ansible-playbooks running on one host, like in my jenkins server.

I scanned all the built in vars that I know of for some of this information but no luck.

Thanks!

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 1, 2016, 4:06pm UTC](https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453/2 "2016-09-01T16:06:16Z")

</div>

Jordan,

Have you looked at the slack callback plugin that is already bundled with ansible?

In your ansible.cfg you would need to have something like:

[defaults]  
callback\_whitelist = slack

The docstring for the callback has information about what environment variables need to be set up for it to work:

[https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/callback/slack.py#L43-L56](https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/callback/slack.py#L43-L56)

To get it to display things like tags, skip tags, limit, etc…you will need to set SLACK\_INVOCATION=True

---

<div class="post-metadata">

**Author:** ![Jordan\_Cohen](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@Jordan\_Cohen](https://forum.ansible.com/u/Jordan_Cohen)\
**Post date:** [September 1, 2016, 4:26pm UTC](https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453/3 "2016-09-01T16:26:09Z")

</div>

The callback plugin is really nice, i didn’t know it existed.

For my purposes though, I would like to use the slack module so that I can more custom tailor the message, the channel to post to, and when to skip a slack message (for local/dev environments)

But thank you, this is cool.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 1, 2016, 4:30pm UTC](https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453/4 "2016-09-01T16:30:52Z")

</div>

So I guess to answer your question directly, there is no way to access tags, skip tags, limit and most other command line options from within a play.

It’s really only achievable via a callback.

---

<div class="post-metadata">

**Author:** ![epiq\_sty](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@epiq\_sty](https://forum.ansible.com/u/epiq_sty)\
**Post date:** [March 13, 2017, 2:33pm UTC](https://forum.ansible.com/t/how-to-get-the-ansible-command-line-information-like-current-tags-skip-tags-limit-etc/22453/5 "2017-03-13T14:33:25Z")

</div>

Hello!

I have the same issue with necessity of tags, limits, etc using slack as callback , and found strange thing:

If i set SLACK\_INVOCATION=True , nothing happens.

Actually, in ansible/plugins/callback/slack.py where is another dependency:

`  
def v2\_playbook\_on\_start(self, playbook):

self.playbook\_name = os.path.basename(playbook.\_file\_name)

title = [  
‘_Playbook initiated_ (_%s_)’ % self.guid  
]  
invocation\_items =   
------\>\> if self.\_options and self.show\_invocation:  
tags = self.\_options.tags  
skip\_tags = self.\_options.skip\_tags  
extra\_vars = self.\_options.extra\_vars  
subset = self.\_options.subset

`

And by default seem’s `self._options` set to none:

How I can properly set “self.\_options” to get all necessary details?

Now I found only one way , by hacking ansible/plugins/callback/slack.py with

`

def v2\_playbook\_on\_start(self, playbook):

self.playbook\_name = os.path.basename(playbook.\_file\_name)

title = [  
‘_Playbook initiated_ (_%s_)’ % self.guid  
]  
invocation\_items =   
------\>\> self.\_options = cli.options

if self.\_options and self.show\_invocation:  
tags = self.\_options.tags  
skip\_tags = self.\_options.skip\_tags  
extra\_vars = self.\_options.extra\_vars  
subset = self.\_options.subset

`

But I am sure, must been some other , better way here 😉  
Can anyone advise ?

Thanks in advance!

ps:  
`  
$ ansible --version  
ansible 2.2.1.0  
$ set | grep INV  
SLACK\_INVOCATION=True

`
