Giter Site home page Giter Site logo

Comments (13)

nicolaibaralmueller avatar nicolaibaralmueller commented on August 24, 2024 1

You are correct again @kurokobo. This was not an issue in older AWX versions.

Now the playbook runs as expected but another issue arises:

Unable to connect to vCenter or ESXi API at virtualcenter.domain.local on TCP/443: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1124)

I solved this issue in AWX 15.0.1 by executing /usr/bin/update-crypto-policies --set LEGACY in the containers.

I will continue the good fight ;)

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

@nicolaibaralmueller
The error means that you can't use sudo, not that you can't use community.vmware.

commynity.vmware is preinstalled in the Execution Environment which used in AWX by default (awx-ee).

If you just want to use community.vmware, you can probably just add become: false to your playbook and remove the task Make sure requirements are met to run vmware modules, then the error will go away.

from awx-on-k3s.

nicolaibaralmueller avatar nicolaibaralmueller commented on August 24, 2024

You are absolutely right. Thx @kurokobo.

Still not working though. Added requests to pip install but still got the below error.

ModuleNotFoundError: No module named 'requests'

This is not your issue though and will report to the collection repo.

from awx-on-k3s.

nicolaibaralmueller avatar nicolaibaralmueller commented on August 24, 2024

btw: How I can update the awx-ee image used in the installation? This might fix the issue.

EE_BASE_IMAGE should be quay.io/ansible/ansible-runner:stable-2.11-latest

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

Hmm the default awx-ee already includes requests. In my environment, community.vmware.vmware_guest_info works good with any of the following Execution Environments.

  • quay.io/ansible/awx-ee:0.5.0 (This is default for AWX 19.2.2)
  • quay.io/ansible/awx-ee:0.6.0.
  • quay.io/ansible/awx-ee:latest (This is default for AWX 19.3.0)

You may want to check that the AWX correctly uses one of these Execution Environments.

If you want to build your own EE yourself anyway, you will need to use ansible-builder. Instruction is also available in my repo: https://github.com/kurokobo/awx-on-k3s/tree/main/builder

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

Have you changed the ansible_python_interpreter for the job anywhere in your inventory, job templates, or extra variables?
Or make sure the playbook is running on localhost (connection: local).

from awx-on-k3s.

nicolaibaralmueller avatar nicolaibaralmueller commented on August 24, 2024

Have you changed the ansible_python_interpreter for the job anywhere in your inventory, job templates, or extra variables?
Or make sure the playbook is running on localhost (connection: local).

Nope. Running below playbook against localhost (inventory) in AWX.

---
- hosts: localhost
  gather_facts: no
  roles:
  - { role: vmware-add-facts }
  post_tasks:
  - name: Export virtual machine facts
    community.vmware.vmware_guest_info:
      hostname: "{{ hostname }}"
      username: '{{ domain_user }}'
      password: "{{ domain_password }}"
      datacenter: "{{ datacenter }}"
      validate_certs: no
      schema: vsphere
      name: VM01
    register: virtualmachine_facts

  - debug: var=virtualmachine_facts

This is the complete output:

Enter passphrase for /runner/artifacts/35/ssh_key_data: 
Identity added: /runner/artifacts/35/ssh_key_data (/runner/artifacts/35/ssh_key_data)
[WARNING]: You are running the development version of Ansible. You should only
run Ansible from "devel" if you are modifying the Ansible engine, or trying out
features under development. This is a rapidly changing source of code and can
become unstable at any point.
ansible-playbook [core 2.12.0.dev0]
  config file = /runner/project/ansible.cfg
  configured module search path = ['/runner/project/Modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.8.6 (default, Jan 29 2021, 17:38:16) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
Using /runner/project/ansible.cfg as config file
Vault password: 
host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
Parsed /runner/inventory/hosts inventory source with script plugin
Skipping callback 'awx_display', as we already have a stdout callback.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: vmware_test.yml ******************************************************
1 plays in Playbooks/VMware/vmware_test.yml

PLAY [localhost] ***************************************************************
META: ran handlers

TASK [vmware-add-facts : Set VMware facts] *************************************
task path: /runner/project/Roles/vmware-add-facts/tasks/main.yml:3
ok: [127.0.0.1] => {
    "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result",
    "changed": false
}
META: role_complete for 127.0.0.1
META: ran handlers

TASK [Export virtual machine facts] ********************************************
task path: /runner/project/Playbooks/VMware/vmware_test.yml:16
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: runner
<127.0.0.1> EXEC /bin/sh -c 'echo ~runner && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/runner/.ansible/tmp `"&& mkdir "` echo /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196 `" && echo ansible-tmp-1630585517.0975893-74-96176537889196="` echo /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196 `" ) && sleep 0'
Using module file /runner/requirements_collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_info.py
<127.0.0.1> PUT /home/runner/.ansible/tmp/ansible-local-20x0gt007_/tmphyunxz9a TO /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196/AnsiballZ_vmware_guest_info.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196/ /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196/AnsiballZ_vmware_guest_info.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/libexec/platform-python /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196/AnsiballZ_vmware_guest_info.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/runner/.ansible/tmp/ansible-tmp-1630585517.0975893-74-96176537889196/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.vmware.vmware_guest_info_payload_suy3w41g/ansible_community.vmware.vmware_guest_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py", line 26, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
fatal: [127.0.0.1]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "datacenter": "DC01",
            "folder": null,
            "hostname": "virtualcenter.domain.local",
            "moid": null,
            "name": "VM01",
            "name_match": "first",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "properties": null,
            "proxy_host": null,
            "proxy_port": null,
            "schema": "vsphere",
            "tag_details": false,
            "tags": false,
            "use_instance_uuid": false,
            "username": "[email protected]",
            "uuid": null,
            "validate_certs": false
        }
    },
    "msg": "Failed to import the required Python library (requests) on automation-job-35-75jhk's Python /usr/libexec/platform-python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}

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

Seems to be python related issue.

As a side note playbooks also mentions this:
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

Thanks for the complete output. This is no longer an issue about the contents of my repository, but I'll comment on something I noticed 😄

Seems you have ansible.cfg in your project root, and you invoke vmware-add-facts role before the task.

  • Are you specifying anything in ansible.cfg, such as library to modify module search path?
  • Check the tasks in vmware-add-facts role whether there are something which change the path for Python or Ansible related.

I mean, in your output, the search path for the module is;

ansible-playbook [core 2.12.0.dev0]
  config file = /runner/project/ansible.cfg
  configured module search path = ['/runner/project/Modules'] 👈👈👈

Also, /usr/libexec/platform-python is being used for your playbook.

<127.0.0.1> EXEC /bin/sh -c '/usr/libexec/platform-python /home/runner/.ansible/... 👈👈👈

But in my environment, the search path for the module is as shown below. This is the default value when there is no ansible.cfg.

ansible-playbook [core 2.12.0.dev0]
  config file = None
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] 👈👈👈

And /usr/bin/python3 is used to invoke playbook.

<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/runner/.ansible/... 👈👈👈

I think your ansible.cfg or vmware-add-facts role is causing some unintended effects.

from awx-on-k3s.

nicolaibaralmueller avatar nicolaibaralmueller commented on August 24, 2024

You are very helpful. Beyond what is expected. Thx

The role just contains set_fact call since some variables are vaulted.

ansible.cfg contains only library = Modules in regards to modules.

Just changed the line to library = Modules:/home/runner/.ansible/plugins/modules:/usr/share/ansible/plugins/modules

But same error:

Enter passphrase for /runner/artifacts/41/ssh_key_data: 
Identity added: /runner/artifacts/41/ssh_key_data (/runner/artifacts/41/ssh_key_data)
[WARNING]: You are running the development version of Ansible. You should only
run Ansible from "devel" if you are modifying the Ansible engine, or trying out
features under development. This is a rapidly changing source of code and can
become unstable at any point.
ansible-playbook [core 2.12.0.dev0]
  config file = /runner/project/ansible.cfg
  configured module search path = ['/runner/project/Modules', '/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.8.6 (default, Jan 29 2021, 17:38:16) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 2.10.3
  libyaml = True
Using /runner/project/ansible.cfg as config file
Vault password: 
host_list declined parsing /runner/inventory/hosts as it did not pass its verify_file() method
Parsed /runner/inventory/hosts inventory source with script plugin
Skipping callback 'awx_display', as we already have a stdout callback.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: vmware_test.yml ******************************************************
1 plays in Playbooks/VMware/vmware_test.yml

PLAY [localhost] ***************************************************************
META: ran handlers

TASK [vmware-add-facts : Set VMware facts] *************************************
task path: /runner/project/Roles/vmware-add-facts/tasks/main.yml:3
ok: [127.0.0.1] => {
    "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result",
    "changed": false
}
META: role_complete for 127.0.0.1
META: ran handlers

TASK [Export virtual machine facts] ********************************************
task path: /runner/project/Playbooks/VMware/vmware_test.yml:8
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: runner
<127.0.0.1> EXEC /bin/sh -c 'echo ~runner && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/runner/.ansible/tmp `"&& mkdir "` echo /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888 `" && echo ansible-tmp-1630653333.580897-31-198337812307888="` echo /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888 `" ) && sleep 0'
<127.0.0.1> Attempting python interpreter discovery
<127.0.0.1> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3.8 && sleep 0'
Using module file /runner/requirements_collections/ansible_collections/community/vmware/plugins/modules/vmware_guest_info.py
<127.0.0.1> PUT /home/runner/.ansible/tmp/ansible-local-20brg61loo/tmpv73bmco3 TO /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888/AnsiballZ_vmware_guest_info.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888/ /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888/AnsiballZ_vmware_guest_info.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/libexec/platform-python /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888/AnsiballZ_vmware_guest_info.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/runner/.ansible/tmp/ansible-tmp-1630653333.580897-31-198337812307888/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.vmware.vmware_guest_info_payload_2bqm6z8h/ansible_community.vmware.vmware_guest_info_payload.zip/ansible_collections/community/vmware/plugins/module_utils/vmware.py", line 26, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
fatal: [127.0.0.1]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "datacenter": "DC01",
            "folder": null,
            "hostname": "virtualacenter.domain.local",
            "moid": null,
            "name": "VM01",
            "name_match": "first",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 443,
            "properties": null,
            "proxy_host": null,
            "proxy_port": null,
            "schema": "vsphere",
            "tag_details": false,
            "tags": false,
            "use_instance_uuid": false,
            "username": "[email protected]",
            "uuid": null,
            "validate_certs": false
        }
    },
    "msg": "Failed to import the required Python library (requests) on automation-job-41-2z79x's Python /usr/libexec/platform-python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}

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

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

any hosts file in your project?

from awx-on-k3s.

nicolaibaralmueller avatar nicolaibaralmueller commented on August 24, 2024

any hosts file in your project?

Nope. I just created a AWX inventory 'localhost' with group 'localhost' and host '127.0.0.1'.

I am not specifying any python executable anywhere. this is a fresh install with just the one playbook.

Also tried commenting out the library variable in ansible.cfg alltogether but still same error.

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

I just created a AWX inventory 'localhost' with group 'localhost' and host '127.0.0.1'.

Ah, that is...
Remove the host 127.0.0.1. It's ok to keep localhost group or inventory empty.

from awx-on-k3s.

kurokobo avatar kurokobo commented on August 24, 2024

Alternatively you can add these two variables as variables for 127.0.0.1

ansible_connection: local
ansible_python_interpreter: '{{ ansible_playbook_python }}'

The localhost of the Demo Inventory is configured in the same way by default.

image

from awx-on-k3s.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.