# junos replace pattern

**URL:** <https://forum.ansible.com/t/junos-replace-pattern/30096>\
**Category:** Ansible Project\
**Created:** [April 11, 2019, 8:38am UTC](https://forum.ansible.com/t/junos-replace-pattern/30096 "2019-04-11T08:38:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Szczesniak](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@Michal\_Szczesniak](https://forum.ansible.com/u/Michal_Szczesniak)\
**Post date:** [April 11, 2019, 8:38am UTC](https://forum.ansible.com/t/junos-replace-pattern/30096/1 "2019-04-11T08:38:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michal\_Szczesniak](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@Michal\_Szczesniak](https://forum.ansible.com/u/Michal_Szczesniak)\
**Post date:** [April 12, 2019, 8:40am UTC](https://forum.ansible.com/t/junos-replace-pattern/30096/2 "2019-04-12T08:40:28Z")

</div>

Juniper Tech Library says it should look like this:

```auto
<rpc>
   <load-configuration>
 
      <!-- replace a pattern globally -->
      <configuration replace-pattern="" with="" [upto=""]>
      </configuration>
   </load-configuration>

```

```auto
</rpc>

```

```auto

```

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- and .  
Itried this way but It gives mi an error:

```auto

```

- 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
