If that path is not taking on the 1.8.X series, please do.   Thanks!


On Thu, Nov 27, 2014 at 3:34 AM, Ilin Tatabitovski <[email protected]>
wrote:

> Hi Branko,
>
> Thanks for the reply, I got it working.
>
> What was different in my case is that the folder was named "filters".
> I renamed it to "filter_plugins" and it works fine now.
>
> I also noticed that the setting
> http://docs.ansible.com/intro_configuration.html#filter-plugins
> in the config file has no effect. I may open issue on github.
>
> Regards,
> ilin
>
>
> On 26 November 2014 at 23:01, Branko Majic <[email protected]> wrote:
>
>> On Wed, 26 Nov 2014 08:58:48 -0800 (PST)
>> Ilin <[email protected]> wrote:
>>
>> > Hi,
>> >
>> > Is there a good example how to extend ansible with custom jinja filters?
>> >
>> > I have added this, but my filter is not found
>> > http://docs.ansible.com/intro_configuration.html#filter-plugins
>> >
>> > Adding the function to core.py works, but it just looks wrong
>> >
>> >
>>
>> As it turns out, I played around a bit with this just a couple of weeks
>> ago, and it's quite simple.
>>
>> The easiest way is to simply create a directory where your top-level
>> playbook is (site.yml?) called filter_plugins. Within that directory
>> you simply put .py files with content similar to (----%---- is just to
>> show where file begins/ends, don't copy that :):
>>
>> ----%----
>> def uppercase_all(arg):
>>     return arg.upper()
>>
>>
>> class FilterModule(object):
>>     def filters(self):
>>         return {'uppercase_all': uppercase_all}
>> ----%----
>>
>> With the above in place, you can simply use the filter uppercase_all
>> within your playbooks, roles etc. Note that you don't necessarily need
>> to have the same name for function and filter, but it's probably better
>> to do it that way.
>>
>> If you look at the page you posted, it will direct you to
>> http://docs.ansible.com/developing_plugins.html which describes most of
>> I wrote (although, in a bit of a less verbose way, and without
>> examples).
>>
>> I hope this helps.
>>
>> Best regards
>>
>> --
>> Branko Majic
>> Jabber: [email protected]
>> Please use only Free formats when sending attachments to me.
>>
>> Бранко Мајић
>> Џабер: [email protected]
>> Молим вас да додатке шаљете искључиво у слободним форматима.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/A7fGX-7X-ks/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/20141126230152.52d18fcb%40zetkin.primekey.se
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> G+ :: https://plus.google.com/+IlinTatabitovski
>
> --
> 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/CAEibsVCGQmugycum7xG3hKBiuV0w01P3%2BRUMfZiU6U9%2BR6fUeQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAEibsVCGQmugycum7xG3hKBiuV0w01P3%2BRUMfZiU6U9%2BR6fUeQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> 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/CA%2BnsWgwiu3z9Gc1W%2BxPsp6S1PVc43%3D1S-7VuzN6vDQ7GphsN3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to