theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
147 stars 164 forks source link

content_view_version_cleanup role fails with error 'slice indices must be integers or None or have an __index__ method' #1712

Closed smeeus closed 7 months ago

smeeus commented 7 months ago
SUMMARY

content_view_version_cleanup role fails with error 'slice indices must be integers or None or have an index method'

ISSUE TYPE
ANSIBLE VERSION
ansible [core 2.15.9]
  config file = /home/local/COMMON/sme8401/ansible/tme-satellite/ansible.cfg
  configured module search path = ['/home/local/COMMON/sme8401/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/local/COMMON/sme8401/bin/ansible-venv-py39/lib64/python3.9/site-packages/ansible
  ansible collection location = /home/local/COMMON/sme8401/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/local/COMMON/sme8401/bin/ansible
  python version = 3.9.18 (main, Nov 16 2023, 02:13:35) [GCC [8.5.0 20210514](callto:8.5.0 20210514) (Red Hat [8.5.0-20.0.1](callto:8.5.0-20.0.1))] (/home/smeeus/bin/ansible-venv-py39/bin/python3.9)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
[smeeus@watson satellite]$ cat /home/smeeus/.ansible/collections/ansible_collections/theforeman/foreman/MANIFEST.json | grep version
  "version": "4.0.0",
KATELLO/FOREMAN VERSION
rubygem-katello-4.8.1-1.el8.noarch
foreman-3.6.1-1.el8.noarch
STEPS TO REPRODUCE
- name: "Cleanup Satellite content views"
  hosts: satellite
  tasks:
    - name: "Content Cleanup | Include theforeman.foreman.content_credentials role"
      ansible.builtin.import_role:
        name: theforeman.foreman.content_view_version_cleanup
      tags: [ "katello_cleanup" ]
EXPECTED RESULTS

Cleanup of unused content views

ACTUAL RESULTS
ansible-playbook -i inventories playbook-satellite-content.yml --diff --tags=katello_cleanup -e "foreman_cleanup_content=true" -e "foreman_content_view_version_cleanup_keep=0"
...
TASK [theforeman.foreman.content_view_version_cleanup : Delete unused composite content view versions] *******************************************************************************************************************************************************************
Friday 23 February 2024  11:27:52 +0100 (0:00:02.368)       0:00:10.594 *******
fatal: [satellite]: FAILED! => {"msg": "The conditional check '(__foreman_ccv.versions | rejectattr('environment_ids') | map(attribute='version') | reverse | list)[foreman_content_view_version_cleanup_keep:]' failed. The error was: Unexpected templating type error occurred on ({% if (__foreman_ccv.versions | rejectattr('environment_ids') | map(attribute='version') | reverse | list)[foreman_content_view_version_cleanup_keep:] %} True {% else %} False {% endif %}): slice indices must be integers or None or have an __index__ method. slice indices must be integers or None or have an __index__ method\n\nThe error appears to be in '/home/smeeus/.ansible/collections/ansible_collections/theforeman/foreman/roles/content_view_version_cleanup/tasks/main.yml': line 19, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Delete unused composite content view versions\"\n  ^ here\n"}