Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'content_filter_rule_modulemd_spec' - missing rule spec #1608

Closed
parmstro opened this issue May 17, 2023 · 2 comments · Fixed by #1614
Closed

KeyError: 'content_filter_rule_modulemd_spec' - missing rule spec #1608

parmstro opened this issue May 17, 2023 · 2 comments · Fixed by #1614

Comments

@parmstro
Copy link
Contributor

SUMMARY

When requesting a content_view_filter of type modulemd, the module throws an error. KeyError: 'content_filter_rule_modulemd_spec
This is caused by a missing rules spec.

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible [core 2.13.3]
  config file = /home/parmstro/.ansible.cfg
  configured module search path = ['/home/parmstro/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/parmstro/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/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

COLLECTION VERSION
3.10.0
KATELLO/FOREMAN VERSION
foreman-3.3.0.21-2.el8sat.noarch
STEPS TO REPRODUCE
---
- name: "Test Task"
  hosts: sat.example.ca
  remote_user: ansiblerunner
  become: true
  gather_facts: true
  vars:
    satellite_admin_username: admin
    satellite_admin_password: password
    satellite_url: https://sat.example.ca
    satellite_initial_organization: "Default Organization"
    satellite_initial_location: "Default Location"   
    satellite_validate_certs: true
    cvf.name: "modulemd filter test"
    cv.name: "test cv"
    cvf.type: "modulemd"
    cvf.repositories: "[]"

  tasks:

  - name: "Create the content view filter - {{ cvf.name }}"
    redhat.satellite.content_view_filter:
      username: "{{ satellite_admin_username }}"
      password: "{{ satellite_admin_password }}"
      server_url: "{{ satellite_url }}"
      organization: "{{ satellite_initial_organization }}"
      validate_certs: "{{ satellite_validate_certs }}"
      name: "{{ cvf.name }}"
      description: "{{ cvf.description | default(omit) }}"
      content_view: "{{ cv.name }}"
      filter_type: "{{ cvf.type }}"
      inclusion: "{{ cvf.inclusion }}"
      repositories: "{{ cvf.repositories }}"
      original_packages: "{{ cvf.original_packages | default(omit) }}"
      original_module_streams: "{{ cvf.original_module_streams | default(omit) }}"

EXPECTED RESULTS

The filter get created successful

ACTUAL RESULTS
Traceback (most recent call last):
  File "<stdin>", line 107, in <module>
  File "<stdin>", line 99, in _ansiballz_main
  File "<stdin>", line 48, in invoke_module
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_redhat.satellite.content_view_filter_payload__8l2fmy9/ansible_redhat.satellite.content_view_filter_payload.zip/ansible_collections/redhat/satellite/plugins/modules/content_view_filter.py", line 338, in <module>
  File "/tmp/ansible_redhat.satellite.content_view_filter_payload__8l2fmy9/ansible_redhat.satellite.content_view_filter_payload.zip/ansible_collections/redhat/satellite/plugins/modules/content_view_filter.py", line 310, in main
KeyError: 'content_filter_rule_modulemd_spec'
fatal: [sat]: FAILED! => {
    "changed": false,
    "module_stderr": "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\nTraceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 48, in invoke_module\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_redhat.satellite.content_view_filter_payload__8l2fmy9/ansible_redhat.satellite.content_view_filter_payload.zip/ansible_collections/redhat/satellite/plugins/modules/content_view_filter.py\", line 338, in <module>\n  File \"/tmp/ansible_redhat.satellite.content_view_filter_payload__8l2fmy9/ansible_redhat.satellite.content_view_filter_payload.zip/ansible_collections/redhat/satellite/plugins/modules/content_view_filter.py\", line 310, in main\nKeyError: 'content_filter_rule_modulemd_spec'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@parmstro
Copy link
Contributor Author

Need the following at or around line 232 in content_view_filter.py

content_filter_rule_modulemd_spec = {
'id': {},
'module_stream_ids': {'type': 'list'},
}

@parmstro
Copy link
Contributor Author

Well ... that's not going to fix it. :-(
The filter type needs the search criteria from content_view_filter_rule.py

It is probably easier to use the original PR ... perhaps push those changes into a 4.0.0 ??

evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue May 31, 2023
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue May 31, 2023
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue May 31, 2023
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue May 31, 2023
evgeni added a commit that referenced this issue May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant