Hi Racke,

I have been told the same thing earlier as you said now and i have also 
tested. When i give "'Apr 09 2021' in show_flash_packages.stdout[0]", it 
seems to check the entire string and not just the first character.  
I give the exact when syntax with ios_command module and other modules and 
it works and it checks the entire string. Porblem with ios_config module is 
that it doesn't even seem to check the 1st character, but it simply seems 
to ignore the when conditional itself.

Are you saying that if i were to give it as below, it should work? I will 
double check again anyways.....

 - name: ADD PACKAGES.CONF AS BOOT STATEMENT WHEN THIS FILE IS UPDATED
      ios_config:
        lines:
          - boot system flash:packages.conf
      when:  
        - "'Apr 09 2021' in show_flash_packages.stdout or
          'Apr 10 2021' in show_flash_packages.stdout"

Thanks,
Vikram
On Sunday, 11 April, 2021 at 7:03:17 pm UTC+5:30 brae...@gmail.com wrote:

> On 4/11/21 3:25 PM, Vikram S wrote:
> > Hi,
> > 
> > I have written the below script to check if packages.conf has been 
> updated (by checking it's date) in flash and if so,
> > to set it as boot statement for switch. But ansible does not seem to 
> consider the when conditional at all. It sets the
> > boot statement regardless of whether the condition matches or not.
> > But below 'when' syntax works for ios_command module. Should i modify 
> the syntax or am i writing it wrong?
> > 
> > 
> >  - name: GATHER PACKAGES.CONF FILE INFO IN FLASH
> >       ios_command:
> >         commands: "show flash: | i packages.conf"
> > 
> >       register: show_flash_packages
> > 
> >     - name: ADD PACKAGES.CONF AS BOOT STATEMENT WHEN THIS FILE IS UPDATED
> >       ios_config:
> >         lines:
> >           - boot system flash:packages.conf
> >       when:  
> >         - "'Apr 09 2021' in show_flash_packages.stdout[0] or
> >           'Apr 10 2021' in show_flash_packages.stdout[0]"
>
> Looks like you confused stdout_lines with stdout.
>
> stdout is a string and so stdout[0] is the first character of stdout.
>
> Regards
> Racke
>
> > 
> > Thanks,
> > Vikram
> > 
> > -- 
> > 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/ea53769d-3763-41ab-9e3b-fc267dc16d64n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/ea53769d-3763-41ab-9e3b-fc267dc16d64n%40googlegroups.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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/55af80c5-0704-40df-8b9d-21fc526260cfn%40googlegroups.com.

Reply via email to