- current host
inventory_hostname, and inventory_hostname_short
- current group
There isn't really a var that says, this is the current group being acted on, but per host has a 'groups' var containing all groups that host is a member of
- current user
Perhaps ansible_ssh_user ?
- current task
This is not exposed
- current role
This is not exposed
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/37134b03-c4e6-49df-91da-07e691d23310%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
We addressed the things you are talking about by treating each app as a host regardless of physical server and from there used host and groups vars, not roles for what you are trying to do. Essentially roles start with tasks and sometimes specialized modules. The variables and defaults are there to support those tasks. Recently I created a module that reads the properties file all of these application use for their configuration and imports them as facts so later roles and playbooks can remain in sync with little to no effort.
We did toy with something like your approach of wrapping application specific meta data as roles, but found that was messy and hard to manage. (Roles get checked in and treated like code, inventory not so much.)
So based on my experience I think your struggles are a modeling problem like Michael suggested.
<tim/>
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/519faf83-1f5c-4058-a189-0689ffe46905%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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 needto configure nginx properly to listen on that port.So we do this by doing:services[current_role].nginx_portBut do access current_role we had to set a variable for *every* role.
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0cc40dad-47d7-4c98-b1f0-2ba1de053e3f%40googlegroups.com.
"Ansible variables seem to have a global scope, because if I set one within the role it seems to be visible to all roles"No exactly true for roles.
Ansible variables set in one role are available in roles further down so you can have roles that describe an environment, but they do have scope. In fact, you are guaranteed access to that particular value, without it being clobbered.
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d913befd-afde-4c1c-86a6-ea41523eef39%40googlegroups.com.
I mean Roles utilized after other roles.
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/df308498-2df8-49f1-84b6-45e66b1ff357%40googlegroups.com.
" I actually saw behavior that looks like a role was getting a value for a variable set in a LATER role"
I am occasionally incorrect.Vars do get compiled down first, tasks run in order, as variables do run in order, but I'd expect that.
My apologies on not remembering correctly - I do think that's still fine due to the built-in protections around variable clobbering in roles (won't happen, etc).