# Blacklisting hosts of a group in inventory file

**URL:** <https://forum.ansible.com/t/blacklisting-hosts-of-a-group-in-inventory-file/31696>\
**Category:** Ansible Developer\
**Created:** [November 21, 2019, 3:46am UTC](https://forum.ansible.com/t/blacklisting-hosts-of-a-group-in-inventory-file/31696 "2019-11-21T03:46:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chavali\_shruti](https://avatars.discourse-cdn.com/v4/letter/c/9fc348/32.png) [@chavali\_shruti](https://forum.ansible.com/u/chavali_shruti)\
**Post date:** [November 21, 2019, 3:46am UTC](https://forum.ansible.com/t/blacklisting-hosts-of-a-group-in-inventory-file/31696/1 "2019-11-21T03:46:20Z")

</div>

Suppose I want to blacklist a host of a group, in the inventory file, so as not to allow the running of any other tasks on it. How can i do it?  
I do want it in my hosts list and later, after i run a playbook on it… i want to blacklist it, so that others cannot run on it.

---

<div class="post-metadata">

**Author:** ![Paul\_Belanger](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@Paul\_Belanger](https://forum.ansible.com/u/Paul_Belanger)\
**Post date:** [November 21, 2019, 12:48pm UTC](https://forum.ansible.com/t/blacklisting-hosts-of-a-group-in-inventory-file/31696/2 "2019-11-21T12:48:27Z")

</div>

We create a disabled group in our inventory file, that we add hosts to  
when we want to blacklist them for some reason. For example:

&nbsp;&nbsp;&nbsp;&nbsp;[foobar]  
&nbsp;&nbsp;&nbsp;&nbsp;example1  
&nbsp;&nbsp;&nbsp;&nbsp;example2  
&nbsp;&nbsp;&nbsp;&nbsp;example3

&nbsp;&nbsp;&nbsp;&nbsp;[disabled]  
&nbsp;&nbsp;&nbsp;&nbsp;example2

Then in our playbooks we do the following:

&nbsp;&nbsp;&nbsp;&nbsp;- hosts: foobar:!disabled  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...

This would be example1 and example3 would run, but example2 would not.

- Paul
