String alignments

78 views
Skip to first unread message

Gopal Chatla

unread,
Dec 23, 2019, 7:26:29 AM12/23/19
to ansible...@googlegroups.com
Hi Team,

I am redirecting debug messages output to a '' Txt" file using jinja2 templating alignment( by replacing extra strings ). Basically I want to send that file contents to email but output is not looking decent.

Is there any way to include python script in ansible playbook for string alignments. Suggestions please.

Thanks, 
Gopal 

Vladimir Botka

unread,
Dec 23, 2019, 9:11:16 AM12/23/19
to Gopal Chatla, ansible...@googlegroups.com
On Mon, 23 Dec 2019 17:56:07 +0530
Gopal Chatla <gopal....@gmail.com> wrote:

> Is there any way to include python script in ansible playbook for string
> alignments?

Try "Filter plugins"
https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html#filter-plugins

Cheers,

-vlado

alicia

unread,
Dec 23, 2019, 1:08:58 PM12/23/19
to ansible...@googlegroups.com, Gopal Chatla
There are already several filters for text - maybe an existing one would do what you need? You can look at https://docs.ansible.com/ansible/devel/user_guide/playbooks_filters.html for some pointers.

Hope this helps,
Alicia

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20191223151103.3f9e60e4%40gmail.com.

Gopal Chatla

unread,
Dec 26, 2019, 4:51:28 AM12/26/19
to alicia, ansible...@googlegroups.com
I've created a variable from stdout_lines and the contents are copied into a file through blockinfile module along with jinja template for loop.

The for loop iterates 40 lines. But how do add new line after every 10 lines in jinja template for loop. Like a excel sheet. 

Thanks, Gopal

Stefan Hornburg (Racke)

unread,
Dec 26, 2019, 10:52:28 AM12/26/19
to ansible...@googlegroups.com
On 12/26/19 10:51 AM, Gopal Chatla wrote:
> I've created a variable from stdout_lines and the contents are copied into a file through blockinfile module along with
> jinja template for loop.
>
> The for loop iterates 40 lines. But how do add new line after every 10 lines in jinja template for loop. Like a excel
> sheet. 
>
> Thanks, Gopal

Please elaborate on what is your real objective. Without any further information it seems quite futile to me to guess
your problem.

Regards
Racke

>
> On Mon, 23 Dec 2019, 23:38 alicia, <aco...@redhat.com <mailto:aco...@redhat.com>> wrote:
>
> There are already several filters for text - maybe an existing one would do what you need? You can look
> at https://docs.ansible.com/ansible/devel/user_guide/playbooks_filters.html for some pointers.
>
> Hope this helps,
> Alicia
>
>> On Dec 23, 2019, at 8:11 AM, Vladimir Botka <vbo...@gmail.com <mailto:vbo...@gmail.com>> wrote:
>>
>> On Mon, 23 Dec 2019 17:56:07 +0530
>> Gopal Chatla <gopal....@gmail.com <mailto:gopal....@gmail.com>> wrote:
>>
>>> Is there any way to include python script in ansible playbook for string
>>> alignments?
>>
>> Try "Filter plugins"
>> https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html#filter-plugins
>>
>> Cheers,
>>
>> -vlado
>>
>> --
>> 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 <mailto:ansible-project%2Bunsu...@googlegroups.com>.
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAAAxneczwYbky9axjhYtTSCo6_B-udFChps44UVkX4nzvz00Yg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAAAxneczwYbky9axjhYtTSCo6_B-udFChps44UVkX4nzvz00Yg%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Gopal Chatla

unread,
Dec 27, 2019, 4:58:12 AM12/27/19
to ansible...@googlegroups.com
I am using jinja2 expressions to iterate a 40 lines list. Basically my objective is, how do I iterate first 10 lines In first column and there after another 10 lines in second column? 

Thanks, 
Gopal 

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a7bb4ee5-a574-8108-49d5-66709f9673f5%40linuxia.de.

Stefan Hornburg (Racke)

unread,
Dec 27, 2019, 5:03:31 AM12/27/19
to ansible...@googlegroups.com
On 12/27/19 10:57 AM, Gopal Chatla wrote:
> I am using jinja2 expressions to iterate a 40 lines list. Basically my objective is, how do I iterate first 10 lines In
> first column and there after another 10 lines in second column? 
>
> Thanks, 
> Gopal 
>

Do you mind to share your playbook / tasks and a sample for the list?

Regards
Racke

> On Thu, 26 Dec 2019, 21:22 Stefan Hornburg (Racke), <ra...@linuxia.de <mailto:ra...@linuxia.de>> wrote:
>
> On 12/26/19 10:51 AM, Gopal Chatla wrote:
> > I've created a variable from stdout_lines and the contents are copied into a file through blockinfile module along
> with
> > jinja template for loop.
> >
> > The for loop iterates 40 lines. But how do add new line after every 10 lines in jinja template for loop. Like a excel
> > sheet. 
> >
> > Thanks, Gopal
>
> Please elaborate on what is your real objective. Without any further information it seems quite futile to me to guess
> your problem.
>
> Regards
>             Racke
>
> >
> > On Mon, 23 Dec 2019, 23:38 alicia, <aco...@redhat.com <mailto:aco...@redhat.com> <mailto:aco...@redhat.com
> <mailto:aco...@redhat.com>>> wrote:
> >
> >     There are already several filters for text - maybe an existing one would do what you need? You can look
> >     at https://docs.ansible.com/ansible/devel/user_guide/playbooks_filters.html for some pointers.
> >
> >     Hope this helps,
> >     Alicia
> >
> >>     On Dec 23, 2019, at 8:11 AM, Vladimir Botka <vbo...@gmail.com <mailto:vbo...@gmail.com>
> <mailto:vbo...@gmail.com <mailto:vbo...@gmail.com>>> wrote:
> >>
> >>     On Mon, 23 Dec 2019 17:56:07 +0530
> >>     Gopal Chatla <gopal....@gmail.com <mailto:gopal....@gmail.com> <mailto:gopal....@gmail.com
> <mailto:gopal....@gmail.com>>> wrote:
> >>
> >>>     Is there any way to include python script in ansible playbook for string
> >>>     alignments?
> >>
> >>     Try "Filter plugins"
> >>     https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html#filter-plugins
> >>
> >>     Cheers,
> >>
> >>     -vlado
> >>
> >>     --
> >>     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 <mailto:ansible-project%2Bunsu...@googlegroups.com>
> <mailto:ansible-project%2Bunsu...@googlegroups.com <mailto:ansible-project%252Buns...@googlegroups.com>>.
> >>     To view this discussion on the web visit
> >>     https://groups.google.com/d/msgid/ansible-project/20191223151103.3f9e60e4%40gmail.com.
> >
> > --
> > 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 <mailto:ansible-project%2Bunsu...@googlegroups.com>
> <mailto:ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/ansible-project/CAAAxneczwYbky9axjhYtTSCo6_B-udFChps44UVkX4nzvz00Yg%40mail.gmail.com
> >
> <https://groups.google.com/d/msgid/ansible-project/CAAAxneczwYbky9axjhYtTSCo6_B-udFChps44UVkX4nzvz00Yg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> 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 <mailto:ansible-project%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/a7bb4ee5-a574-8108-49d5-66709f9673f5%40linuxia.de.
>
> --
> 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 <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAAAxneekJhkFNunsYaAPdCaXdK_5YQmtJA7fAy7kGx-KNPT0gQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAAAxneekJhkFNunsYaAPdCaXdK_5YQmtJA7fAy7kGx-KNPT0gQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
signature.asc
Reply all
Reply to author
Forward
0 new messages