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).
More on Inventory
What is an inventory and why does Ansible need one?BeginnerWhat are the INI and YAML inventory formats and how do they differ?BeginnerHow do you create groups of groups?BeginnerExplain host patterns: `:`, `:&`, `:!` and wildcards.IntermediateWhich connection variables can you set per host in inventory?BeginnerWhat are `group_vars` and `host_vars` directories?Intermediate