Hello team,
I am trying to register variable /setfacts and use it in jinja2 template for printing the output but it says variable not define , Please can yo suggest something what is missing
========================Playbook =====================
---
- name: WinRM Test
hosts: all
tasks:
- name: WinRMPing
ping:
register: out
- name: debug
debug: var=out
- name: debug
debug:
msg: "{{ out.ping }}"
- name: setfacts
set_fact: mysnapshotname11="{{ out.ping }}"
- name: debug
debug:
msg: "{{ mysnapshotname11 }}"
- name: CSV File Output
delegate_to: localhost
template:
src: generate_csv.j2
dest: winping_info.csv
=========================
Jinja 2
[root@closvl2058 /]# cat generate_csv.j2
# generate_csv.j2
HostName, PingFailed
{% for each in groups['winupdates'] %}
#{{ hostvars[each].inventory_hostname }}, {{hostvars[each].mysnapshotname11 }}
{{ hostvars[each].mysnapshotname11 }}
{% endfor %}