# Excluding groups issue

**URL:** <https://forum.ansible.com/t/excluding-groups-issue/11892>\
**Category:** Ansible Project\
**Created:** [September 14, 2012, 2:19pm UTC](https://forum.ansible.com/t/excluding-groups-issue/11892 "2012-09-14T14:19:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [September 14, 2012, 2:19pm UTC](https://forum.ansible.com/t/excluding-groups-issue/11892/1 "2012-09-14T14:19:37Z")

</div>

Hi

Documentation says:

> You can exclude groups as well, for instance, all webservers not in Phoenix:  
> webservers:!phoenix

But when I do so, I get:

> [root@ansible playbooks]# ansible -o all:!webservers -u admin -k -K -m ping  
> bash: !webservers: event not found

To avoid this error, I have to escape exclamation mark:

> [root@ansible playbooks]# ansible -o all:!webservers -u admin -k -K -m ping

Perhaps this is mentioned somewhere, but I couldn’t find. So it’s just FYI 😉

Edgars

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 14, 2012, 2:43pm UTC](https://forum.ansible.com/t/excluding-groups-issue/11892/2 "2012-09-14T14:43:29Z")

</div>

You need to quote it for the shell

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [September 14, 2012, 2:47pm UTC](https://forum.ansible.com/t/excluding-groups-issue/11892/3 "2012-09-14T14:47:58Z")

</div>

Ok I got it. I tried to quote with doublequotes and it didn’t work, but it appears that I need to use singlequotes.

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [September 14, 2012, 6:00pm UTC](https://forum.ansible.com/t/excluding-groups-issue/11892/4 "2012-09-14T18:00:58Z")

</div>

> But when I do so, I get:
> 
> [root@ansible playbooks]# ansible -o all:!webservers -u admin -k -K -m ping  
> \> bash: !webservers: event not found

If you don't feel like escaping each '!', I'd

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set +o histexpand

H which disables !-style history substitution. This  
option is on by default when the shell is interactive."

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP
