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

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?

Use the file module.

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