# read hosts from another file

**URL:** <https://forum.ansible.com/t/read-hosts-from-another-file/13374>\
**Category:** Ansible Project\
**Created:** [August 28, 2013, 2:35am UTC](https://forum.ansible.com/t/read-hosts-from-another-file/13374 "2013-08-28T02:35:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [August 28, 2013, 2:35am UTC](https://forum.ansible.com/t/read-hosts-from-another-file/13374/1 "2013-08-28T02:35:19Z")

</div>

Hi,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 28, 2013, 2:57am UTC](https://forum.ansible.com/t/read-hosts-from-another-file/13374/2 "2013-08-28T02:57:08Z")

</div>

Yes.

You can do ansible-playbook -e @parameters.yml, where variables will be loaded on the command line.

Alternatively, and this is the original way, you could do -e “servers=all”.

The other thing to look into is “–limit”, where you just keep the server value as what you have, and “–limit” selects a subset of the original, for example

ansible-playbook foo.yml --limit boston

If foo.yml originally targetted “all webservers”, this would only target webservers that were also in the group “boston”

In what you have based above, one minor syntax tweak. You should have:

hosts: “{{ servers }}”

As otherwise YAML will see the “{” and suspect you are starting a hash value.

---

<div class="post-metadata">

**Author:** ![celine](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@celine](https://forum.ansible.com/u/celine)\
**Post date:** [August 28, 2013, 3:27am UTC](https://forum.ansible.com/t/read-hosts-from-another-file/13374/3 "2013-08-28T03:27:51Z")

</div>

Hi Michael,

Thank you for your reply. I tried:  
hosts: ‘{{servers}}’

It works too. Is there any difference between using single or double quote?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [August 28, 2013, 10:15am UTC](https://forum.ansible.com/t/read-hosts-from-another-file/13374/4 "2013-08-28T10:15:07Z")

</div>

Not in that case, the yaml parser doesn’t treat them differently.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 28, 2013, 12:48pm UTC](https://forum.ansible.com/t/read-hosts-from-another-file/13374/5 "2013-08-28T12:48:30Z")

</div>

There’s no difference.

–Michael
