Hi Matt,
Thanks for your thorough and quick answer. We'll look into it and let you
know the result.
On Friday, January 26, 2018 at 12:44:02 PM UTC-3, Matt Martz wrote:
>
> the `reverse` argument for `dictsort` was not added until jinja2 v2.10
> which was released on Nov 8, 2017
>
> Ansible has a dependency on jinja2, but does not dictate which specific
> version you should have installed. To get access to that feature you will
> need to upgrade your version of jinja2
>
> You may be able to use the `reverse` filter instead, but I have not
> tested: http://jinja.pocoo.org/docs/dev/templates/#reverse
>
> On Fri, Jan 26, 2018 at 9:35 AM, Martin Cigorraga > wrote:
>
>> Hi everyone,
>>
>> We are using a Jinja2 template to populate a configuration file, based on
>> the information Ansible feeds it on runtime:
>>
>> ### Main Processes
>>
>> {% for k, v in some_conf | dictsort() %}
>>
>> cmdline -c /etc/some_tool/some_agent-{{ k }}.conf -o /var/log/
>> some_tool/some_agent.log
>>
>> {% endfor %}
>>
>>
>> We get a predictable output thanks to using dictsort():
>>
>> % cat /etc/some_tool/some_agent.conf
>>
>> cmdline -c some_agent-AAA.conf -o /var/log/some_tool/some_agent.log
>>
>>
>> cmdline -c some_agent-BBB.conf -o /var/log/some_tool/some_agent.log
>>
>>
>>
>> Thing is we need in the above configuration file that some_agent-BBB.conf is
>> placed *before* than some_agent-AAA.conf; for that matter I introduced
>> the *reverse=True* argument to dictsort():
>>
>> ### Main Processes
>>
>> {% for k, v in some_conf | dictsort(*reverse=True*) %}
>>
>> cmdline -c /etc/some_tool/some_agent-{{ k }}.conf -o /var/log/
>> some_tool/some_agent.log
>>
>> {% endfor %}
>>
>>
>> When tested using Yasha (https://github.com/kblomqvist/yasha), the
>> output is the expected one:
>>
>> % cat /etc/some_tool/some_agent.conf
>>
>> cmdline -c some_agent-BBB.conf -o /var/log/some_tool/some_agent.log
>>
>>
>> cmdline -c some_agent-AAA.conf -o /var/log/some_tool/some_agent.log
>>
>>
>>
>> However, when running the playbook, Ansible complains and stops
>> execution, showing the error message I put on the subject of this email:
>> *do_dictsort()
>> got an unexpected keyword argument 'reverse'*
>>
>> Why're running *ansible 2.1.1.0*.
>> Thanks!
>>
>> --
>> 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/a7bebf32-fb5e-4829-acac-8a8d3a12c91d%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/a7bebf32-fb5e-4829-acac-8a8d3a12c91d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Matt Martz
> @sivel
> sivel.net
>
--
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/62a5e3af-8512-4dd4-95f0-f69cf5311be1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.