Hi Dick,

I went through example in ansible documentation but was not descriptive 
enough and searched extensively on internet but didn't find any examples 
for multiline for ansible.

ROUTER#sh run | i boot 
boot system flash bootflash:isr4300-universalk9.16.12.04.SPA.bin 
boot system flash bootflash:isr4300-universalk9.16.06.04.SPA.bin

Below is a script i wrote using regex_search multiline for checking if 
'........9.16.12.04.SPA.bin' is present specifically in 1st line followed 
by '.......9.16.06.04.SPA.bin' specifically in 2nd line. But doesn't work. 
How should i modify it?

- name: GATHER SHOW VERSION
      ios_command:
        commands: "sh run | i boot"

      register: show_boot

    - debug:
        msg:
        - "{{ show_version.stdout[0] | 
regex_search('isr4300-universalk9.16.12.04.SPA.bin ', 
'isr4300-universalk9.16.06.04.SPA.bin', multiline=True) }}"

Thanks,
Vikram


On Tuesday, 18 May, 2021 at 10:02:07 pm UTC+5:30 dick....@geant.org wrote:

> Yes this is possible but having the regex multiline aware 
>
> On Tue, 18 May 2021 at 15:36, Vikram S <vikrams...@gmail.com> wrote:
>
>>
>> Hi Dick,
>>
>> Not sure if i misunderstood your suggestion but iam already aware of 
>> regex_search but does it help with specificaly ensuring that 
>> '........9.16.12.04.SPA.bin' is present specifically in 1st line followed 
>> by '.......9.16.06.04.SPA.bin' specifically in 2nd line like in below 
>> output?
>>
>> ROUTER#sh run | i boot 
>> boot system flash bootflash:isr4300-universalk9.16.12.04.SPA.bin 
>> boot system flash bootflash:isr4300-universalk9.16.06.04.SPA.bin
>>
>> Reason for this question is even when i give 'no boot' first and then add 
>> boot statement in correct order, the lines interchage in rare cases when i 
>> check boot statement. Which means the router will boot up with old image 
>> rather than new image after reload since that comes in 1st line.
>>
>> Thanks,
>> Vikram
>> On Tuesday, 18 May, 2021 at 9:08:55 am UTC+5:30 dick....@geant.org wrote:
>>
>>> No need for scripts, use the regex_search filter: 
>>>
>>> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#id40
>>>
>>>
>>> On Tue, 18 May 2021 at 04:59, Vikram S <vikrams...@gmail.com> wrote:
>>>
>>>> The output of 'sh run | i boot' shows 2 boot statements set in router. 
>>>> But i need to write a script which will check if 
>>>> '........9.16.12.04.SPA.bin' is present specifically in 1st line followed 
>>>> by '.......9.16.06.04.SPA.bin' specifically in 2nd line.
>>>>
>>>> I know to write a script to check if both these lines are persent or 
>>>> not. But my challenge is that i need to check if 
>>>> '........9.16.12.04.SPA.bin' is present specifically in 1st line and so 
>>>> on. 
>>>> How do i do that?
>>>> ROUTER#sh run | i boot 
>>>> boot system flash bootflash:isr4300-universalk9.16.12.04.SPA.bin boot 
>>>> system flash bootflash:isr4300-universalk9.16.06.04.SPA.bin
>>>>
>>>> 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.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/ansible-project/bc23196e-8ea6-461f-b1da-f0ffa234347dn%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ansible-project/bc23196e-8ea6-461f-b1da-f0ffa234347dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>>> Sent from a mobile device - please excuse the brevity, spelling and 
>>> punctuation.
>>>
>> -- 
>> 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/eaaa41c4-e430-4779-8097-edc5645fd83dn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/eaaa41c4-e430-4779-8097-edc5645fd83dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Sent from a mobile device - please excuse the brevity, spelling and 
> punctuation.
>

-- 
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/a290aff2-211f-434c-a595-da224e26cf68n%40googlegroups.com.

Reply via email to