An exception occurred during task execution.

118 views
Skip to first unread message

Tony Wong

unread,
Jun 1, 2020, 2:42:42 PM6/1/20
to Ansible Project
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}



 

Ompragash

unread,
Jun 1, 2020, 2:58:21 PM6/1/20
to ansible...@googlegroups.com
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

--
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/22c83ca2-606e-4d0f-8ed4-22cddeb0a6a5%40googlegroups.com.

Tony Wong

unread,
Jun 1, 2020, 4:23:31 PM6/1/20
to ansible...@googlegroups.com
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


Dick Visser

unread,
Jun 1, 2020, 4:37:21 PM6/1/20
to ansible...@googlegroups.com
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.
> 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

Tony Wong

unread,
Jun 1, 2020, 6:46:04 PM6/1/20
to ansible...@googlegroups.com
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

Dick Visser

unread,
Jun 2, 2020, 12:53:46 AM6/2/20
to ansible...@googlegroups.com
There is no copy task in your playbook.
There is a template task, which is meant for... templating files.



--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Tony Wong

unread,
Jun 2, 2020, 9:05:27 AM6/2/20
to ansible...@googlegroups.com
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

Stefan Hornburg (Racke)

unread,
Jun 2, 2020, 9:15:15 AM6/2/20
to ansible...@googlegroups.com
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
> ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>.
> >>> 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
> ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>.
> >> 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
> ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>.
> > 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
> ansible-proje...@googlegroups.com <mailto:ansible-project%2Bunsu...@googlegroups.com>.
>
> 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
> 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/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
> 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/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
> 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/CALmkhkq9WGyY39eAPAOit9mkhb71S%3DwVPk6sycjxO-BoxOjj6g%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CALmkhkq9WGyY39eAPAOit9mkhb71S%3DwVPk6sycjxO-BoxOjj6g%40mail.gmail.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Tony Wong

unread,
Jun 2, 2020, 9:59:27 AM6/2/20
to ansible...@googlegroups.com
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

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/040ae9e5-f762-ffcd-d701-98e75e07ece4%40linuxia.de.

Tony Wong

unread,
Jun 2, 2020, 10:21:22 AM6/2/20
to ansible...@googlegroups.com
ok I got the copy to work. 

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

Tony Wong

unread,
Jun 2, 2020, 10:54:56 AM6/2/20
to ansible...@googlegroups.com
ok got it working now
Reply all
Reply to author
Forward
0 new messages