I am facing error while executing below ansible playbook. I don't know what I am missing, in with_items
Trying to retrieve disk details using gather_subset module and partition each disk that is available in the file system by looping into the var
Error Message:
fatal: [localhost]: FAILED! => {"msg": "'dict object' has no attribute 'list'"}
Playbook:
---
- hosts: localhost
become: true
gather_facts: false
tasks:
- name: Collect Disk Information
setup:
gather_subset:
- hardware
- name: Print disks Details
debug:
var: hostvars[inventory_hostname].ansible_devices.keys()| list
- name: Create Partition
parted:
device: "{{ item }}"
number: 1
part_type: 'primary'
state: present
with_items: "{{ disks.list[0] }}"
Print disk details task is printing below
TASK [Print disks Details] ***************************************************************************************************
ok: [localhost] => {
"hostvars[inventory_hostname].ansible_devices.keys()| list": [
"xvdf",
"xvdb",
"xvdc",
"xvda"
]
}