Re: [ansible-project] ansible - J2 template
On Wed, 30 Jun 2021 23:17:21 -0700 (PDT) "dudu.c...@gmail.com" wrote: > If value1 is not defined (empty Value1: ) Test the variable is both defined and not empty, e.g. (minimal version) {% if value1 is defined and value1|d('')|length > 0 %} {{ value1 }} {% else %} This string must be included {% endif %} -- Vladimir Botka -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20210701105507.0a89ada5%40gmail.com. pgpsYgiVOcW8r.pgp Description: OpenPGP digital signature
Re: [ansible-project] ansible - J2 template
LINE=” This string must be included{% if value1 is defined %} this string is optional= {{ value1 }}{% endif %}” On Thu, 1 Jul 2021 at 08:17, dudu.c...@gmail.com wrote: > > Ansible question > I have a variable, let call it value1 and a J2 template. > > The J2 template includes the following line : > LINE=” This string mut be included this string is optional= {{ value1}}” > > What I need to implement > > If value1 is defined with a string – let assume that the string is OK > (Value1: OK) > , the file should be > LINE=” This string must be includedthis string is optional= OK” > > > If value1 is not defined (empty Value1: ) –the file should be > LINE=” This string must be included” > > So how the J2 should be configured? > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/f9c56cbd-6356-4efd-b0d7-2e6abe9faf9dn%40googlegroups.com. -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwNEbHLTzQwdkWPX%2B8rmhmfsJ1%2BVHc_T%2BAeyGzu%2BxQxbKA%40mail.gmail.com.
[ansible-project] ansible - J2 template
Ansible question I have a variable, let call it value1 and a J2 template. The J2 template includes the following line : LINE=” This string mut be included this string is optional= {{ value1}}” What I need to implement If value1 is defined with a string – let assume that the string is OK (Value1: OK) , the file should be LINE=” This string must be includedthis string is optional= OK” If value1 is not defined (empty Value1: ) –the file should be LINE=” This string must be included” So how the J2 should be configured? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f9c56cbd-6356-4efd-b0d7-2e6abe9faf9dn%40googlegroups.com.