cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Starfighter Starfighter
Starfighter
  • 3,330 Views

ansible fetch module

Hello all,

Got a question concerning the fetch module in an ad-hoc command.

Note:
- I'm executing the ad-hoc command using an account named "student1"; a  non-priv user account
- The targeted (managed) node is named "rh2"

First ad-hoc command syntax:

$   ansible  rh2  -m  fetch  -a  "src=/tmp/donkey  dest=~"

rh2 | CHANGED => {
"changed": true,
"checksum": "e1f48cd1226e4ce7ab8bf87d15ce7c9b0014cf16",
"dest": "/home/student1/rh2/tmp/donkey",
"md5sum": "5b9d07ad9c1bed09d6986e593f4ca7dc",
"remote_checksum": "e1f48cd1226e4ce7ab8bf87d15ce7c9b0014cf16",
"remote_md5sum": null

 

Second ad-hoc command syntax:

ansible  rh2  -m  fetch  -a  "src=/tmp/donkey  dest=~  flat=yes"

rh2 | FAILED! => {
"changed": false,
"checksum": null,
"dest": "/home/student1",
"file": "/tmp/donkey",
"md5sum": null,
"msg": "checksum mismatch",
"remote_checksum": "e1f48cd1226e4ce7ab8bf87d15ce7c9b0014cf16",
"remote_md5sum": null

 

Okay, as you can see, the only difference is the inclusion of the parameter flat=yes.

First, both ad-hoc commands copy the file /tmp/donkey from the targeted host, to
the controller host.  However, you can see from the output of the second ad-hoc
command, that the status of the task is being reported as FAILED.   Also, "changed"
is showing a result of "false" - and yet, the file was copied to the controller host.

Does anyone have an idea as to why the second ad-hoc syntax actually copies the
file to the controller host, but ansible reports the outcome as FAILED?  That file 
named "donkey" is absolutely in the /home/student1 directory, after the ad-hoc 
command is executed.  While I'm at it, I may as well confess that the "checksum 
mismatch" message in the output of the second ad-hoc command is also disturbing
me.

Thanks in advance.

Trevor

 

 

Trevor "Red Hat Evangelist" Chandler
Labels (2)
0 Kudos
3 Replies
Sillihkram
Flight Engineer
Flight Engineer
  • 3,186 Views

It would seem the flat parameter does not work with validate_checksum=true (default)

$ ansible -m fetch -a "src=/tmp/donkey dest=~ flat=yes validate_checksum=false" shaula

shaula | CHANGED => {
"changed": true,
"checksum": null,
"dest": "/home/mhillis",
"md5sum": null,
"remote_checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"remote_md5sum": null
}

 

Sillihkram
Flight Engineer
Flight Engineer
  • 3,183 Views

this module uses sha1 for checksum and that's deprecated in RHEL9. I would consider making a pull request here as the flat parameter should not break the validate_checksum function.

$ ansible -vvv -m fetch -a "src=/tmp/donkey dest=~ flat=yes validate_checksum=false" shaula | grep sum


<shaula> (0, b'\r\n{"changed": false, "stat": {"exists": true, "path": "/tmp/donkey", "mode": "0775", "isdir": false, "ischr": false, "isblk": false, "isreg": true, "isfifo": false, "islnk": false, "issock": false, "uid": 1000, "gid": 10, "size": 0, "inode": 1456, "dev": 64768, "nlink": 1, "atime": 1654717819.581362, "mtime": 1654717632.1223679, "ctime": 1654717632.1223679, "wusr": true, "rusr": true, "xusr": true, "wgrp": true, "rgrp": true, "xgrp": true, "woth": false, "roth": true, "xoth": true, "isuid": false, "isgid": false, "blocks": 0, "block_size": 4096, "device_type": 0, "readable": true, "writeable": true, "executable": true, "pw_name": "mhillis", "gr_name": "wheel", "checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709", "mimetype": "inode/x-empty", "charset": "binary", "version": "2641741203", "attributes": [], "attr_flags": ""}, "invocation": {"module_args": {"path": "/tmp/donkey", "follow": true, "get_checksum": true, "checksum_algorithm": "sha1", "get_md5": false, "get_mime": true, "get_attributes": true}}}\r\n', b'Shared connection to shaula closed.\r\n')
"checksum": null,
"md5sum": null,
"remote_checksum": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"remote_md5sum": null

Sillihkram
Flight Engineer
Flight Engineer
  • 3,182 Views

There is a bug open apparently it only works if used in conjunction with become

https://github.com/ansible/ansible/issues/69383 

Join the discussion
You must log in to join this conversation.