【发布时间】:2021-05-03 18:10:17
【问题描述】:
我在执行下面的 ansible playbook 时遇到错误。我不知道我错过了什么,with_items
尝试使用gather_subset 模块检索磁盘详细信息,并通过循环进入var 对文件系统中可用的每个磁盘进行分区
错误信息:
fatal: [localhost]: FAILED! => {"msg": "'dict object' has no attribute 'list'"}
剧本:
---
- 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] }}"
打印磁盘详细信息下面正在打印任务
TASK [Print disks Details] ***************************************************************************************************
ok: [localhost] => {
"hostvars[inventory_hostname].ansible_devices.keys()| list": [
"xvdf",
"xvdb",
"xvdc",
"xvda"
]
}
【问题讨论】:
标签: ansible