# Questions about file copy / modification

**URL:** <https://forum.ansible.com/t/questions-about-file-copy-modification/26745>\
**Category:** Ansible Project\
**Created:** [February 15, 2018, 10:13am UTC](https://forum.ansible.com/t/questions-about-file-copy-modification/26745 "2018-02-15T10:13:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sacha\_Lrt](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@Sacha\_Lrt](https://forum.ansible.com/u/Sacha_Lrt)\
**Post date:** [February 15, 2018, 10:13am UTC](https://forum.ansible.com/t/questions-about-file-copy-modification/26745/1 "2018-02-15T10:13:02Z")

</div>

Hello everybody !

I’m kind of new around here and a fresh new Ansible user ! So my questions may sounds little bit stupid…  
Anyway ! My environment is the following : I’m using ansible to manage VM behind a bastion. So I have a ssh.cfg file with ProxyCommand in it etc.  
Everything is working but this is slow ! And this is actually normal.

Still, I was wondering how exactly copy / unarchive / file modules are proceeding.  
Let’s assume that I have a httpd.conf file deployed on my VM. Everytime I’m running my playbook with the copy module with a httpd.conf file as src parameter, what is going to happen ?  
Is Ansible going to check if modifications have been done ? Or is Ansible simply replacing the file ?  
I’m asking these questions because when I run my playbook, I get the “ok” status for the copy task but couldn’t find anything about it ! I really want to make sure that ansible isn’t doing anything that could slow down my general deployment.

Indeed, I want to know what is better in term of speed :

- Use the copy module directly  
OR
- add a WHEN condition to the copy task and have a rapid checksum using stat module before running the copy ?

Basically, my general question is :

What is actually doing copy / file (symlink use case) / unarchive modules whereas the version on the remote server is the same as the local one !

My goal is to avoid any useless operations in order to minimize the time of my playbook run.

So that I have an answer to this question : Is it worth using different stat module in order to determine if I should run a task or not ?

As an example, is it better to perform this :

- name: Checking if the link has to be updated  
stat:  
path: “{{ ihm\_symlink\_name }}”  
register: ihm\_lnk\_stat

- name: Update the {{ name }} symlink to point at the new folder  
file:  
src: “{{ folder\_path }}”  
dest: “{{ symlink\_name }}”  
state: link

when: ihm\_lnk\_stat.stat.lnk\_target != “{{ folder\_path }}”

OR simply that :

- name: Update the {{ name }} symlink to point at the new folder  
file:  
src: “{{ folder\_path }}”  
dest: “{{ symlink\_name }}”  
state: link

I hope you see what I mean and why I’m asking me this question ! If not, please tell me, I’ll try to rephrase !  
Thank you for reading me !
