Generally speaking, a role shouldn't change behavior based on it's name, and this would become confusing if role dependencies were used (should the dependent role set thename, etc)
So basically you can't do this, but you could do a - set_fact: role_name="xxx" if you wanted or something like that. On Fri, Jul 25, 2014 at 7:13 AM, jepper <[email protected]> wrote: > I'm sure this is dead simple, but googling seems hard since most posts > contain the words "role" and "variable"! > > I have versioned playbooks. I would like to stick a file somewhere on the > target system that explains what role was used, a time stamp, and a > version. I use maven as it happens. I thought I could something like this: > > roles/install_iod_base/tasks/pom.yml > - name: copy the pom for this trunk/branch/tag > copy: src=../../../../pom.xml dest=~/pom.xml-{{ ansible_date_time.date > }}-{{ ansible_date_time.time }} mode=0644 > > I would like to include this snippet in all my roles, and therefore it > would be useful to have something like > > copy: src=../../../../pom.xml dest=~/pom.xml-*{{ ansible_role }}*-{{ > ansible_date_time.date }}-{{ ansible_date_time.time }} mode=0644 > > How can I enumerate the current roles name? > > -- > 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/8865c77e-9e5f-4695-b643-cb1a17281d79%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/8865c77e-9e5f-4695-b643-cb1a17281d79%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CA%2BnsWgybXP7iK9c6%2BmOZ_d9qy73FtJWAuFo1LPDkdKGyohe-YA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
