-
Notifications
You must be signed in to change notification settings - Fork 302
nginx role doesn't work with with_items #164
Comments
Ok, I've read more about this issue and it turns out that roles are not supposed to work with with_items. So, to rephrase my question: I have central nginx reverse proxy, and list of "hosts". Is there a way to set everything up using ansible-role-nginx, such that when I add new host to some configuration file, proxy vhost will be added to nginx automatically? |
Can you explain more about what the end result configuration would look like? i.e. do you need a separate server block for each host? Are the proxy back-end servers the same for each host you want to add? |
I'm rather flexible at exact configuration format. I thought about configuring hosts like that (websrv and website are my role names):
What I want to achieve is end result, and that should be: nginx instance on web.lxc, with two vhosts:
and two additional nginx instances (but that should be easy):
Hard part (at least for me) is using ansible-role-nginx with dynamically generated list of sites. |
@philipwigg I think I have a same problem. How can optimize this config? I need for many vhosts a similar configuration.
|
I got bitten by the same problem, and just came up with a simple solution for the problem (via patch, that's it). Let's assume that we might extend de configuration with this 'alias', so any of the sites defined can use a var instead of the hardcoded name:
In this example, I'd use site_80 and site_443 as hardcoded placeholders, but I could optionaly add the If you omit the The patch needed for this to work would be:
|
(sorry I just made a diff because. I'm not working with the more recent version, I fear) |
i was stumbling on some same requirements, after a while of thinkering i came up with something working:
the template looks like:
this is what ends up on my server:
and some file content:
\o/ maybe this is of help |
I'm new to ansible, but I feel like this should work:
But instead the result is:
Is this something wrong with my config? Or is this specific to ansible-role-nginx?
(I understand that my rule is recursive for some reason, but I don't understand why)
The text was updated successfully, but these errors were encountered: