Hi All,
I am trying to append multiple values in same cell csv but not getting through.Could someone help here?
Current output:
Hostname Disk Info
testserver sdd: 1.00 Gbsde: 1.00 Gb
Expected output:
Hostname Disk Info
testserver sdd: 1.00 Gb
sde: 1.00 Gb
Playbook:
-
set_fact:
my_devices: “{{ ansible_devices.keys()|select(‘match’, ‘^sd(.*)$’)|list }}” -
name: show templating results
set_fact:
disk_size: “{{ lookup(‘template’, ‘template-test.j2’) }}” -
set_fact:
csv_data: “{{ inventory_hostname }}, {{ disk_size }}” -
lineinfile:
path: /tmp/disks_info.csv
insertafter: EOF
line: “{{ csv_data }}”
create: yes
state: present
mode: 0777
connection: local
Template:
{%- for dev in my_devices -%}
{{ dev }}: {{ ansible_devices[dev].size }}
{%- endfor -%}
regards
Kumar