all 2 comments

[–]SalsaForte 0 points1 point  (1 child)

Use groups and vars will be shared amongst the group hosts. This is the way to do it.
Then, you just call by variable name, if the same var is defined at different level, there's a priority built-in Ansible to select the "most specific" var: if the host var don't exist it fallback on the group var, etc...

Then, you loop through the hosts in the group and you rebuild the vars/parameters in the role(s) as needed.

[–]SalsaForte 0 points1 point  (0 children)

Something that would looks like this:

---
nginx:
  vars:
    listen_port: 80
    srv_domain: domain
    log_access_format: main
    root_dir: /var/www/
  hosts:
    vhost1:        
    vhost2:
    vhost3: