1

我在 /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 }}"

我有一个错误,比如

失败:[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: state 的值必须是以下之一: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 '}。状态

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

4

1 回答 1

1

我自己发现了错误:它必须"{{ item.state }}"代替"{{ item }}.state"

于 2016-01-05T09:03:21.417 回答