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.