# Create Multiple Nginx Virtual Hosts with one Ansible role

**URL:** <https://forum.ansible.com/t/create-multiple-nginx-virtual-hosts-with-one-ansible-role/19938>\
**Category:** Ansible Project\
**Created:** [December 4, 2015, 3:11pm UTC](https://forum.ansible.com/t/create-multiple-nginx-virtual-hosts-with-one-ansible-role/19938 "2015-12-04T15:11:45Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [December 4, 2015, 3:11pm UTC](https://forum.ansible.com/t/create-multiple-nginx-virtual-hosts-with-one-ansible-role/19938/1 "2015-12-04T15:11:45Z")

</div>

Hi,

How I can Create Multiple Nginx Virtual Hosts with one Ansible role, can someone give me an idea?

Thanks,

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [December 4, 2015, 3:23pm UTC](https://forum.ansible.com/t/create-multiple-nginx-virtual-hosts-with-one-ansible-role/19938/2 "2015-12-04T15:23:17Z")

</div>

2 ways, have the role take a list of vhost configs and loop over them. Or have it take a single one and call it once per vhost.

---

<div class="post-metadata">

**Author:** ![Adithya\_Khamithkar](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Adithya\_Khamithkar](https://forum.ansible.com/u/Adithya_Khamithkar)\
**Post date:** [December 4, 2015, 3:36pm UTC](https://forum.ansible.com/t/create-multiple-nginx-virtual-hosts-with-one-ansible-role/19938/3 "2015-12-04T15:36:48Z")

</div>

You can name the virtual hosts differently and you can use the template function.
