junos replace pattern

12 views
Skip to first unread message

Michał Szczęśniak

unread,
Apr 11, 2019, 4:38:53 AM4/11/19
to Ansible Project
Hi,
Is there any way using junos modules in ansible to send "replace pattern" command to Juniper device?
I stucked on this. 
Any help would be greatly appreciated!

Michal

Michał Szczęśniak

unread,
Apr 12, 2019, 4:40:28 AM4/12/19
to Ansible Project
Juniper Tech Library says it should look like this:

<rpc>
<load-configuration>

<!-- replace a pattern globally -->
<configuration replace-pattern="pattern1" with="pattern2" [upto="n"]>
</configuration>
</load-configuration>
</rpc>

But I have no idea how to format this kind of rpc request to junos_rc module:
The problem is, I think, that there are one tag nested in onother- <load-configuration> and <configurationa>.
Itried this way but It gives mi an error:

     - name: replace pattern 
       junos_rpc: 
          rpc: load-configuration configuration
           attrs:
             replace-pattern="pattern1"
             with="pattern2
 
I tried also this way and it gives me "OK" response but it doesn't change anything in configuration:

     - name: replace pattern 
       junos_rpc: 
          rpc: load-configuration
           attrs:
             replace-pattern="pattern1"
             with="pattern2

Any other idea?
Thanks in advance,
Michal
Reply all
Reply to author
Forward
0 new messages