# sudo(become) difference between "copy" module and "command" module

**URL:** <https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119>\
**Category:** Ansible Project\
**Created:** [June 8, 2020, 3:25pm UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119 "2020-06-08T15:25:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mukuntha\_rajaa](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mukuntha\_rajaa](https://forum.ansible.com/u/Mukuntha_rajaa)\
**Post date:** [June 8, 2020, 3:25pm UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/1 "2020-06-08T15:25:58Z")

</div>

Hello,

“become” works perfectly fine with “command” module. But not with “copy” module. Am I doing something wrong here.

**Working playbook:**

- name: demo  
hosts: localhost  
tasks:
- name: copy  
command: cp /etc/ssh/sshd\_config /tmp/sshd\_config  
become: yes
- name: edit  
lineinfile:  
path: /tmp/sshd\_config  
regexp: ‘^PermitRootLogin’  
line: “PermitRootLogin yes”  
become: yes

working logs:

$ ap lineinfile.yml  
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

PLAY [demo] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [copy] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost]

TASK [edit] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost]

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

**Problematic playbook:**

- name: demo  
hosts: localhost  
tasks:
- name: copy  
copy:  
src: /etc/ssh/sshd\_config  
dest: /tmp/sshd\_config  
become: yes
- name: edit  
lineinfile:  
path: /tmp/sshd\_config  
regexp: ‘^PermitRootLogin’  
line: “PermitRootLogin yes”  
become: yes

Logs for problematic playbook:

$ap zz.yml  
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

PLAY [demo] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [copy] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “an error occurred while trying to read the file ‘/etc/ssh/sshd\_config’: [Errno 13] Permission denied: b’/etc/ssh/sshd\_config’”}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [June 8, 2020, 5:22pm UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/2 "2020-06-08T17:22:38Z")

</div>

> Hello,
> 
> "become" works perfectly fine with "command" module. But not with  
> "copy" module. Am I doing something wrong here.
> 
> \*\_Working playbook:\_\*  
> - name: demo  
> hosts: localhost  
> tasks:  
> - name: copy  
> command: cp /etc/ssh/sshd\_config /tmp/sshd\_config  
> become: yes  
> - name: edit  
> lineinfile:  
> path: /tmp/sshd\_config  
> regexp: '^PermitRootLogin'  
> line: "PermitRootLogin yes"  
> become: yes
> 
> working logs:  
> $ ap lineinfile.yml  
> [WARNING]: provided hosts list is empty, only localhost is available.  
> Note that the implicit localhost does not match 'all'
> 
> PLAY [demo]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK [Gathering Facts]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> ok: [localhost]
> 
> TASK [copy]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> changed: [localhost]
> 
> TASK [edit]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> changed: [localhost]
> 
> PLAY RECAP  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0  
> ignored=0
> 
> \*\_Problematic playbook:\_\*  
> - name: demo  
> hosts: localhost  
> tasks:  
> - name: copy  
> copy:  
> src: /etc/ssh/sshd\_config  
> dest: /tmp/sshd\_config  
> become: yes  
> - name: edit  
> lineinfile:  
> path: /tmp/sshd\_config  
> regexp: '^PermitRootLogin'  
> line: "PermitRootLogin yes"  
> become: yes
> 
> Logs for problematic playbook:  
> $ap zz.yml  
> [WARNING]: provided hosts list is empty, only localhost is available.  
> Note that the implicit localhost does not match 'all'
> 
> PLAY [demo]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK [Gathering Facts]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> ok: [localhost]
> 
> TASK [copy]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> fatal: [localhost]: FAILED! =\> {"msg": "an error occurred while trying  
> to read the file '/etc/ssh/sshd\_config': [Errno 13] Permission denied:  
> b'/etc/ssh/sshd\_config'"}

You want `remote_src: yes`... otherwise it's trying to read the file from the controller.

V/r,  
James Cassell

---

<div class="post-metadata">

**Author:** ![Mukuntha\_rajaa](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mukuntha\_rajaa](https://forum.ansible.com/u/Mukuntha_rajaa)\
**Post date:** [June 9, 2020, 12:27am UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/3 "2020-06-09T00:27:33Z")

</div>

Thanks for your email. This playbook is for testing purpose. I wanted src to be from controller only.

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [June 9, 2020, 1:27am UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/4 "2020-06-09T01:27:11Z")

</div>

> \>  
> \> \> Hello,  
> \> \>  
> \> \> "become" works perfectly fine with "command" module. But not with  
> \> \> "copy" module. Am I doing something wrong here.  
> \> \>  
> \> \> \*\_Working playbook:\_\*  
> \> \> - name: demo  
> \> \> hosts: localhost  
> \> \> tasks:  
> \> \> - name: copy  
> \> \> command: cp /etc/ssh/sshd\_config /tmp/sshd\_config  
> \> \> become: yes  
> \> \> - name: edit  
> \> \> lineinfile:  
> \> \> path: /tmp/sshd\_config  
> \> \> regexp: '^PermitRootLogin'  
> \> \> line: "PermitRootLogin yes"  
> \> \> become: yes  
> \> \>  
> \> \> working logs:  
> \> \> $ ap lineinfile.yml  
> \> \> [WARNING]: provided hosts list is empty, only localhost is available.  
> \> \> Note that the implicit localhost does not match 'all'  
> \> \>  
> \> \> PLAY [demo]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \>  
> \> \> TASK [Gathering Facts]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \> ok: [localhost]  
> \> \>  
> \> \> TASK [copy]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \> changed: [localhost]  
> \> \>  
> \> \> TASK [edit]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \> changed: [localhost]  
> \> \>  
> \> \> PLAY RECAP  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \> localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0  
> \> \> ignored=0  
> \> \>  
> \> \>  
> \> \> \*\_Problematic playbook:\_\*  
> \> \> - name: demo  
> \> \> hosts: localhost  
> \> \> tasks:  
> \> \> - name: copy  
> \> \> copy:  
> \> \> src: /etc/ssh/sshd\_config  
> \> \> dest: /tmp/sshd\_config  
> \> \> become: yes  
> \> \> - name: edit  
> \> \> lineinfile:  
> \> \> path: /tmp/sshd\_config  
> \> \> regexp: '^PermitRootLogin'  
> \> \> line: "PermitRootLogin yes"  
> \> \> become: yes  
> \> \>  
> \> \> Logs for problematic playbook:  
> \> \> $ap zz.yml  
> \> \> [WARNING]: provided hosts list is empty, only localhost is available.  
> \> \> Note that the implicit localhost does not match 'all'  
> \> \>  
> \> \> PLAY [demo]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \>  
> \> \> TASK [Gathering Facts]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \> ok: [localhost]  
> \> \>  
> \> \> TASK [copy]  
> \> \> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> \> \> fatal: [localhost]: FAILED! =\> {"msg": "an error occurred while trying  
> \> \> to read the file '/etc/ssh/sshd\_config': [Errno 13] Permission denied:  
> \> \> b'/etc/ssh/sshd\_config'"}  
> \> \>  
> \>  
> \> You want `remote_src: yes`... otherwise it's trying to read the file from the controller.

> Thanks for your email. This playbook is for testing purpose. I wanted  
> src to be from controller only.

In that case, you'll need to make sure the src file can be read by the user running ansible. sshd\_config is not world readable by default.

V/r,  
James Cassell

---

<div class="post-metadata">

**Author:** ![Mukuntha\_rajaa](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mukuntha\_rajaa](https://forum.ansible.com/u/Mukuntha_rajaa)\
**Post date:** [June 9, 2020, 1:59am UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/5 "2020-06-09T01:59:43Z")

</div>

Hello,

Which is why I’ve mentioned “become: yes” option. Like I’ve mentioned in starting of this thread, if I run the exact same playbook with “command” module, permission issue does not come. Only with “copy” module, it complains about permission issue. Please note I’ve used “become” in both the cases.

---

<div class="post-metadata">

**Author:** ![Luca\_remix\_tj\_Lorenz](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Luca\_remix\_tj\_Lorenz](https://forum.ansible.com/u/Luca_remix_tj_Lorenz)\
**Post date:** [June 9, 2020, 6:58am UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/6 "2020-06-09T06:58:49Z")

</div>

Hello,

but become applies on target host, not controller. And, as stated  
before, in the first playbook you're copying with cp sshd\_config of  
the remote host to /tmp/sshd\_config. Instead in the second one you're  
copying sshd\_config from controller to /tmp/sshd\_config of the remote  
host.  
Even if the host is localhost and localhost is the controller, it is  
treated like any remote host. Become is applied inside the connection  
to remote host (even if connection: local), not when executing  
ansible.

Luca

---

<div class="post-metadata">

**Author:** ![Mukuntha\_rajaa](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mukuntha\_rajaa](https://forum.ansible.com/u/Mukuntha_rajaa)\
**Post date:** [June 9, 2020, 9:15am UTC](https://forum.ansible.com/t/sudo-become-difference-between-copy-module-and-command-module/33119/7 "2020-06-09T09:15:38Z")

</div>

Hello,

Thanks a lot. Its clear now. I have used “remote\_src” to apply “become” logic.

Regards,  
Mukuntha.
