简体   繁体   中英

local facts (facts.d) and mount module

I create the following local facts file in /etc/ansible/facts.d/mount.fact:

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

]

when I try to use this facts for mount module like

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

I got an error like

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

Any other tries are resulting in similar errors. Any idea what I did wrong?

我一个人发现了错误:它必须是"{{ item.state }}"而不是"{{ item.state }}" "{{ item }}.state"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM