I wrote a playbook/roles to create list of vhost on a webserver.
I have a big dict describing all the sites. It's not easily maintainable and I would like to define each vhost in a separate vars file and loop on these files. But I don't really know how to do this.
Here is my actual code:
- name: "Create domain configuration"
include_role:
name: webserver/domain
loop: "{{ list_domains | dict2items }}"
loop_control:
loop_var: domain
With the dict definition :
list_domains:
domain1:
server_name: "domain1.com"
server_alias:
- "domain1.fr"
certificate:
method: "webroot"
php_custom_values:
memory_limit: "128M"
database:
type: "mysql"
cms:
type: "prestashop"
domain2:
server_name: domain2.com
php_custom_values:
memory_limit: "512M"
The goal is to have a directory with domain1.yml and domain2.yml with the domains definitions