# replace a line in remote file

**URL:** <https://forum.ansible.com/t/replace-a-line-in-remote-file/17632>\
**Category:** Ansible Project\
**Created:** [February 26, 2015, 10:24pm UTC](https://forum.ansible.com/t/replace-a-line-in-remote-file/17632 "2015-02-26T22:24:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinay.bhasker](https://avatars.discourse-cdn.com/v4/letter/v/5f9b8f/32.png) [@vinay.bhasker](https://forum.ansible.com/u/vinay.bhasker)\
**Post date:** [February 26, 2015, 10:24pm UTC](https://forum.ansible.com/t/replace-a-line-in-remote-file/17632/1 "2015-02-26T22:24:05Z")

</div>

Question:  
Need some advice on how to do in ansible.

We are fetching the archive from artifactory url and calling a script to deploy the application.  
The archive would be different for different release and we need to replace the value into the property file before executing the script.  
In simpler words

Example for artifactory uri  
[http://xxxxxxxxx/artifactory/simple/internal-releases/xx/xxx/xx/ear/ZZZZ\_EAR/0.0.4/ZZZZ\_EAR-0.0.4.ear](http://xxxxxxxxx/artifactory/simple/internal-releases/xx/xxx/xx/ear/ZZZZ_EAR/0.0.4/ZZZZ_EAR-0.0.4.ear)

we need to extract ZZZZ\_EAR-0.0.4.ear

and then replace in /a/b/propFile/deployment.ini

from  
DEPLOYMENTFILE=/x/yZZZZ/\_EAR-0.0.4.ear  
to  
DEPLOYMENTFILE=/x/y/ZZZZ\_EAR-0.0.4.ear  
&  
then finally excute the deploymentApplication.sh file

Need help with completing below ansible playbook for above requirement.

---

<div class="post-metadata">

**Author:** ![vinay.bhasker](https://avatars.discourse-cdn.com/v4/letter/v/5f9b8f/32.png) [@vinay.bhasker](https://forum.ansible.com/u/vinay.bhasker)\
**Post date:** [February 26, 2015, 10:29pm UTC](https://forum.ansible.com/t/replace-a-line-in-remote-file/17632/2 "2015-02-26T22:29:42Z")

</div>

Correction of typo…

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [February 27, 2015, 1:53pm UTC](https://forum.ansible.com/t/replace-a-line-in-remote-file/17632/3 "2015-02-27T13:53:29Z")

</div>

Hi

You can use lineinfile module [http://docs.ansible.com/lineinfile\_module.html](http://docs.ansible.com/lineinfile_module.html) but if I were you I would just download deployment file as ZZZ\_EAR-latest.ear and in your config file it will always be DEPLOYMENTFILE=/x/y/ZZZZ\_EAR-latest.ear

Edgars

ceturtdiena, 2015. gada 26. februāris 23:24:06 UTC+1, [vinay....@gmail.com](mailto:vinay....@gmail.com) rakstīja:

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [March 5, 2015, 9:05pm UTC](https://forum.ansible.com/t/replace-a-line-in-remote-file/17632/4 "2015-03-05T21:05:25Z")

</div>

Funny to see how the lineinfile module gets all the fame when sometimes the replace module would be “good enough” [http://docs.ansible.com/replace\_module.html](http://docs.ansible.com/replace_module.html) 🙂
