On Tuesday, July 1, 2014 10:19:16 AM UTC-7, John Anderson wrote:
>
> So we configure a pool for all the nodes in the addressbookweb group to
> listen on nginx port 6014, and then when a request to
> /addressbook comes into the loadbalancer it routes to that specific pool.
> But when we setup the addressbook nodes we also need
> to configure nginx properly to listen on that port.
>
> So we do this by doing:
>
> services[current_role].nginx_port
>
> But do access current_role we had to set a variable for *every* role.
>
How about this?
# roles/anonweb/tasks/main.yml
{ include: ../../../roles/pythonapp/tasks/main.yml, app_role: anonweb }
# roles/addressbookweb/tasks/main.yml
{ include: ../../../roles/pythonapp/tasks/main.yml, app_role:
addressbookweb }
# ../../../roles/pythonapp/tasks/main.yml
# do stuff nginx config stuff with {{ app_role }}
Ansible variables seem to have a global scope, because if I set one within
the role it seems to be visible to all roles (which surprised me as I was
expecting roles to be more self-contained since they're supposed to be
reusable, shared on Galaxy, etc.). All roles are referencing the same named
variable are sharing the same global variable. But the parameterized roles
and parameterized includes are more akin to parameter passing and so the
state is not shared.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0cc40dad-47d7-4c98-b1f0-2ba1de053e3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.