# Clean way to "rm /root/.bashrc && ln -s /root/.profile/.bashrc"

**URL:** <https://forum.ansible.com/t/clean-way-to-rm-root-bashrc-ln-s-root-profile-bashrc/23788>\
**Category:** Ansible Project\
**Created:** [February 21, 2017, 3:42pm UTC](https://forum.ansible.com/t/clean-way-to-rm-root-bashrc-ln-s-root-profile-bashrc/23788 "2017-02-21T15:42:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_L\_Harris](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Robert\_L\_Harris](https://forum.ansible.com/u/Robert_L_Harris)\
**Post date:** [February 21, 2017, 3:42pm UTC](https://forum.ansible.com/t/clean-way-to-rm-root-bashrc-ln-s-root-profile-bashrc/23788/1 "2017-02-21T15:42:30Z")

</div>

I’m trying to use ansible to enforce some file configurations in a test environment. Right now I’ve got a command: which does the remove of the original .bashrc then creates the links. But then every run, it removes the links and re-creates them. I/m looking to create a task to only remove .bashrc if it’s a file, then create the link.

Anyone have an example of such?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 22, 2017, 7:02pm UTC](https://forum.ansible.com/t/clean-way-to-rm-root-bashrc-ln-s-root-profile-bashrc/23788/2 "2017-02-22T19:02:48Z")

</div>

Use the file module.

- name: Create link  
&nbsp;&nbsp;&nbsp;file:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: /root/.bashrc  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src: /root/.profile/.bashrc  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;force: yes  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: link
