theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
https://theforeman.github.io/foreman-ansible-modules/
GNU General Public License v3.0
149 stars 166 forks source link

repository module - idempotence is broken for docker repos #1548

Closed parmstro closed 1 year ago

parmstro commented 1 year ago
SUMMARY

repository.yml test play errors out on idempotence test with "param is missing or the value is empty: repository"

ISSUE TYPE
ANSIBLE VERSION
ansible --version
[WARNING]: log file at /var/log/ansible/ansible.log is not writeable and we cannot create it, aborting

ansible [core 2.13.0]
  config file = /home/parmstro/.ansible.cfg
  configured module search path = ['/home/parmstro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/parmstro/Projects/ansible/foreman-ansible-modules/venv/lib64/python3.9/site-packages/ansible
  ansible collection location = /home/parmstro/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/parmstro/Projects/ansible/foreman-ansible-modules/venv/bin/ansible
  python version = 3.9.14 (main, Nov  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
  jinja version = 3.1.2
  libyaml = True
(venv)
COLLECTION VERSION
ansible-galaxy collection list
[WARNING]: log file at /var/log/ansible/ansible.log is not writeable and we cannot create it, aborting

# /usr/share/ansible/collections/ansible_collections
Collection                  Version
--------------------------- -------
redhat.rhel_system_roles    1.20.1 
redhat.satellite_operations 0.3.2  

# /home/parmstro/.ansible/collections/ansible_collections
Collection                  Version
--------------------------- -------
ansible.netcommon           2.4.0  
ansible.posix               1.3.0  
ansible.utils               2.4.2  
ansible.windows             1.7.3  
awx.awx                     19.4.0 
azure.azcollection          1.9.0  
community.general           6.0.1  
community.mysql             3.5.1  
freeipa.ansible_freeipa     0.3.5  
(venv) 
KATELLO/FOREMAN VERSION
rpm -q rubygem-katello foreman
rubygem-katello-4.5.0.20-1.el8sat.noarch
foreman-3.3.0.17-1.el8sat.noarch
STEPS TO REPRODUCE
make record_repository
EXPECTED RESULTS

All tests PASS It appears that auto_lookup_entities called from repository.py does not resolve docker repos.

ACTUAL RESULTS
TASK [Idempotence check - no change] *******************************************
task path: /home/parmstro/Projects/ansible/foreman-ansible-modules/tests/test_playbooks/repository.yml:166
Read vars_file 'vars/server.yml'
included: /home/parmstro/Projects/ansible/foreman-ansible-modules/tests/test_playbooks/tasks/repository.yml for tests
Read vars_file 'vars/server.yml'
Read vars_file 'vars/server.yml'

TASK [Create katello repository] ***********************************************
task path: /home/parmstro/Projects/ansible/foreman-ansible-modules/tests/test_playbooks/tasks/repository.yml:2
<tests> ESTABLISH LOCAL CONNECTION FOR USER: parmstro
<tests> EXEC /bin/sh -c 'echo ~parmstro && sleep 0'
<tests> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/parmstro/.ansible/tmp `"&& mkdir "` echo /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366 `" && echo ansible-tmp-1672976887.6138458-2352476-170121931842366="` echo /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366 `" ) && sleep 0'
Using module file /home/parmstro/Projects/ansible/foreman-ansible-modules/build/collections/ansible_collections/theforeman/foreman/plugins/modules/repository.py
<tests> PUT /home/parmstro/.ansible/tmp/ansible-local-2351880x7vt4fy5/tmp1vysgwqt TO /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366/AnsiballZ_repository.py
<tests> EXEC /bin/sh -c 'chmod u+x /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366/ /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366/AnsiballZ_repository.py && sleep 0'
<tests> EXEC /bin/sh -c '../vcr_python_wrapper.py /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366/AnsiballZ_repository.py && sleep 0'
<tests> EXEC /bin/sh -c 'rm -f -r /home/parmstro/.ansible/tmp/ansible-tmp-1672976887.6138458-2352476-170121931842366/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_repository_payload_yw3_nygo/ansible_repository_payload.zip/ansible_collections/theforeman/foreman/plugins/module_utils/foreman_helper.py", line 1164, in resource_action
    result = self._resource_call(resource, action, resource_payload, options=options, data=data, files=files)
  File "/tmp/ansible_repository_payload_yw3_nygo/ansible_repository_payload.zip/ansible_collections/theforeman/foreman/plugins/module_utils/foreman_helper.py", line 640, in _resource_call
    return self._resource(resource).call(*args, **kwargs)
  File "/tmp/ansible_repository_payload_yw3_nygo/ansible_repository_payload.zip/ansible_collections/theforeman/foreman/plugins/module_utils/_apypie.py", line 864, in call
    return self.api.call(self.name, action, params, headers, options, data, files)
  File "/tmp/ansible_repository_payload_yw3_nygo/ansible_repository_payload.zip/ansible_collections/theforeman/foreman/plugins/module_utils/_apypie.py", line 482, in call
    return self._call_action(action, params, headers, data, files)
  File "/tmp/ansible_repository_payload_yw3_nygo/ansible_repository_payload.zip/ansible_collections/theforeman/foreman/plugins/module_utils/_apypie.py", line 490, in _call_action
    return self.http_call(
  File "/tmp/ansible_repository_payload_yw3_nygo/ansible_repository_payload.zip/ansible_collections/theforeman/foreman/plugins/module_utils/_apypie.py", line 532, in http_call
    request.raise_for_status()
  File "/home/parmstro/Projects/ansible/foreman-ansible-modules/venv/lib64/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
fatal: [tests]: FAILED! => {
    "changed": false,
    "error": {
        "displayMessage": "Missing values for repository.",
        "errors": [
            "param is missing or the value is empty: repository"
        ]
    },
    "invocation": {
        "module_args": {
            "ansible_collection_requirements": null,
            "arch": null,
            "auto_enabled": null,
            "checksum_type": null,
            "content_type": "docker",
            "deb_architectures": null,
            "deb_components": null,
            "deb_errata_url": null,
            "deb_releases": null,
            "description": null,
            "docker_tags_whitelist": [
                "latest"
            ],
            "docker_upstream_name": "ubi8",
            "download_concurrency": null,
            "download_policy": null,
            "exclude_tags": null,
            "gpg_key": null,
            "http_proxy": null,
            "http_proxy_policy": null,
            "ignorable_content": null,
            "ignore_global_proxy": null,
            "include_tags": null,
            "label": null,
            "mirror_on_sync": null,
            "mirroring_policy": null,
            "name": "Test Docker Repository",
            "organization": "Test Organization",
            "os_versions": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "product": "Test Product",
            "server_url": "https://satdev.parmstrong.ca",
            "ssl_ca_cert": null,
            "ssl_client_cert": null,
            "ssl_client_key": null,
            "state": "present",
            "unprotected": null,
            "upstream_password": null,
            "upstream_username": null,
            "url": "https://registry.access.redhat.com",
            "username": "admin",
            "validate_certs": false,
            "verify_ssl_on_sync": null
        }
    },
    "msg": "Error while performing update on repositories: 400 Client Error: Bad Request for url: https://satdev.parmstrong.ca/katello/api/repositories/79"
}
evgeni commented 1 year ago

this was fixed in d0e1ce6952b63082ff8c3fac878f7af688654e0a