Content View Filter Bug: Original_packages & Original_module_streams
Guys, let's dive into a bug report concerning the creation of content views within Red Hat Satellite using Ansible. This issue specifically arises when dealing with original_packages
or original_module_streams
filters. We'll break down the problem, the steps to reproduce it, and how to work around it. This guide aims to help you understand the issue and potentially avoid it in your own deployments.
Summary of the Issue
The core problem is that the content_views
role in the redhat.satellite
Ansible collection fails when you attempt to create content view filters using the original_module_streams
or original_packages
filters. Essentially, the Ansible playbook tries to add rules to filters that are not designed to have rules, leading to an error. Let's get into the specifics.
Issue Type
This is classified as a Bug Report.
Ansible Version Details
Here's the Ansible version used when this bug was encountered:
ansible [core 2.18.7]
config file = /sat_example_playbook/ansible.cfg
configured module search path = ['/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/Cellar/ansible/11.8.0/libexec/lib/python3.13/site-packages/ansible
ansible collection location = /sat_example_playbook/collections:/usr/share/ansible/collections:/.ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.13.5 (main, Jun 11 2025, 15:36:57) [Clang 17.0.0 (clang-1700.0.13.3)] (/usr/local/Cellar/ansible/11.8.0/libexec/bin/python)
jinja version = 3.1.6
libyaml = True
This output gives us a clear picture of the Ansible environment, including the Python version, Jinja version, and libyaml. It's crucial to include this information when reporting bugs, as it helps in pinpointing environment-specific issues.
Collection Version
The redhat.satellite
collection version in use is 5.5.0
:
Collection Version
---------------------------------------- -------
redhat.satellite 5.5.0
Knowing the collection version is vital because bug fixes and new features are often introduced in newer versions. This helps in determining if the issue has already been addressed in a later release.
Katello/Foreman Version
Here are the versions of Katello and Foreman:
rubygem-katello-4.16.0.6-1.el9sat.noarch
foreman-3.14.0.4-1.el9sat.noarch
These versions are significant as they indicate the specific environment where the bug was observed. Different versions of Katello and Foreman may have variations in their APIs or behaviors, which can impact Ansible module functionality.
Steps to Reproduce
To reproduce this issue, follow these steps:
- Create an Ansible playbook (e.g.,
playbook.yaml
) with the following content:
---
- name: 'Create (Composite-) Content Views in a Red Hat Satellite'
hosts: 'all'
connection: local
gather_facts: false
vars:
satellite_server_url: 'https://192.168.100.1'
satellite_username: 'admin'
satellite_password: 'password'
satellite_organization: 'Default'
satellite_validate_certs: false
satellite_content_views:
- name: 'cv-os-rhel9-latest'
description: 'Last version of RHEL9.4 using latest RHEL9 repositories and filters'
lifecycle_environments:
- Library
repositories:
- name: 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs 9'
product: 'Red Hat Enterprise Linux for x86_64'
- name: 'Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs 9'
product: 'Red Hat Enterprise Linux for x86_64'
filters:
- name: 'All packages without errata'
filter_type: 'rpm'
inclusion: true
original_packages: true
- name: 'All modules without errata'
filter_type: 'modulemd'
inclusion: true
original_module_streams: true
- name: 'Include errata until date'
filter_type: 'erratum'
inclusion: true
date_type: updated
end_date: '2024-11-10'
roles:
- name: 'redhat.satellite.content_views'
- Run the playbook using the command:
ansible-playbook -i localhost, playbook.yaml
This playbook is designed to create a content view named cv-os-rhel9-latest
in a Red Hat Satellite instance. It includes filters for packages, modules, and errata. The key part that triggers the bug is the inclusion of filters with original_packages
and original_module_streams
set to true
.
Diving Deeper into the Playbook
Let's break down the playbook to understand what's happening. The playbook starts by defining variables required for connecting to the Red Hat Satellite instance, such as the URL, username, password, and organization. It then defines a list of content views to be created under the satellite_content_views
variable. Each content view has attributes like name
, description
, lifecycle_environments
, repositories
, and filters
.
The filters
section is where the problem lies. The playbook defines three filters:
All packages without errata
: This filter is intended to include all RPM packages without errata. It usesoriginal_packages: true
, which means it should include packages as they were originally released.All modules without errata
: Similar to the previous filter, this one includes all module streams without errata, usingoriginal_module_streams: true
.Include errata until date
: This filter includes errata up to a specified date (2024-11-10). This filter works correctly as it doesn't useoriginal_packages
ororiginal_module_streams
.
The playbook then uses the redhat.satellite.content_views
role to create the content view. This role interacts with the Red Hat Satellite API to create and manage content views based on the provided configuration.
Expected Results
The expectation was that the content view would be created without any errors, including the filters specified in the playbook. This means Ansible should successfully create a content view named cv-os-rhel9-latest
with the specified filters for packages, modules, and errata.
Actual Results
Instead of creating the content view seamlessly, the Ansible playbook failed. The content view was created with the required filters, but the playbook failed because it attempted to add rules to filters where original_packages
and original_module_streams
were set to true
. These types of filters are not designed to have additional rules, which resulted in the error.
Understanding the Error
The error occurs because the Ansible role tries to perform an operation that is not supported by the Red Hat Satellite API for filters with original_packages
or original_module_streams
enabled. These filters are meant to include content as it was originally provided by the content source, without any modifications or additional rules.
When Ansible tries to add rules to these filters, the API returns an error indicating that the operation is not allowed. This causes the Ansible playbook to fail, even though the content view itself might have been created with the basic filter settings.
Workaround and Solutions
So, what can you do if you encounter this issue? Here are a few potential workarounds and solutions:
- Avoid Adding Rules to
original_packages
andoriginal_module_streams
Filters: The most straightforward solution is to avoid adding specific rules to filters whereoriginal_packages
ororiginal_module_streams
are set totrue
. These filters are designed to include content as-is, so adding rules contradicts their purpose. - Use Separate Filters: If you need to apply additional filtering, consider creating separate filters for specific packages or modules. For example, instead of trying to add a rule to an
original_packages
filter, create a new filter that includes or excludes specific packages based on your requirements. - Update the
redhat.satellite
Collection: Check if there's a newer version of theredhat.satellite
collection available. Bug fixes and improvements are often released in newer versions, so updating might resolve the issue. - Contribute to the Collection: If you have a fix or a better way to handle this scenario, consider contributing to the
redhat.satellite
collection on Ansible Galaxy. This helps improve the collection for everyone.
Practical Example of a Workaround
Let's say you want to include all original packages except for a specific one. Instead of trying to add an exclusion rule to the original_packages
filter, you can create a separate filter that excludes the specific package. Here's how you might modify the playbook:
filters:
- name: 'All packages without errata'
filter_type: 'rpm'
inclusion: true
original_packages: true
- name: 'Exclude specific package'
filter_type: 'rpm'
inclusion: false
package_names:
- 'unwanted-package'
In this example, we've added a new filter named Exclude specific package
that excludes the package unwanted-package
. This filter works in conjunction with the All packages without errata
filter to achieve the desired result without causing an error.
Conclusion
In conclusion, the issue of failing to add content view filter rules when using original_packages
or original_module_streams
filters in the redhat.satellite
Ansible collection is a notable bug. By understanding the steps to reproduce it and the reasons behind the failure, you can effectively work around it. Remember to avoid adding rules to these types of filters and consider using separate filters for more specific inclusion or exclusion criteria. Keep your Ansible collections updated, and don't hesitate to contribute to the community with your fixes and improvements. Happy automating, guys!