An exception occurred during task execution.

I am trying to deploy new vmware vcsa appliance from iso usibg ansible

below is playbook

As you can see “IOError: [Errno 13] Permission denied: ‘/etc/fstab’”, you’re executing the playbook with an unprivileged user. Try running the playbook with privileged user or use become directive for TASK [Mount vCSA6.7 iso to /mnt/iso directory].

thanks now i get this

TASK [Creating a Directory to mount the iso file] ***********************************************************************************************************************************
task path: /home/tony/ansible-vmware/vcsa-deploy/vcsa-deploy.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c ‘echo ~tony && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299” && echo ansible-tmp-1591038655.19-107209855175299=“echo /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299” ) && sleep 0’
Using module file /home/tony/.local/lib/python2.7/site-packages/ansible/modules/files/file.py
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-14135_sPOWT/tmp_3K7YH TO /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299/AnsiballZ_file.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299/ /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299/AnsiballZ_file.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘sudo -H -S -n -u root /bin/sh -c ‘"’“‘echo BECOME-SUCCESS-ccrzovesmfdvvyqstimtyqlawdjpeaxf ; /usr/bin/python /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299/AnsiballZ_file.py’”’"’ && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1591038655.19-107209855175299/ > /dev/null 2>&1 && sleep 0’
fatal: [127.0.0.1]: FAILED! => {
“changed”: false,
“module_stderr”: “sudo: a password is required\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}

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

As you can see you ran into another privilege escalation issue.
Since this is an important topic, rather than going down the trial and
error path further, you are probably better of by reading the docs on
privilege escalation:
https://docs.ansible.com/ansible/latest/user_guide/become.html and try
to grasp the concept behind it.
It will be very useful.

ok got it fixed but now its having issues on next copying task

TASK [Creating a Working Directory] *************************************************************************************************************************************************
task path: /home/tony/ansible-vmware/vcsa-deploy/vcsa-deploy.yml:21
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c ‘echo ~tony && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181” && echo ansible-tmp-1591051342.78-219752301038181=“echo /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181” ) && sleep 0’
Using module file /home/tony/.local/lib/python2.7/site-packages/ansible/modules/files/file.py
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-14943p5pRVm/tmpg2MvtR TO /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181/AnsiballZ_file.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181/ /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181/AnsiballZ_file.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘sudo -H -S -p “[sudo via ansible, key=ymjggrenjkdverbptktaesjqbccosbfw] password:” -u root /bin/sh -c ‘"’“‘echo BECOME-SUCCESS-ymjggrenjkdverbptktaesjqbccosbfw ; /usr/bin/python /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181/AnsiballZ_file.py’”’"’ && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1591051342.78-219752301038181/ > /dev/null 2>&1 && sleep 0’
changed: [127.0.0.1] => {
“changed”: true,
“diff”: {
“after”: {
“mode”: “0777”,
“path”: “/vcsa”,
“state”: “directory”
},
“before”: {
“mode”: “0755”,
“path”: “/vcsa”,
“state”: “absent”
}
},
“gid”: 0,
“group”: “root”,
“invocation”: {
“module_args”: {
“_diff_peek”: null,
“_original_basename”: null,
“access_time”: null,
“access_time_format”: “%Y%m%d%H%M.%S”,
“attributes”: null,
“backup”: null,
“content”: null,
“delimiter”: null,
“directory_mode”: null,
“follow”: true,
“force”: false,
“group”: null,
“mode”: 511,
“modification_time”: null,
“modification_time_format”: “%Y%m%d%H%M.%S”,
“owner”: null,
“path”: “/vcsa”,
“recurse”: false,
“regexp”: null,
“remote_src”: null,
“selevel”: null,
“serole”: null,
“setype”: null,
“seuser”: null,
“src”: null,
“state”: “directory”,
“unsafe_writes”: null
}
},
“mode”: “0777”,
“owner”: “root”,
“path”: “/vcsa”,
“size”: 4096,
“state”: “directory”,
“uid”: 0
}

TASK [Copying contents to working Directory] ****************************************************************************************************************************************
task path: /home/tony/ansible-vmware/vcsa-deploy/vcsa-deploy.yml:27
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c ‘echo ~tony && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /home/tony/.ansible/tmp/ansible-tmp-1591051343.05-86141275342768” && echo ansible-tmp-1591051343.05-86141275342768=“echo /home/tony/.ansible/tmp/ansible-tmp-1591051343.05-86141275342768” ) && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1591051343.05-86141275342768/ > /dev/null 2>&1 && sleep 0’
fatal: [127.0.0.1]: FAILED! => {
“changed”: false,
“msg”: “Could not find or access ‘/mnt/iso/*’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”
}

PLAY RECAP **************************************************************************************************************************************************************************
127.0.0.1 : ok=4 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

There is no copy task in your playbook.
There is a template task, which is meant for… templating files.

https://docs.ansible.com/ansible/latest/modules/template_module.html

Have a look at the copy module:
https://docs.ansible.com/ansible/latest/modules/copy_module.html

why do I keep failing on this copy task?

TASK [Copying contents to working Directory] ***************************************************************************************************************************************
task path: /home/tony/ansible-vmware/vcsa-deploy/vcsa-deploy.yml:28
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c ‘echo ~tony && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /home/tony/.ansible/tmp/ansible-tmp-1591098693.86-2821013559691” && echo ansible-tmp-1591098693.86-2821013559691=“echo /home/tony/.ansible/tmp/ansible-tmp-1591098693.86-2821013559691” ) && sleep 0’
The full traceback is:
Traceback (most recent call last):
File “/home/tony/.local/lib/python2.7/site-packages/ansible/plugins/action/copy.py”, line 464, in run
source = self._find_needle(‘files’, source)
File “/home/tony/.local/lib/python2.7/site-packages/ansible/plugins/action/init.py”, line 1155, in _find_needle
return self._loader.path_dwim_relative_stack(path_stack, dirname, needle)
File “/home/tony/.local/lib/python2.7/site-packages/ansible/parsing/dataloader.py”, line 319, in path_dwim_relative_stack
raise AnsibleFileNotFound(file_name=source, paths=[to_native(p) for p in search])
AnsibleFileNotFound: Could not find or access ‘/mnt/iso/*’ on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option

fatal: [127.0.0.1]: FAILED! => {
“changed”: false,
“invocation”: {
“dest”: “/vcsa”,
“module_args”: {
“dest”: “/vcsa”,
“src”: “/mnt/iso/"
},
“src”: "/mnt/iso/

},
“msg”: “Could not find or access ‘/mnt/iso/*’ on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option”
}

why do I keep failing on this copy task?

TASK [Copying contents to working Directory]
***************************************************************************************************************************************
task path: /home/tony/ansible-vmware/vcsa-deploy/vcsa-deploy.yml:28
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c 'echo ~tony && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo
/home/tony/.ansible/tmp/ansible-tmp-1591098693.86-2821013559691 `" && echo ansible-tmp-1591098693.86-2821013559691="`
echo /home/tony/.ansible/tmp/ansible-tmp-1591098693.86-2821013559691 `" ) && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/home/tony/.local/lib/python2.7/site-packages/ansible/plugins/action/copy.py", line 464, in run
source = self._find_needle('files', source)
File "/home/tony/.local/lib/python2.7/site-packages/ansible/plugins/action/__init__.py", line 1155, in _find_needle
return self._loader.path_dwim_relative_stack(path_stack, dirname, needle)
File "/home/tony/.local/lib/python2.7/site-packages/ansible/parsing/dataloader.py", line 319, in path_dwim_relative_stack
raise AnsibleFileNotFound(file_name=source, paths=[to_native(p) for p in search])
AnsibleFileNotFound: Could not find or access '/mnt/iso/*' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option

fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"invocation": {
"dest": "/vcsa",
"module_args": {
"dest": "/vcsa",
"src": "/mnt/iso/*"
},
"src": "/mnt/iso/*"
},
"msg": "Could not find or access '/mnt/iso/*' on the Ansible Controller.\nIf you are using a module and expect the
file to exist on the remote, see the remote_src option"
}

Hello Tony,

the copy module doesn't expand wildcards, so you either need to lookup the files on the Ansible controller
or use the directory path as src parameter:

https://docs.ansible.com/ansible/latest/modules/copy_module.html#parameter-src

Regards
        Racke

I am trying to use iso_extract to copy the iso contents to a directory. can i do that? Still getting error

TASK [Copy contents to working directory] *****************************************************************************************************************************
task path: /home/tony/ansible-vmware/vcsa-deploy/vcsa-deploy.yml:29
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: tony
<127.0.0.1> EXEC /bin/sh -c ‘echo ~tony && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630” && echo ansible-tmp-1591106235.25-162698201745630=“echo /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630” ) && sleep 0’
Using module file /home/tony/.local/lib/python2.7/site-packages/ansible/modules/files/iso_extract.py
<127.0.0.1> PUT /home/tony/.ansible/tmp/ansible-local-18561PFMSaV/tmp7y39M1 TO /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630/AnsiballZ_iso_extract.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630/ /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630/AnsiballZ_iso_extract.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/usr/bin/python /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630/AnsiballZ_iso_extract.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /home/tony/.ansible/tmp/ansible-tmp-1591106235.25-162698201745630/ > /dev/null 2>&1 && sleep 0’
The full traceback is:
WARNING: The below traceback may not be related to the actual failure.
File “/tmp/ansible_iso_extract_payload_IbRncr/ansible_iso_extract_payload.zip/ansible/module_utils/basic.py”, line 1562, in _check_required_arguments
check_required_arguments(spec, param)
File “/tmp/ansible_iso_extract_payload_IbRncr/ansible_iso_extract_payload.zip/ansible/module_utils/common/validation.py”, line 193, in check_required_arguments
raise TypeError(to_native(msg))

fatal: [127.0.0.1]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“dest”: “/vcsa”,
“force”: true,
“image”: “/home/temp/VMware-VCSA-all-6.7.0-16046470.iso”
}
},
“msg”: “missing required arguments: files”

name: Copy contents to working directory
iso_extract:
image: /home/temp/VMware-VCSA-all-6.7.0-16046470.iso
dest: /vcsa

- name: deployment of vcsa

ok I got the copy to work.

instead of copying, cant I just run vcsa-deply directory from mnt/iso?

ok got it working now