How do you run a playbook against only a subset of hosts?

BeginnerConceptInventory
Answer

Use --limit (or -l), which intersects with the play's hosts.

ansible-playbook site.yml --limit web1
ansible-playbook site.yml --limit 'web:!web3'
ansible-playbook site.yml --limit @failed_hosts.txt

--limit @file reads host names from a file, useful to retry only failed hosts, which Ansible writes to a .retry file when retry_files_enabled is set (off by default).

All Ansible questions Roadmap: Ansible

More on Inventory