I’m not sure how to make it work how you have laid out. But I would do the
check in the jinja template anyway. Get your current ntp lines. In the
jinja template run.
{% for ntp_server in ntp_config_get %}
{% if ntp_line not in ntp_servers %}
no ntp server {{ ntp_server }}
{% ending %}
{% for ntp_srv in ntp_servers %}
ntp server {{ ntp_srv }}
{% endfor %}
If you got the whole line of current ntp servers, you’ll have to parse the
ips with regex, I’m certain I’ve done something very similar to this
before. Let me know if you still have issues after trying this.
On Mon, Sep 17, 2018 at 5:40 PM Krishna N <[email protected]> wrote:
> Greetings!
>
> How to compare when items are not in jinja template loop?
>
> with_items: "{{ runconfser.stdout_lines[0] }}"
> when: (item not in {src: 'ntprequired.j2'} and (item!=""))
> ios_config:
> lines:
> - "no {{ item }}"
>
> I am using roles.
>
> */templates/ntprequired.j2*:
>
> {% for ntp_srv in ntp_servers %}
> ntp server {{ ntp_srv }}
> {% endfor %}
>
>
> --
> 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/1d64f07a-6be8-483f-8dd7-343ea7ab73dd%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1d64f07a-6be8-483f-8dd7-343ea7ab73dd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Jonathon Woods
--
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/CAB1Ty_fgx1XtbOC3KU636AsPYcWTdGK4jbfatp8gj_dwJHhzCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.