With command line patterns, you can specify patterns like "all,!ntpservers" but I can't figure out how to specify this in a playbook. I'm regularly running into cases where I have to install a client on all machines except the server.
Asked
Active
Viewed 3.2k times
11
-
What do you mean you can't figure out? You need to type it in. Alternatively please point to the line in the docs that makes it hard for you to understand. https://docs.ansible.com/ansible/devel/user_guide/intro_patterns.html – techraf Jul 16 '18 at 19:59
-
you mean inside the playbook? – dkokmadis Jul 16 '18 at 20:07
1 Answers
21
You specify the hosts for a playbook on the line that begins with hosts:
.
From the documentation:
The
hosts
line is a list of one or more groups or host patterns, separated by colons, as described in the Working with Patterns documentation.
For example:
---
- hosts: all,!ntpservers
tasks:
# ... your tasks here
roles:
# ... etc etc etc
These roles and tasks will be appled to all
hosts except ntpservers
.
Michael Hampton
- 237,123
- 42
- 477
- 940
-
1I'll add more detail to the question. This method ignores the !ntpservers on my installation of ansible 2.5.3. – Robert Rapplean Jul 17 '18 at 17:14
-
@RobertRapplean Probably best if you post a new question. Changing the meaning of a question after it's been answered is a great way to confuse everyone. – Michael Hampton Jul 17 '18 at 17:16