How to register with local_action?

2,081 views
Skip to first unread message

Pierre Thibault

unread,
Sep 11, 2013, 7:04:39 PM9/11/13
to ansible...@googlegroups.com
I am trying to create a new variable from a local action:

- name: Get ansible host directory
  local_action: command /usr/bin/dirname $ENV(ANSIBLE_HOSTS)
  register: host_vars_dir
  sudo: False

But when I try to use the variable "host_vars_dir" in the none local action of my playbook, it seems that the variable does not exists.

Do you know how can I access its value?

Romeo Theriault

unread,
Sep 11, 2013, 7:53:25 PM9/11/13
to ansible...@googlegroups.com
Might want to take a look at the debug module:


and running ansible-playbook with verbose (e.g. -vvv):

e.g. 
- name: Get ansible host directory
  local_action: command /usr/bin/dirname $ENV(ANSIBLE_HOSTS)
  register: host_vars_dir
  sudo: False

- name: See what we got
 debug: msg="heres what we gots {{ host_vars_dir.stdout }}

Note: Untested :)



--
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.
For more options, visit https://groups.google.com/groups/opt_out.



--
Romeo

Michael DeHaan

unread,
Sep 12, 2013, 1:42:48 PM9/12/13
to ansible...@googlegroups.com
You can just run with -v too


Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Reply all
Reply to author
Forward
0 new messages