The value of register can not be a variable.  You must statically define it
such as:

register: cange

Additionally, 'register' works a little differently with loops such as
with_items.  See <
http://docs.ansible.com/playbooks_loops.html#using-register-with-a-loop>

On Sat, Nov 15, 2014 at 10:33 AM, Can Shen <[email protected]> wrote:

> now . I  has run two comands  and register the  two variable , when I call
> the variable , the variable Unavailable (undefined)
>
> flowing is my  playbook:
>
> ---
>  - hosts: 127.0.0.1
>    connection: local
>    tasks:
>     - name: test
>       shell: df -{{ item.command }}
>       register: "{{ item.res }}"
>       with_items:
>         - { command: h, res: cange }
>         - { command: i, res: cange1 }
>
>     - name: xxx1
>       shell: echo "{{ cange.results[0].stdout }}" >/tmp/xxx
>
>     - name: xxx2
>       shell: echo "{{ cange1.results[0].stdout }}" >/tmp/xxx1
>
> the error information:
>
> TASK: [xxx1]
> ******************************************************************
> fatal: [127.0.0.1] => One or more undefined variables: 'cange' is undefined
>
> FATAL: all hosts have already failed -- aborting
>
>
> Who can help me !   thank you  very much.
>
>  --
> 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/736a3855-7636-4220-98e7-9366e0211c04%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/736a3855-7636-4220-98e7-9366e0211c04%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
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/CAD8N0v-6SZjvag6ELgt8aUJtc9qMMXQjJu5OQpfuAb99qSrcHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to