# hosts syntax?

**URL:** <https://forum.ansible.com/t/hosts-syntax/34189>\
**Category:** Ansible Project\
**Created:** [November 12, 2020, 4:18pm UTC](https://forum.ansible.com/t/hosts-syntax/34189 "2020-11-12T16:18:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [November 12, 2020, 4:18pm UTC](https://forum.ansible.com/t/hosts-syntax/34189/1 "2020-11-12T16:18:19Z")

</div>

Normally in my playbooks I say “hosts: all”. For a new playbook I want to say “hosts: !A,!B”, but that is not a valid syntax. What is the syntax to exclude two hosts (not in a group)?

Mike

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 12, 2020, 5:01pm UTC](https://forum.ansible.com/t/hosts-syntax/34189/2 "2020-11-12T17:01:01Z")

</div>

You need something to negate

hosts: all:!A:!B

FYI all hosts are always in at least 2 groups, 'all' being always one  
of them, if no other group is assigned 'ungrouped' becomes the 2nd.

---

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [November 12, 2020, 5:07pm UTC](https://forum.ansible.com/t/hosts-syntax/34189/3 "2020-11-12T17:07:36Z")

</div>

Duh, thank you.

Mike
