Matt's answer above is slightly incorrect. Things like "always_run" and such are keywords, not variables that are usable in scripts.
http://ansibleworks.com/docs/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts (The statement about their being other variables is not accurate and will be removed next time docs are pushed, I have that queued up right now) You should also look into facts: http://ansibleworks.com/docs/playbooks_variables.html#id17 I think if you need a variable that defines your current role, it's probably the sign of a modeling problem -- with a few possible exceptions. The role shouldn't have to know what it's name is to operate correctly. On Mon, Dec 30, 2013 at 10:35 AM, Matt Martz <[email protected]> wrote: > Here are the ones that I can recall and easily find in the source: > > vars > always_run > changed_when > delegate_to > failed_when > ignore_errors > inventory_dir > playbook_dir > register > > The vars variable, is a dictionary, that contains all of the above vars as > key/value pairs. > > inventory_file > inventory_hostname_short > inventory_hostname > ansible_ssh_user > hostvars > group_names > groups > defaults > environment > > Also, anything from --extra_vars, host_vars/, group_vars/, facts.d/, > register, etc... > > Some of this is mentioned on < > http://www.ansibleworks.com/docs/playbooks_variables.html> , pay some > special attention to < > http://www.ansibleworks.com/docs/playbooks_variables.html#id22> > > But to address some of your specifics: > > - 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 > > -- > Matt Martz > [email protected] > > On December 30, 2013 at 8:54:53 AM, [email protected] > ([email protected]<//[email protected]>) > wrote: > > Does Ansible provide predefined variables to use in scripts? I am looking > for variables like: > - current host > - current group > - current user > - current task > - current role > etc. > > I have not found these variables among these from "gathering facts". > -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Michael DeHaan <[email protected]> CTO, AnsibleWorks, Inc. http://www.ansibleworks.com/ -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
