'copy' TASK won't copy a file - eventhough reporting 'ok'

78 views
Skip to first unread message

dulh...@mailbox.org

unread,
Jul 14, 2022, 9:41:54 AM7/14/22
to ansible...@googlegroups.com
I have a TASK that should copy ~/files/repo_pgbackrest.conf to the remote as /etc/pgbackrest/pgbackrest.conf (note the differing file name).
 
however, despite that fact playbook exection returns an 'ok' an that TASK, the file is not pushed to the remote.
 
==============================================================
 
- name: install preps - push config file
  copy:
    src: files/repo_pgbackrest.conf # was: repo_pgbackrest.conf
    dest: " {{ item }} "
    mode: '0640'
        owner: pgbackrest
    group: pgbackrest
  become: true
  loop:
    - /etc/pgbackrest/pgbackrest.conf
 
==============================================================
 
Knowing that sometimes things only work after several re-runs I executed this about 5 times with the exact same, unwanted behavior.
 
So ... what am I doing wrong here? 

Stefan Hornburg (Racke)

unread,
Jul 14, 2022, 9:44:18 AM7/14/22
to ansible...@googlegroups.com
On 14/07/2022 15:41, dulhaver via Ansible Project wrote:
> I have a TASK that should copy *~/files/repo_pgbackrest.conf* to the remote as */etc/pgbackrest/pgbackrest.conf* (note the differing file name).
> however, despite that fact playbook exection returns an 'ok' an that TASK, the file is *not pushed* to the remote.
> ==============================================================
> - name: install preps - push config file
>   copy:
>     src: files/repo_pgbackrest.conf # was: repo_pgbackrest.conf
>     dest: " {{ item }} "
>     mode: '0640'
> owner: pgbackrest
>     group: pgbackrest
>   become: true
>   loop:
>     - /etc/pgbackrest/pgbackrest.conf
> ==============================================================
> Knowing that sometimes things only work after several re-runs I executed this about 5 times with the exact same, unwanted behavior.
> So ... what am I doing wrong here?
>
My suspicion would be that you are looking at the wrong target.

Regards
Racke

> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1699810404.552239.1657806094344%40office.mailbox.org <https://groups.google.com/d/msgid/ansible-project/1699810404.552239.1657806094344%40office.mailbox.org?utm_medium=email&utm_source=footer>.


--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

Brian Coca

unread,
Jul 14, 2022, 9:51:04 AM7/14/22
to Ansible Project
always use -vvv before even asking a question, then also post that info here.

I suspect that the file is there and that ansible is comparing the
checksums and seeing they are the same and that it does not need to
make the copy.



--
----------
Brian Coca

Todd Lewis

unread,
Jul 14, 2022, 12:00:50 PM7/14/22
to Ansible Project
Remove the bogus leading and trailing spaces from `dest:`.

dulh...@mailbox.org

unread,
Jul 15, 2022, 5:18:32 AM7/15/22
to ansible...@googlegroups.com
 
On 07/14/2022 6:00 PM CEST Todd Lewis <uto...@gmail.com> wrote:
 
Remove the bogus leading and trailing spaces from `dest:`.
spot on! thx. changing
    
dest: " {{ item }} "   to
dest: "{{ item }}"
 
solves the issue. It's unexpected though that such a mistake does not produce any kind of error message.
 
 
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2f0cb460-4513-49f3-b0f9-10bf61a54c4en%40googlegroups.com.

Dick Visser

unread,
Jul 15, 2022, 5:45:04 AM7/15/22
to ansible...@googlegroups.com
On Fri, 15 Jul 2022 at 11:18, dulhaver via Ansible Project <ansible...@googlegroups.com> wrote:
 
On 07/14/2022 6:00 PM CEST Todd Lewis <uto...@gmail.com> wrote:
 
Remove the bogus leading and trailing spaces from `dest:`.
spot on! thx. changing
    
dest: " {{ item }} "   to
dest: "{{ item }}"
 
solves the issue. It's unexpected though that such a mistake does not produce any kind of error message.
 

Probably because there isn't an error. You will find that the files are correctly created, likely with a leading and trailing space - as you told ansible to. 
The verbose output will tell - but you didn't provide that.

 
On Thursday, July 14, 2022 at 9:41:54 AM UTC-4 dulh...@mailbox.org wrote:
I have a TASK that should copy ~/files/repo_pgbackrest.conf to the remote as /etc/pgbackrest/pgbackrest.conf (note the differing file name).
 
however, despite that fact playbook exection returns an 'ok' an that TASK, the file is not pushed to the remote.
 
==============================================================
 
- name: install preps - push config file
  copy:
    src: files/repo_pgbackrest.conf # was: repo_pgbackrest.conf
    dest: " {{ item }} "
    mode: '0640'
        owner: pgbackrest
    group: pgbackrest
  become: true
  loop:
    - /etc/pgbackrest/pgbackrest.conf
 
==============================================================
 
Knowing that sometimes things only work after several re-runs I executed this about 5 times with the exact same, unwanted behavior.
 
So ... what am I doing wrong here? 

 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2f0cb460-4513-49f3-b0f9-10bf61a54c4en%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
--
Sent from Gmail Mobile

dulh...@mailbox.org

unread,
Jul 15, 2022, 7:07:03 AM7/15/22
to ansible...@googlegroups.com
hi,
On 07/15/2022 11:44 AM CEST Dick Visser <dnmv...@gmail.com> wrote:
On Fri, 15 Jul 2022 at 11:18, dulhaver via Ansible Project <ansible...@googlegroups.com> wrote:
changing
    
dest: " {{ item }} "   to
dest: "{{ item }}"
 
solves the issue. It's unexpected though that such a mistake does not produce any kind of error message.
Probably because there isn't an error. You will find that the files are correctly created, likely with a leading and trailing space - as you told ansible to. 
The verbose output will tell - but you didn't provide that.
 
sorry, you are right I did not provide the -vvv output. I tested this once again though and it showed that the copying
 
  • does not work with    dest: " {{ item }} "
# dest: " {{ item }} "
TASK [pgBackRest_step_install : install preps - push config file] *********************************************************
task path: /home/gwagner/repos/ansible/step/roles/pgBackRest_step_install/tasks/main.yml:73
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'echo ~stepuser && sleep 0'"'"''
<vm-xzy.local> (0, b'/home/stepuser\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/stepuser/.ansible/tmp `"&& mkdir "` echo /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617 `" && echo ansible-tmp-1657880906.308936-536971-114267205405617="` echo /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617 `" ) && sleep 0'"'"''
<vm-xzy.local> (0, b'ansible-tmp-1657880906.308936-536971-114267205405617=/home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617\n', b'')
Using module file /usr/lib/python3.8/site-packages/ansible/modules/stat.py
<vm-xzy.local> PUT /home/gwagner/.ansible/tmp/ansible-local-5359602lbb241d/tmp4j_zai9b TO /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_stat.py
<vm-xzy.local> SSH: EXEC sshpass -d11 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' '[vm-xzy.local>]'
<vm-xzy.local> (0, b'sftp> put /home/gwagner/.ansible/tmp/ansible-local-5359602lbb241d/tmp4j_zai9b /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_stat.py\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'chmod u+x /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/ /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_stat.py && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' -tt vm-xzy.local> '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-twlbdnfessfbowadgxwcufekdmtbfhqq ; /usr/libexec/platform-python /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_stat.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<vm-xzy.local> (0, b'\r\n\r\n{"changed": false, "stat": {"exists": true, "path": " /etc/pgbackrest/pgbackrest.conf ", "mode": "0640", "isdir": false, "ischr": false, "isblk": false, "isreg": true, "isfifo": false, "islnk": false, "issock": false, "uid": 3354, "gid": 20105, "size": 739, "inode": 182, "dev": 64771, "nlink": 1, "atime": 1657802098.813018, "mtime": 1657802008.0713508, "ctime": 1657802008.333347, "wusr": true, "rusr": true, "xusr": false, "wgrp": false, "rgrp": true, "xgrp": false, "woth": false, "roth": false, "xoth": false, "isuid": false, "isgid": false, "blocks": 8, "block_size": 4096, "device_type": 0, "readable": true, "writeable": true, "executable": false, "pw_name": "pgbackrest", "gr_name": "pgbackrest", "checksum": "39b82b1660166f6852b5e1ae9cd7865a7a0cd390", "mimetype": "text/plain", "charset": "us-ascii", "version": "2016571620", "attributes": [], "attr_flags": ""}, "invocation": {"module_args": {"path": " /etc/pgbackrest/pgbackrest.conf ", "follow": false, "get_checksum": true, "checksum_algorithm": "sha1", "get_md5": false, "get_mime": true, "get_attributes": true}}}\r\n', b'Shared connection to vm-xzy.local> closed.\r\n')
Using module file /usr/lib/python3.8/site-packages/ansible/modules/file.py
<vm-xzy.local> PUT /home/gwagner/.ansible/tmp/ansible-local-5359602lbb241d/tmpv_7q0zxq TO /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_file.py
<vm-xzy.local> SSH: EXEC sshpass -d11 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' '[vm-xzy.local>]'
<vm-xzy.local> (0, b'sftp> put /home/gwagner/.ansible/tmp/ansible-local-5359602lbb241d/tmpv_7q0zxq /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_file.py\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'chmod u+x /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/ /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_file.py && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' -tt vm-xzy.local> '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-kkvidhgydqatjocboygqmuabzunhnmuh ; /usr/libexec/platform-python /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/AnsiballZ_file.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<vm-xzy.local> (0, b'\r\n\r\n{"path": " /etc/pgbackrest/pgbackrest.conf ", "changed": false, "diff": {"before": {"path": " /etc/pgbackrest/pgbackrest.conf "}, "after": {"path": " /etc/pgbackrest/pgbackrest.conf "}}, "uid": 3354, "gid": 20105, "owner": "pgbackrest", "group": "pgbackrest", "mode": "0640", "state": "file", "secontext": "unconfined_u:object_r:user_home_t:s0", "size": 739, "invocation": {"module_args": {"mode": "0640", "owner": "pgbackrest", "group": "pgbackrest", "dest": " /etc/pgbackrest/pgbackrest.conf ", "_original_basename": "repo_pgbackrest.conf", "recurse": false, "state": "file", "path": " /etc/pgbackrest/pgbackrest.conf ", "force": false, "follow": true, "modification_time_format": "%Y%m%d%H%M.%S", "access_time_format": "%Y%m%d%H%M.%S", "unsafe_writes": false, "_diff_peek": null, "src": null, "modification_time": null, "access_time": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to vm-xzy.local> closed.\r\n')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'rm -f -r /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/ > /dev/null 2>&1 && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
ok: [vm-xzy.local>] => (item=/etc/pgbackrest/pgbackrest.conf) => changed=false
ansible_loop_var: item
checksum: 39b82b1660166f6852b5e1ae9cd7865a7a0cd390
dest: ' /etc/pgbackrest/pgbackrest.conf '
diff:
after:
path: ' /etc/pgbackrest/pgbackrest.conf '
before:
path: ' /etc/pgbackrest/pgbackrest.conf '
gid: 20105
group: pgbackrest
invocation:
module_args:
_diff_peek: null
_original_basename: repo_pgbackrest.conf
access_time: null
access_time_format: '%Y%m%d%H%M.%S'
attributes: null
dest: ' /etc/pgbackrest/pgbackrest.conf '
follow: true
force: false
group: pgbackrest
mode: '0640'
modification_time: null
modification_time_format: '%Y%m%d%H%M.%S'
owner: pgbackrest
path: ' /etc/pgbackrest/pgbackrest.conf '
recurse: false
selevel: null
serole: null
setype: null
seuser: null
src: null
state: file
unsafe_writes: false
item: /etc/pgbackrest/pgbackrest.conf
mode: '0640'
owner: pgbackrest
path: ' /etc/pgbackrest/pgbackrest.conf '
secontext: unconfined_u:object_r:user_home_t:s0
size: 739
state: file
 
 
  • while it does work with    dest: "{{ item }}"
 
TASK [pgBackRest_step_install : install preps - push config file] *******************************************************************************
task path: /home/gwagner/repos/ansible/step/roles/pgBackRest_step_install/tasks/main.yml:73
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'echo ~stepuser && sleep 0'"'"''
<vm-xzy.local> (0, b'/home/stepuser\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/stepuser/.ansible/tmp `"&& mkdir "` echo /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813 `" && echo ansible-tmp-1657881160.6701202-537076-79922878271813="` echo /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813 `" ) && sleep 0'"'"''
<vm-xzy.local> (0, b'ansible-tmp-1657881160.6701202-537076-79922878271813=/home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813\n', b'')
Using module file /usr/lib/python3.8/site-packages/ansible/modules/stat.py
<vm-xzy.local> PUT /home/gwagner/.ansible/tmp/ansible-local-537028rkexd51s/tmp7j0_jskb TO /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_stat.py
<vm-xzy.local> SSH: EXEC sshpass -d11 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' '[vm-xzy.local>]'
<vm-xzy.local> (0, b'sftp> put /home/gwagner/.ansible/tmp/ansible-local-537028rkexd51s/tmp7j0_jskb /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_stat.py\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'chmod u+x /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/ /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_stat.py && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' -tt vm-xzy.local> '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-fvagnaiipacqngrattkmrszxxfkuhhor ; /usr/libexec/platform-python /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_stat.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<vm-xzy.local> (0, b'\r\n{"changed": false, "stat": {"exists": false}, "invocation": {"module_args": {"path": "/etc/pgbackrest/pgbackrest.conf", "follow": false, "get_checksum": true, "checksum_algorithm": "sha1", "get_md5": false, "get_mime": true, "get_attributes": true}}}\r\n', b'Shared connection to vm-xzy.local> closed.\r\n')
<vm-xzy.local> PUT /home/gwagner/repos/ansible/step/roles/pgBackRest_step_install/files/repo_pgbackrest.conf TO /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source
<vm-xzy.local> SSH: EXEC sshpass -d11 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' '[vm-xzy.local>]'
<vm-xzy.local> (0, b'sftp> put /home/gwagner/repos/ansible/step/roles/pgBackRest_step_install/files/repo_pgbackrest.conf /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'chmod u+x /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/ /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
Using module file /usr/lib/python3.8/site-packages/ansible/modules/copy.py
<vm-xzy.local> PUT /home/gwagner/.ansible/tmp/ansible-local-537028rkexd51s/tmpod2bbp87 TO /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_copy.py
<vm-xzy.local> SSH: EXEC sshpass -d11 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' '[vm-xzy.local>]'
<vm-xzy.local> (0, b'sftp> put /home/gwagner/.ansible/tmp/ansible-local-537028rkexd51s/tmpod2bbp87 /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_copy.py\n', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'chmod u+x /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/ /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_copy.py && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' -tt vm-xzy.local> '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-jrfmzdhcxkipllgmwwxlrjbkwivzfjli ; /usr/libexec/platform-python /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/AnsiballZ_copy.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<vm-xzy.local> (0, b'\r\n\r\n{"dest": "/etc/pgbackrest/pgbackrest.conf", "src": "/home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source", "md5sum": "f5f410521b8c111536934fdad55902ea", "checksum": "39b82b1660166f6852b5e1ae9cd7865a7a0cd390", "changed": true, "uid": 3354, "gid": 20105, "owner": "pgbackrest", "group": "pgbackrest", "mode": "0640", "state": "file", "secontext": "system_u:object_r:etc_t:s0", "size": 739, "invocation": {"module_args": {"src": "/home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source", "dest": "/etc/pgbackrest/pgbackrest.conf", "mode": "0640", "owner": "pgbackrest", "group": "pgbackrest", "_original_basename": "repo_pgbackrest.conf", "follow": false, "checksum": "39b82b1660166f6852b5e1ae9cd7865a7a0cd390", "backup": false, "force": true, "unsafe_writes": false, "content": null, "validate": null, "directory_mode": null, "remote_src": null, "local_follow": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\r\n', b'Shared connection to vm-xzy.local> closed.\r\n')
<vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
<vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'rm -f -r /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/ > /dev/null 2>&1 && sleep 0'"'"''
<vm-xzy.local> (0, b'', b'')
changed: [vm-xzy.local>] => (item=/etc/pgbackrest/pgbackrest.conf) => changed=true
ansible_loop_var: item
checksum: 39b82b1660166f6852b5e1ae9cd7865a7a0cd390
dest: /etc/pgbackrest/pgbackrest.conf
diff: []
gid: 20105
group: pgbackrest
invocation:
module_args:
_original_basename: repo_pgbackrest.conf
attributes: null
backup: false
checksum: 39b82b1660166f6852b5e1ae9cd7865a7a0cd390
content: null
dest: /etc/pgbackrest/pgbackrest.conf
directory_mode: null
follow: false
force: true
group: pgbackrest
local_follow: null
mode: '0640'
owner: pgbackrest
remote_src: null
selevel: null
serole: null
setype: null
seuser: null
src: /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source
unsafe_writes: false
validate: null
item: /etc/pgbackrest/pgbackrest.conf
md5sum: f5f410521b8c111536934fdad55902ea
mode: '0640'
owner: pgbackrest
secontext: system_u:object_r:etc_t:s0
size: 739
src: /home/stepuser/.ansible/tmp/ansible-tmp-1657881160.6701202-537076-79922878271813/source
state: file
uid: 3354
 
 
 

Dick Visser

unread,
Jul 17, 2022, 3:12:00 AM7/17/22
to ansible...@googlegroups.com
Hi

On Fri, 15 Jul 2022 at 13:07, dulhaver via Ansible Project
<ansible...@googlegroups.com> wrote:

> sorry, you are right I did not provide the -vvv output. I tested this once again though and it showed that the copying
>
>
> does not work with dest: " {{ item }} "

I think your definition of "it works" is incorrect, see below

.....
> <vm-xzy.local> ESTABLISH SSH CONNECTION FOR USER: stepuser
> <vm-xzy.local> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="stepuser"' -o ConnectTimeout=10 -o 'ControlPath="/home/gwagner/.ansible/cp/b5d05b761c"' vm-xzy.local> '/bin/sh -c '"'"'rm -f -r /home/stepuser/.ansible/tmp/ansible-tmp-1657880906.308936-536971-114267205405617/ > /dev/null 2>&1 && sleep 0'"'"''
> <vm-xzy.local> (0, b'', b'')
> ok: [vm-xzy.local>] => (item=/etc/pgbackrest/pgbackrest.conf) => changed=false

^^^ This clearly says "ok" so as far as ansible is concerned, things *did* work.
It's not what you expected, but that's because you didn't give ansible
the correct input.
Your loop item is a string that starts with a slash, which, if used as
'dest' parameter for the copy command, is considered an absolute path.
But because of your superfluous spaces it will be considered a *relative* path.
Ansible will try to copy the file to that path, and according to your
logs, that was successful.
It doesn't actually list the full path, but from the logs it will
likely be '/home/stepuser/ /etc/pgbackrest/pgbackrest.conf '.
Note that this includes a directory with a name that is just a space,
which, depending on your shell setup, is not easy to spot - especially
if you don't expect it.
Also the file name will have a trailing space.

One strange thing is that the copy module does not create any parent
directory structures for files, so I wonder how that got created.

dulh...@mailbox.org

unread,
Jul 18, 2022, 8:24:32 AM7/18/22
to ansible...@googlegroups.com
> It doesn't actually list the full path, but from the logs it will
> likely be '/home/stepuser/ /etc/pgbackrest/pgbackrest.conf '.
> Note that this includes a directory with a name that is just a space,
> which, depending on your shell setup, is not easy to spot - especially
> if you don't expect it. Also the file name will have a trailing space.

spot on, thx for the explanation. I didn't use Ansible for a couple of months and it seems getting back on the horse takes a litte time just for getting the essentials back up'n'running


> One strange thing is that the copy module does not create any parent
> directory structures for files, so I wonder how that got created.

I ran this and other variants of the TASK a couple of times against that host. So, maybe in one of those rounds the directory somehow got created accidentally.
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF8BbLa_uWRSBSQC3jv6k_b4V_qzqFPWBaeHYzsWwnH1_syi5Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages