root of hg tree?

17 views
Skip to first unread message

Roy Smith

unread,
Dec 20, 2014, 12:07:44 PM12/20/14
to ansible...@googlegroups.com
I want to set a playbook variable to the root of my hg tree, i.e. capture the output of the "hg root" command run on my local host.  How do I do that?

J Hawkesworth

unread,
Dec 21, 2014, 9:27:17 AM12/21/14
to ansible...@googlegroups.com
'register' and perhaps 'set_fact' are probably what you need - here's an example:

$ cat set_fact.yml
---
- hosts: linux
  tasks
:
 
- name: call a command to get some output...
    command
: "echo somecomandoutput"
    delegate_to
: localhost
   
register: result

# debug statements very handy for seeing what's in your registered variables.
 
- debug: var=result


# now use set_fact to put the var into a fact.
 
- name: set fact based on output of previous command
    set_fact
:
      my_hg_root
: "{{result.stdout_lines[0]}}"

# debug just to show the value is now in the fact
 
- debug: var=my_hg_root

Reply all
Reply to author
Forward
0 new messages