Blacklisting hosts of a group in inventory file

9 views
Skip to first unread message

chavali shruti

unread,
Nov 20, 2019, 10:46:20 PM11/20/19
to Ansible Development
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.

Paul Belanger

unread,
Nov 21, 2019, 7:48:36 AM11/21/19
to ansibl...@googlegroups.com
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:

[foobar]
example1
example2
example3

[disabled]
example2

Then in our playbooks we do the following:

- hosts: foobar:!disabled
tasks:
...

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

- Paul

Reply all
Reply to author
Forward
0 new messages