gpt4 book ai didi

python - 本地事实(facts.d)和安装模块

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:48:20 25 4
gpt4 key购买 nike

我在/etc/ansible/facts.d/mount.fact 中创建了以下本地事实文件:

[
{
"name": "/mastersystem",
"src": "/dev/sda1",
"fstype": "ext3",
"state": "mounted",
"opts": "defaults"
}

]

当我尝试将这些事实用于挂载模块时

- name: mount filesystem 
mount:
name="{{ item }}.name"
src="{{ item }}.src"
fstype="{{ item }}.fstype"
state="{{ item }}.state"
opts="{{ item }}.opts"
with_items:
"{{ ansible_local.mount }}"

我遇到了这样的错误

failed: [127.0.0.1] => (item={u'src': u'/dev/sda1', u'state': u'mounted', u'name': u'/mastersystem', u'opts': u'defaults', u'fstype': u'ext3'}) => {"failed": true, "item": {"fstype": "ext3", "name": "/mastersystem", "opts": "defaults", "src": "/dev/sda1", "state": "mounted"}} msg: value of state must be one of: present,absent,mounted,unmounted, got: {u'src': u'/dev/sda1', u'state': u'mounted', u'name': u'/mastersystem', u'opts': u'defaults', u'fstype': u'ext3'}.state

任何其他尝试都会导致类似的错误。知道我做错了什么吗?

最佳答案

我自己发现错误:它必须是 "{{ item.state }}" 而不是 "{{ item }}.state"

关于python - 本地事实(facts.d)和安装模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34433674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com