local facts (facts.d) and mount module

33 views
Skip to first unread message

Marten Bauer

unread,
Jan 5, 2016, 1:58:31 PM1/5/16
to Ansible Project
Hey,

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 the 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?

- debug: var=ansible_local.mount before the task above results in:

 TASK: [system_init_stage_2 | debug var=ansible_local] ************************* 
ok: [127.0.0.1] => {
    "var": {
        "ansible_local": {
            "grub": {
                "install_device": "/dev/sda"
            }, 
            "mount": [
                {
                    "fstype": "ext3", 
                    "name": "/mastersystem", 
                    "opts": "defaults", 
                    "src": "/dev/sda1", 
                    "state": "mounted"
                }
            ], 
            "system": [
                "backupsystem"
            ]
        }
    }
}

Brian Coca

unread,
Jan 5, 2016, 2:09:39 PM1/5/16
to Ansible Project
try this:

- name: mount filesystem
mount:
name="{{ item.name}}"
src="{{ item.src}}"
fstype="{{ item.fstype}}"

etc ...
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/448971bf-3acb-48a5-8779-902e300b86d7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages