简体   繁体   中英

Ansible Tower custom environments

I'm running Ansible Tower v3.8.6 on a RHEL8 server and I've defined a custom environment by following this link. I've added this custom environment to under Settings - System - "Custom Virtual Environment Paths" and also made this custom environment the default for my organisation.

I've added the following to my playbook and it confirms that I'm using the "correct" version of ansible and python as defined in my custom virtual environment.`

- name: get ansible and python versions
  shell: |
    ansible --version
    python -V
  register: result

- name: display ansible and python versions
  debug:
    var: result.stdout

I setup this environment so I can interact with our Ovirt 4.5 environment. Despite the fact that I have the python ovirt sdk installed I keep getting this error.

"msg": "ovirtsdk4 version 4.4.0 or higher is required for this module"

I've googled and googled but none of the solutions work for me.

Is this a lost cause? Upgrading to Ansible Automation Platform is out of the question.

Any ideas how I can make this work?

#pwd
/var/lib/awx/venv/rhv-4.5
#source bin/activate
(rhv-4.5) #ansible --version
ansible [core 2.12.6]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/lib/awx/venv/rhv-4.5/lib/python3.8/site-packages/ansible
  ansible collection location = /var/lib/awx/vendor/inventory_collections:/opt/collections
  executable location = /var/lib/awx/venv/rhv-4.5/bin/ansible
  python version = 3.8.12 (default, Sep 16 2021, 10:46:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.1.2
  libyaml = True
(rhv-4.5) #python -V
Python 3.8.12
(rhv-4.5) #pip list
Package                 Version
----------------------- ---------
ansible-core            2.12.6
certifi                 2022.6.15
cffi                    1.15.1
charset-normalizer      2.1.1
cryptography            37.0.4
idna                    3.3
Jinja2                  3.1.2
lxml                    4.9.1
MarkupSafe              2.1.1
ntlm-auth               1.5.0
ovirt-engine-sdk-python 4.5.2
packaging               21.3
pip                     22.2.2
psutil                  5.9.1
pycparser               2.21
pycurl                  7.45.1
pykerberos              1.2.4
pyparsing               3.0.9
pywinrm                 0.4.3
PyYAML                  6.0
requests                2.28.1
requests-ntlm           1.1.0
resolvelib              0.5.4
setuptools              65.3.0
six                     1.16.0
urllib3                 1.26.12
wheel                   0.37.1
xmltodict               0.13.0
(rhv-4.5) #

EDIT

I wrote a small playbook to test ovirt_auth from within the venv.

---
- name: Test ovirt_auth
  hosts: localhost
  vars:
    rhv1_url: "https://rhvm.server.local/ovirt-engine/api"
    rhv1_username: "me@rhvm.local"
    rhv1_passwd: "Super Secure Password"

  tasks:
    - name: Authenticate with RHV
      ovirt.ovirt.ovirt_auth:
        url: "{{ rhv1_url }}"
        username: "{{ rhv1_username }}"
        password: "{{ rhv1_passwd }}"

    - name: debug ovirt_auth
      debug:
        var: ovirt_auth

This worked and the debug printed the expected output.

When I ran it through Ansible Tower, fails and "ovirtsdk4 version 4.4.0 or higher is required for this module" message is back

So it looks like Ansible Tower just isn't getting the memo...

So the solution was deceptively simple, and shout out to Kevin from Red Hat Support for the answer.

The workflow runs on the Ansible Tower server using an inventory called 'inv-localhost'. This inventory already had the "ansible_connection: local" but needed 'ansible_python_interpreter: "{{ansible_playbook_python}}"' as well.

Now it works!

In addition, I'd not followed custom environment documentation correctly. Should go without saying but read the doco closely...

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM