$ 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