In this case "fred" is the key to the exports dictionary. It can't be
both the key and the entry itself. Try something like:
{{ fred }}
{{ exports[fred].options }}
On Sun, Nov 23, 2014 at 6:35 AM, Stephen Tan <[email protected]> wrote:
> Hi - I'm doing something which seems very simple - trying to create a file
> from a jinja template.
>
> Here are my vars:
>
> export_root:
> host: "81.187.209.128/27"
> options: "rw,fsid=0,insecure,no_subtree_check,async"
> exports:
> video:
> host: "81.187.209.128/27"
> options: "rw,nohide,insecure,no_subtree_check,async"
> shared_dir: "/mnt/video"
>
> Here is the template which I'm using the test var fred:
>
> {{export_root_dir}} {{export_root.host}}({{export_root.options}})
> {% for fred in exports %}
> {{ fred }}
> {{ fred.options }}
> {% endfor %}
>
> For some reason, fred.options fails with:
>
> fatal: [althea.home.stanandliz.net] => {'msg': "One or more undefined
> variables: 'str object' has no attribute 'options'", 'failed': True}
> fatal: [althea.home.stanandliz.net] => {'msg': "One or more undefined
> variables: 'str object' has no attribute 'options'", 'failed': True}
>
> I have no idea why this should be the case. When I access fred, the template
> prints fine. It's when I try to access the dictionary in fred that I fail.
>
> I'm sure there is a very simple fix to this, but after about an hour, I just
> can't get this to work. Can I have a few debugging clues?
>
> many thanks in advance
>
> Stephen
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0b1cdc31-1ab2-449b-a91f-6f138cc5516c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAJQqANe0OnsF4p0hS%3DThju0QiXeeCFdheFhJ1YCjB2mDneAx6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.