# Override hosts: in any playbook via command-line argument

**URL:** <https://forum.ansible.com/t/override-hosts-in-any-playbook-via-command-line-argument/18926>\
**Category:** Ansible Project\
**Created:** [August 3, 2015, 3:52pm UTC](https://forum.ansible.com/t/override-hosts-in-any-playbook-via-command-line-argument/18926 "2015-08-03T15:52:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Leonhardt](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Alex\_Leonhardt](https://forum.ansible.com/u/Alex_Leonhardt)\
**Post date:** [August 3, 2015, 3:52pm UTC](https://forum.ansible.com/t/override-hosts-in-any-playbook-via-command-line-argument/18926/1 "2015-08-03T15:52:48Z")

</div>

Hi,

How can I override the hosts: definition in any playbook ? I’ve got some playbooks that run against remote hosts, which I want to keep in the playbook, but need to be able to run /test it against “localhost” as well … I guess adding localhost would be an option, but I dont want it to run against the other hosts in that case - I found in some forums to use a --extra-vars “target=host” and use - hosts: “{{ target }}” but that would mean I have to update all my playbooks and how I’d run them …

Any suggestions ?

Thanks  
Alex
