I need to list the target host's name and IP address using set_fact. Below is my playbook, but it's giving error.
hosts: all
tasks:
- set_fact:
data: "{{ ansible_all_ipv4_addresses }}"
- set_fact:
ip: "{{ data.split(',') }}"
- name: Show the devices
shell: echo {{ item }} >> /tmp/ips
with_items: "{{ blockdevices }}"
Desired o/p is
host1 : 172.168.1.21
system2: 172.168.1.22
Anybody help me to fix this pls ? thanks in advance