Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2097333

Summary: Fix ansible-lint 6.0.0 for hosted_engine_setup and shutdown_env
Product: [oVirt] ovirt-ansible-collection Reporter: Martin Necas <mnecas>
Component: hosted-engine-setupAssignee: Yedidyah Bar David <didi>
Status: CLOSED CURRENTRELEASE QA Contact: Nikolai Sednev <nsednev>
Severity: high Docs Contact:
Priority: high    
Version: 2.0.3CC: arachman, bugs, didi, mperina, sbonazzo
Target Milestone: ovirt-4.5.2Keywords: CodeChange, Triaged, ZStream
Target Release: 2.2.0Flags: mperina: ovirt-4.5+
sbonazzo: devel_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-ansible-collection-2.2.0-1 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-30 08:47:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Integration RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Necas 2022-06-15 13:20:17 UTC
Description of problem:
ovirt-ansible-collection has moved to the latest ansible-lint but some roles do not match the requirements.


How reproducible:
Run latests ansible-lint on roles/hosted_engine_setup roles/shutdown_env


Steps to Reproduce:
1. Install ansible-lint (`pip3 install ansible-lint`)
2. Run `ansible-lint roles/hosted_engine_setup roles/shutdown_env`

Actual results:
Multiple issues with the role.

Expected results:
Pass all lint tests.

Comment 1 Yedidyah Bar David 2022-06-16 12:47:28 UTC
Not sure that's already part of comment 0, but I'll use the opportunity to also get rid of these warnings:

    The loop variable 'item' is already in use

Comment 2 Yedidyah Bar David 2022-07-07 05:21:26 UTC
Copying [1] here, for completeness:

Documenting here a long discussion with @mnecas. With the current version of this PR, ansible-lint outputs (to stderr):

[DEPRECATION WARNING]: Use 'ansible.utils.ipaddr' module instead. This feature will be removed from ansible.netcommon in a 
release after 2024-01-01. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Use 'ansible.utils.ipv4' module instead. This feature will be removed from ansible.netcommon in a 
release after 2024-01-01. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Use 'ansible.utils.ipv6' module instead. This feature will be removed from ansible.netcommon in a 
release after 2024-01-01. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

This is a result of using filters ipaddr, ipv4 and ipv6, without a namespace. Right now, they are used from ansible.netcommon, which outputs these warnings. I tried fixing this (with [1], and then [2]), but this does not work, because right now, the version of ansible-collection-ansible-utils that we use (which we get from CentOS Stream 8), does not include these filters.

So for now, just giving up on this. Later, once they are included in ansible-utils, we can simply remove 'Requires: ansible-collection-ansible-netcommon', and will automatically (hopefully) get the version from utils and get rid of the warning.

[1] bece1c3 lint: he: Fix deprecation warnings from ansible.netcommon

[2] 579422d lint: he: Use ansible.utils collection

[1] https://github.com/oVirt/ovirt-ansible-collection/pull/545#issuecomment-1164399341

Comment 3 Nikolai Sednev 2022-08-15 19:02:48 UTC
serval17 ~]# pip3 install ansible-lint
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting ansible-lint
  Downloading https://files.pythonhosted.org/packages/6f/12/93f9418043e8ddc4859c94f27679a1972f31d529f737e0347eb29e715e68/ansible_lint-5.4.0-py3-none-any.whl (119kB)
    100% |████████████████████████████████| 122kB 1.1MB/s 
Requirement already satisfied: pyyaml in /usr/lib64/python3.6/site-packages (from ansible-lint)
Collecting typing-extensions; python_version < "3.8" (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl
Collecting ruamel.yaml<1,>=0.15.34; python_version < "3.7" (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/9e/cb/938214ac358fbef7058343b3765c79a1b7ed0c366f7f992ce7ff38335652/ruamel.yaml-0.17.21-py3-none-any.whl (109kB)
    100% |████████████████████████████████| 112kB 3.3MB/s 
Collecting tenacity (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/f2/a5/f86bc8d67c979020438c8559cc70cfe3a1643fd160d35e09c9cca6a09189/tenacity-8.0.1-py3-none-any.whl
Collecting packaging (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl (40kB)
    100% |████████████████████████████████| 40kB 3.5MB/s 
Collecting enrich>=1.2.6 (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/76/67/aecd1d435dbbdcea21a197d708e9ff0bcc7306c2847c6c87cc1a91e2cca4/enrich-1.2.7-py3-none-any.whl
Collecting rich>=9.5.1 (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/f6/39/4cb526e0d505464376e3c47a812df6e6638363ebe66e6a63618831fe47ad/rich-12.5.1-py3-none-any.whl (235kB)
    100% |████████████████████████████████| 245kB 1.4MB/s 
Collecting wcmatch>=7.0 (from ansible-lint)
  Downloading https://files.pythonhosted.org/packages/8c/20/6f34f7161cea46c8e05810c388bd1526ae7c16898d64c782bbc603f4bb1c/wcmatch-8.3-py3-none-any.whl (42kB)
    100% |████████████████████████████████| 51kB 4.8MB/s 
Collecting ruamel.yaml.clib>=0.2.6; platform_python_implementation == "CPython" and python_version < "3.11" (from ruamel.yaml<1,>=0.15.34; python_version < "3.7"->ansible-lint)
  Downloading https://files.pythonhosted.org/packages/2a/25/5b1dfc832ef3b83576c546d1fb3e27f136022cdd1008aab290a1e28ef220/ruamel.yaml.clib-0.2.6-cp36-cp36m-manylinux1_x86_64.whl (552kB)
    100% |████████████████████████████████| 552kB 1.1MB/s 
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/lib/python3.6/site-packages (from packaging->ansible-lint)
Collecting dataclasses<0.9,>=0.7; python_version < "3.7" (from rich>=9.5.1->ansible-lint)
  Downloading https://files.pythonhosted.org/packages/fe/ca/75fac5856ab5cfa51bbbcefa250182e50441074fdc3f803f6e76451fab43/dataclasses-0.8-py3-none-any.whl
Collecting pygments<3.0.0,>=2.6.0 (from rich>=9.5.1->ansible-lint)
  Downloading https://files.pythonhosted.org/packages/4f/82/672cd382e5b39ab1cd422a672382f08a1fb3d08d9e0c0f3707f33a52063b/Pygments-2.13.0-py3-none-any.whl (1.1MB)
    100% |████████████████████████████████| 1.1MB 923kB/s 
Collecting commonmark<0.10.0,>=0.9.0 (from rich>=9.5.1->ansible-lint)
  Downloading https://files.pythonhosted.org/packages/b1/92/dfd892312d822f36c55366118b95d914e5f16de11044a27cf10a7d71bbbf/commonmark-0.9.1-py2.py3-none-any.whl (51kB)
    100% |████████████████████████████████| 51kB 3.5MB/s 
Collecting bracex>=2.1.1 (from wcmatch>=7.0->ansible-lint)
  Downloading https://files.pythonhosted.org/packages/db/ba/6b2fd77f670c7c59da817df9be07799f38789da8ab1b96efe4ebc4695fd4/bracex-2.2.1-py3-none-any.whl
Installing collected packages: typing-extensions, ruamel.yaml.clib, ruamel.yaml, tenacity, packaging, dataclasses, pygments, commonmark, rich, enrich, bracex, wcmatch, ansible-lint
Successfully installed ansible-lint-5.4.0 bracex-2.2.1 commonmark-0.9.1 dataclasses-0.8 enrich-1.2.7 packaging-21.3 pygments-2.13.0 rich-12.5.1 ruamel.yaml-0.17.21 ruamel.yaml.clib-0.2.6 tenacity-8.0.1 typing-extensions-4.1.1 wcmatch-8.3

serval17 ~]# ansible-lint
ERROR    No module named 'ansible'
FATAL: ansible-lint requires a version of Ansible package >= 2.9, but none was found. Please install a compatible version using the same python interpreter. See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-with-pip

Tested on:
ansible-core-2.12.2-4.el8_6.x86_64
ansible-collection-ansible-posix-1.3.0-1.2.el8ev.noarch
ansible-collection-ansible-netcommon-2.2.0-3.2.el8ev.noarch
ansible-collection-ansible-utils-2.3.0-2.2.el8ev.noarch
ovirt-ansible-collection-2.2.2-1.el8ev.noarch
ovirt-hosted-engine-setup-2.6.5-1.1.el8ev.noarch
ovirt-hosted-engine-ha-2.5.0-1.el8ev.noarch
Linux 4.18.0-372.23.1.el8_6.x86_64 #1 SMP Wed Aug 10 11:51:12 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
Red Hat Enterprise Linux release 8.6 (Ootpa)

Something went wrong here.

Comment 4 Nikolai Sednev 2022-08-15 19:15:41 UTC
serval17 ~]# ansible-lint roles/hosted_engine_setup roles/shutdown_env
ERROR    No module named 'ansible'
FATAL: ansible-lint requires a version of Ansible package >= 2.9, but none was found. Please install a compatible version using the same python interpreter. See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-with-pip

Comment 5 Martin Perina 2022-08-16 06:28:10 UTC
Officially suggested way to run ansible-lint is inside specialized container image:

https://github.com/oVirt/ovirt-ansible-collection/blob/master/.github/workflows/build.yaml#L11

where you need to install ansible-lint from pip and run:

https://github.com/oVirt/ovirt-ansible-collection/blob/master/.github/workflows/build.yaml#L28

Anyway this bug is marked as CodeChange, so it doesn't need to be verified by QE.

Comment 6 Martin Perina 2022-08-16 06:29:01 UTC
It can be moved to verified if QE automation haven't found any regressions.

Comment 7 Yedidyah Bar David 2022-08-16 06:30:59 UTC
In addition, details for how to verify this manually on el8 follow. This is using a temporary/isolated venv (virtualenv), which is how I worked on my laptop. In GitHub, we install as root directly on the system (a temporary container), which I'd not recommend on your laptop, or any long-lived machine.

sudo dnf install python38

T=$(mktemp -d)

python3.8 -m venv $T/venv
. $T/venv/bin/activate
pip install ansible 'ansible-lint>=6.0.0,<7.0.0'

git clone https://github.com/oVirt/ovirt-ansible-collection.git $T/code
cd $T/code
./build.sh build ovirt $PWD
cd ansible_collections/ovirt/ovirt
ansible-lint roles/hosted_engine_setup

Comment 8 Sandro Bonazzola 2022-08-30 08:47:42 UTC
This bugzilla is included in oVirt 4.5.2 release, published on August 10th 2022.
Since the problem described in this bug report should be resolved in oVirt 4.5.2 release, it has been closed with a resolution of CURRENT RELEASE.
If the solution does not work for you, please open a new bug report.