Seems like the module command: parameter isn’t working. Anyone have the same error?
playbook:
Seems like the module command: parameter isn’t working. Anyone have the same error?
playbook:
Seems like the module command: parameter isn’t working. Anyone have the same error?
Hello Mike,
the tar binary is probably missing in the $PATH Ansible is using. The $PATH is most likely different compared to $PATH
the interactive shell is using on the host.
Also consider to use the unarchive module instead.
Regards
Racke
I looked for a “tar” module; I had forgotten about “unarchive”. I have changed my playbook and the relevant changed sections are below. I still get an error:
The changed sections of the playbook:
name: “copy {{file}} to the {{ansible_host}}”
copy:
src=“…/templates/{{file}}”
dest=“{{installdir}}/{{file}}”
owner=“root”
group=“root”
mode=“0644”
backup=“yes”
name: “extract {{file}}”
unarchive:
src=“{{installdir}}/{{file}}”
dest=“{{installdir}}”
register: x
debug:
msg=“installdir=‘{{installdir}}’ file=‘{{file}}’ command=‘{{y}}’ unarchive='{{x}}”
fail: msg=“doing fail for testing”
Output from: ansible-playbook —limit had-dbora-s1 -vvv carbonblackresponse.yml
2021-07-23 10:38:59,326 p=3699 u=meggleston n=ansible | TASK [extract CarbonBlackLinuxDevelopment-210721.tar.gz] **********************************************************************************************
2021-07-23 10:38:59,346 p=3751 u=meggleston n=ansible | ESTABLISH SSH CONNECTION FOR USER: None
2021-07-23 10:38:59,347 p=3751 u=meggleston n=ansible | SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/meggleston/.ansible/cp/7058214ea1 hqd-dbora-n2 ‘/bin/sh -c ‘"’"’( umask 77 && mkdir -p “echo /tmp
”&& mkdir “echo /tmp/ansible-tmp-1627051139.35-3751-266795384375758
” && echo ansible-tmp-1627051139.35-3751-266795384375758=“echo /tmp/ansible-tmp-1627051139.35-3751-266795384375758
” ) && sleep 0’“'”‘’
2021-07-23 10:38:59,399 p=3751 u=meggleston n=ansible | (0, ‘ansible-tmp-1627051139.35-3751-266795384375758=/tmp/ansible-tmp-1627051139.35-3751-266795384375758\n’, ‘’)
2021-07-23 10:38:59,400 p=3751 u=meggleston n=ansible | ESTABLISH SSH CONNECTION FOR USER: None
2021-07-23 10:38:59,401 p=3751 u=meggleston n=ansible | SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/meggleston/.ansible/cp/7058214ea1 hqd-dbora-n2 ‘/bin/sh -c ‘"’“‘rm -f -r /tmp/ansible-tmp-1627051139.35-3751-266795384375758/ > /dev/null 2>&1 && sleep 0’”’"‘’
2021-07-23 10:38:59,444 p=3751 u=meggleston n=ansible | (0, ‘’, ‘’)
2021-07-23 10:38:59,449 p=3699 u=meggleston n=ansible | fatal: [hqd-dbora-n2]: FAILED! => {
“changed”: false,
“msg”: “Could not find or access ‘/tmp/CarbonBlack-install/CarbonBlackLinuxDevelopment-210721.tar.gz’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”
}
2021-07-23 10:38:59,450 p=3699 u=meggleston n=ansible | PLAY RECAP ********************************************************************************************************************************************
2021-07-23 10:38:59,451 p=3699 u=meggleston n=ansible | hqd-dbora-n2 : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Output of the directory showing the file is there:
[meggleston@hq-mgtlinux-s1 ~]$ ssh hqd-dbora-n2 ls -l /tmp /tmp/CarbonBlack-install /tmp/CarbonBlack-install/CarbonBlackLinuxDevelopment-210721.tar.gz ; date
-rw-r–r–. 1 root root 52643490 Jul 23 09:50 /tmp/CarbonBlack-install/CarbonBlackLinuxDevelopment-210721.tar.gz
/tmp:
total 0
drwxr-xr-x. 2 root root 55 Jul 23 09:50 CarbonBlack-install
/tmp/CarbonBlack-install:
total 51412
-rw-r–r–. 1 root root 52643490 Jul 23 09:50 CarbonBlackLinuxDevelopment-210721.tar.gz
Fri Jul 23 10:42:39 EDT 2021
I looked for a “tar” module; I had forgotten about “unarchive”. I have changed my playbook and the relevant changed sections are below. I still get an error:
"msg": "Could not find or access '/tmp/CarbonBlack-install/CarbonBlackLinuxDevelopment-210721.tar.gz' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"
What part of this error message is unclear?
Regards
Racke
Below the error message I showed where the file does exist on the remote host.
The file is on the remote host, as shown in the output below the error message, but the error message does say the file for “unarchive” "on the Ansible Controller”. Why is “unarchive” module looking on the Ansible controller for the file?
The file is on the remote host, as shown in the output below the error message, but the error message does say the file for “unarchive” "on the Ansible Controller”. Why is “unarchive” module looking on the Ansible controller for the file?
It is all in the error message:
expect the file to exist on the remote, see the remote_src option
Works the same way as "copy" module does.
Regards
Racke
Duh. Thank you.
Well, I changed things around and used the shell module rather than the command module. I put “cd {{installdir}} ; sh {{script}}” in the playbook. The full playbook is here: