0

I'm writing a playbook to perform some VMware tasks. The first step is to gather VM facts. However, I'm keep getting permission denied error.

That's the part of my code for getting the VM facts:

- name: Find VM's facts community.vmware.vmware_guest_info: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" datacenter: "{{ vmware_datacentres[vcenter_hostname] }}" name: "{{ ansible_fqdn }}" validate_certs: false delegate_to: localhost register: vm_facts - name: Debug vm_facts debug: var=vm_facts 

Error message:

TASK [vmware-test : Find VM's facts] ************************************************************************************************** fatal: [testhost1 -> localhost]: FAILED! => {"changed": false, "module_stderr": "\n/bin/sh: /home/neil/venv/Ansible/bin/python3.11: Permission denied\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 126} 

/home/neil/venv/Ansible/bin/python3.11 is the symbolic link to -rwxr-xr-x. 1 root root 7.6K Jun 20 02:05 /bin/python3.11

-vvv doesn't show any valuable information:

<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1725915868.587364-136219-255490713105262 `" && echo ansible-tmp-1725915868.587364-136219-255490713105262="` echo /tmp/ansible-tmp-1725915868.587364-136219-255490713105262 `" ) && sleep 0' Using module file /home/neil/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_info.py <localhost> PUT /home/neil/.ansible/tmp/ansible-local-135815w4jkzmib/tmp311y27ef TO /tmp/ansible-tmp-1725915868.587364-136219-255490713105262/AnsiballZ_vmware_guest_info.py <localhost> EXEC /bin/sh -c 'chmod u+x /tmp/ansible-tmp-1725915868.587364-136219-255490713105262/ /tmp/ansible-tmp-1725915868.587364-136219-255490713105262/AnsiballZ_vmware_guest_info.py && sleep 0' <localhost> EXEC /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=tobzmscvdwzdpmgluekcfjdklxdypfip] password:" -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-tobzmscvdwzdpmgluekcfjdklxdypfip ; /home/neil/venvs/Ansible/bin/python3.11 /tmp/ansible-tmp-1725915868.587364-136219-255490713105262/AnsiballZ_vmware_guest_info.py'"'"' && sleep 0' <localhost> EXEC /bin/sh -c 'rm -f -r /tmp/ansible-tmp-1725915868.587364-136219-255490713105262/ > /dev/null 2>&1 && sleep 0' 

The vcenter variables are stored in a separate var file. Credentials are correct.

Any thoughts?

2
  • If you log in as the same user Ansible is using, can you successfully run /home/neil/venv/Ansible/bin/python3.11? Commented Sep 9, 2024 at 23:46
  • Yes, I can source into the venv and execute python3.11 Commented Sep 9, 2024 at 23:53

1 Answer 1

-1

I must run it without root, so must set become: false in the playbook!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.