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"
}
---------------
I changed the p[laybook to copy
---
- hosts: localhost
vars:
name_iso: VMware-VCSA-all-6.7.0-16046470.iso
tasks:
- name: Creating a Directory to mount the iso file
become: yes
become_method: sudo
file:
path: /mnt/iso
state: directory
mode: 0777
- name: Mount vCSA6.7 iso to /mnt/iso directory
mount:
path: /mnt/iso
src: /home/tony/temp/{{name_iso}}
fstype: iso9660
opts: ro,noauto
state: mounted
become: yes
become_method: sudo
- name: Creating a Working Directory
become: yes
file:
path: /vcsa
state: directory
mode: 0777
- name: Copying contents to working Directory
copy:
src: /mnt/iso/*
dest: /vcsa
- name: deployment of vcsa
shell: ./vcsa-deploy install --no-esx-ssl-verify --accept-eula
--acknowledge-ceip /home/tony/ansible-vmware/vcsa-deploy/config.json
become: yes
become_method: sudo
On Mon, Jun 1, 2020 at 9:53 PM Dick Visser <[email protected]> wrote:
> 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
>
>
> On Tue, 2 Jun 2020 at 00:45, Tony Wong <[email protected]> wrote:
>
>> 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
>>
>> On Mon, Jun 1, 2020 at 1:37 PM Dick Visser <[email protected]> wrote:
>>
>>> 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.
>>>
>>>
>>> On Mon, 1 Jun 2020 at 22:23, Tony Wong <[email protected]> wrote:
>>> >
>>> > 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
>>> >
>>> >
>>> > On Mon, Jun 1, 2020 at 11:58 AM Ompragash <[email protected]>
>>> wrote:
>>> >>
>>> >> 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].
>>> >>
>>> >> -
>>> >> Ompragash
>>> >>
>>> >> On Tue, 2 Jun 2020 at 00:12, Tony Wong <[email protected]> wrote:
>>> >>>
>>> >>> I am trying to deploy new vmware vcsa appliance from iso usibg
>>> ansible
>>> >>>
>>> >>>
>>> >>> below is playbook
>>> >>>
>>> >>> ---
>>> >>> - hosts: localhost
>>> >>> vars:
>>> >>> name_iso: VMware-VCSA-all-6.7.0-16046470.iso
>>> >>> tasks:
>>> >>> - name: Creating a Directory to mount the iso file
>>> >>> become: yes
>>> >>> file:
>>> >>> path: /mnt/iso
>>> >>> state: directory
>>> >>> mode: 0777
>>> >>> - name: Mount vCSA6.7 iso to /mnt/iso directory
>>> >>> mount:
>>> >>> path: /mnt/iso
>>> >>> src: /home/tony/temp/{{name_iso}}
>>> >>> fstype: iso9660
>>> >>> opts: ro,noauto
>>> >>> state: present
>>> >>> - name: Creating a Working Directory
>>> >>> become: yes
>>> >>> file:
>>> >>> path: /vcsa
>>> >>> state: directory
>>> >>> mode: 0777
>>> >>> - name: Copying contents to working Directory
>>> >>> template:
>>> >>> src: /mnt/iso/*
>>> >>> dest: /vcsa
>>> >>> - name: deployment of vcsa
>>> >>> shell: ./vcsa-deploy install --no-esx-ssl-verify
>>> --accept-eula --acknowledge-ceip
>>> /home/tony/ansible-vmware/vcsa-deploy/config.json
>>> >>> args:
>>> >>> chdir: /VCSA-new/vcsa-cli-installer/lin64/
>>> >>>
>>> >>>
>>> >>> but its failing on the iso mount part
>>> >>>
>>> >>>
>>> >>> any idea?
>>> >>>
>>> >>>
>>> >>> TASK [Mount vCSA6.7 iso to /mnt/iso directory]
>>> *************************************************************************************************************************************
>>> >>> An exception occurred during task execution. To see the full
>>> traceback, use -vvv. The error was: IOError: [Errno 13] Permission denied:
>>> '/etc/fstab'
>>> >>> fatal: [127.0.0.1]: FAILED! => {"changed": false, "module_stderr":
>>> "Traceback (most recent call last):\n File
>>> \"/home/tony/.ansible/tmp/ansible-tmp-1591036438.98-60861409289967/AnsiballZ_mount.py\",
>>> line 102, in <module>\n _ansiballz_main()\n File
>>> \"/home/tony/.ansible/tmp/ansible-tmp-1591036438.98-60861409289967/AnsiballZ_mount.py\",
>>> line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path,
>>> ANSIBALLZ_PARAMS)\n File
>>> \"/home/tony/.ansible/tmp/ansible-tmp-1591036438.98-60861409289967/AnsiballZ_mount.py\",
>>> line 40, in invoke_module\n
>>> runpy.run_module(mod_name='ansible.modules.system.mount',
>>> init_globals=None, run_name='__main__', alter_sys=False)\n File
>>> \"/usr/lib/python2.7/runpy.py\", line 192, in run_module\n fname,
>>> loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 72, in
>>> _run_code\n exec code in run_globals\n File
>>> \"/tmp/ansible_mount_payload_ufhUI0/ansible_mount_payload.zip/ansible/modules/system/mount.py\",
>>> line 751, in <module>\n File
>>> \"/tmp/ansible_mount_payload_ufhUI0/ansible_mount_payload.zip/ansible/modules/system/mount.py\",
>>> line 735, in main\n File
>>> \"/tmp/ansible_mount_payload_ufhUI0/ansible_mount_payload.zip/ansible/modules/system/mount.py\",
>>> line 284, in set_mount\n File
>>> \"/tmp/ansible_mount_payload_ufhUI0/ansible_mount_payload.zip/ansible/modules/system/mount.py\",
>>> line 163, in write_fstab\nIOError: [Errno 13] Permission denied:
>>> '/etc/fstab'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee
>>> stdout/stderr for the exact error", "rc": 1}
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> 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 [email protected].
>>> >>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/22c83ca2-606e-4d0f-8ed4-22cddeb0a6a5%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 [email protected].
>>> >> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAEFccTX2-HH65gouyq-7YZ4Z5m8%2BwpjSvAJyWNFrguNZf3wiuQ%40mail.gmail.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 [email protected].
>>> > To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CALmkhkoGLotrkxzDqk1%2BZmc8iex%2B9yvNCfR9cZ9mZUz2i%2BFjKQ%40mail.gmail.com
>>> .
>>>
>>>
>>>
>>> --
>>> Dick Visser
>>> Trust & Identity Service Operations Manager
>>> GÉANT
>>>
>>> --
>>> 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 [email protected].
>>>
>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMcsxqBXuP55jR_X7%3D3HSoamqz-pSxoTEEZFAV%3DKT3g9w%40mail.gmail.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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CALmkhkoCuvoPG501QesOccz89c8h2NisK%3DTvv989J4iBVUFWfg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CALmkhkoCuvoPG501QesOccz89c8h2NisK%3DTvv989J4iBVUFWfg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwNAAE-ZmOBXOJ3Nbgh6QEYUOiG%2BdQ%3Drvd3i5vsDrDUSeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwNAAE-ZmOBXOJ3Nbgh6QEYUOiG%2BdQ%3Drvd3i5vsDrDUSeA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CALmkhkq9WGyY39eAPAOit9mkhb71S%3DwVPk6sycjxO-BoxOjj6g%40mail.gmail.com.