# Why doesn't Ansible have mv/rename?

**URL:** <https://forum.ansible.com/t/why-doesnt-ansible-have-mv-rename/7914>\
**Category:** Get Help\
**Created:** [August 17, 2024, 6:49pm UTC](https://forum.ansible.com/t/why-doesnt-ansible-have-mv-rename/7914 "2024-08-17T18:49:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoftyGoals](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@LoftyGoals](https://forum.ansible.com/u/LoftyGoals)\
**Post date:** [August 17, 2024, 6:49pm UTC](https://forum.ansible.com/t/why-doesnt-ansible-have-mv-rename/7914/1 "2024-08-17T18:49:56Z")

</div>

I already know how do move or rename a file. I’m just wondering why there isn’t a specific module that does this. It seems like a very specific design decision… does anyone know what the reason was?

---

<div class="post-metadata">

**Author:** ![fale](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/fale/32/2181_2.png) [@fale](https://forum.ansible.com/u/fale)\
**Post date:** [August 18, 2024, 7:07am UTC](https://forum.ansible.com/t/why-doesnt-ansible-have-mv-rename/7914/2 "2024-08-18T07:07:51Z")

</div>

Although I have no direct insights in this, my opinion on why there is no move/rename module is that such operations would intrinsically be non-idempotent. Although Ansible has no strict rule against non-idempotent code, there has always been a strong bias against it.

---

<div class="post-metadata">

**Author:** ![CBeerse](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@CBeerse](https://forum.ansible.com/u/CBeerse)\
**Post date:** [September 11, 2024, 8:20pm UTC](https://forum.ansible.com/t/why-doesnt-ansible-have-mv-rename/7914/3 "2024-09-11T20:20:34Z")

</div>

If you know unix and the ansible.builtin.file module, you could have found the link optioin. In unix, a rename and a move within a filesystem is effective a hardlink on the new location and a removal on the old location. With the ansible.builtin.file module you can do the same.

Following [https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file\_module.html:](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html:)

- name: Create the new name  
ansible.builtin.file:  
src: /path/to/old/name  
dest: /path/to/new/name  
state: hard
- name: Remove the old name  
ansible.builtin.file:  
path: /path/to/old/name  
state: absent
