Valid INI format in local facts

423 views
Skip to first unread message

sandra....@googlemail.com

unread,
Nov 14, 2014, 3:14:21 AM11/14/14
to ansible...@googlegroups.com
Hi,

I'm newbie using Ansible (1.7.2) and try to write my first local fact using INI. According to Wikipedia (http://en.wikipedia.org/wiki/INI_file#Format), a INI file with only key-value pairs is a valid INI format.

Example:

foo=bar

So my local fact /etc/ansible/facts.d/test.fact has only key-value pairs. Calling ansible localhost -m setup -a "filter=ansible_local" returns following error

localhost | success >> {
    "ansible_facts": {
        "ansible_local": {
            "test": "error loading fact - please check content"
        }
    },
    "changed": false
}

My expectation is the following output

localhost | success >> {
    "ansible_facts": {
        "ansible_local": {
            "test": {
              "foo": "bar"
            }
        }
    },
    "changed": false
}

When I add in my local fact a section like

[section]
foo=bar

then no error is thrown.

So my question is, is it a bug or a conscious decision for not supporting only key-value pairs or is the wikipedia article wrong?

Regards,

Sandra

Toshio Kuratomi

unread,
Nov 16, 2014, 11:04:48 AM11/16/14
to ansible...@googlegroups.com
Ini is not a standardized format so many things about it are defined
by implementation. In our case, we're using configparser from the
python stdlib which will be present on all platforms where ansible
runs. Requiring a top-level section is a feature of configparser:

"The configuration file consists of sections, led by a [section]
header and followed by name: value entries,"

-https://docs.python.org/2/library/configparser.html
> --
> 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/b9c75993-1a9b-409f-8ead-a08aad69baaa%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

sandra....@googlemail.com

unread,
Nov 18, 2014, 7:01:04 AM11/18/14
to ansible...@googlegroups.com
Thank you for the explanation.
Reply all
Reply to author
Forward
0 new messages