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-project+unsubscr...@googlegroups.com > <mailto:ansible-project+unsubscr...@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/14a15e2e-46a0-98f0-e495-45675ca66b82%40linuxia.de.
OpenPGP_signature
Description: OpenPGP digital signature