Sorry to put again a bockinfile issue, but regarding the cases before, i don't think, this is similar to them. How can i use key/value pair, to return a unique key/value in the output file for each host. Using the playbook mentioned bellow, it loops the key/value and returns just the same key/value in all outputs
- hosts: all
gather_facts: yes
become: yes
tasks:
- blockinfile:
create: yes
path: /root/hardware_report
block: |
hostname: "{{inventory_hostname}}"
total_mem: "{{ansible_memtotal_mb}}"
bios_version: "{{ansible_bios_version}}"
device_size: "{{ansible_devices.nvme0n1.size | default ('NONE')}}"
device_size: "{{ansible_devices.nvme1n1.size | default ('NONE')}}"
"{{item.key}}: {{item.value}}" # (the line main of my issue)
with_dict: {a: 1, b: 2, c: 3, d: 4}
Expected_outputs: host1:
# BEGIN ANSIBLE MANAGED BLOCK
hostname: "node6"
total_mem: "966"
bios_version: "1.0"
vda_size: "20.00 GB"
vdb_size: "2.00 GB"
"b: 2"
# END ANSIBLE MANAGED BLOCK
host2:
# BEGIN ANSIBLE MANAGED BLOCK
hostname: "node6"
total_mem: "966"
bios_version: "1.0"
vda_size: "20.00 GB"
vdb_size: "2.00 GB"
"d: 4"
# END ANSIBLE MANAGED BLOCK