Bug 2189687

Summary: Ansible Satellite Collection Content View Filters incorrectly handles packages with different architectures
Product: Red Hat Satellite Reporter: Glenn Snead <gsnead>
Component: Ansible CollectionAssignee: Evgeni Golov <egolov>
Status: CLOSED ERRATA QA Contact: Griffin Sullivan <gsulliva>
Severity: medium Docs Contact:
Priority: high    
Version: UnspecifiedCC: egolov, ehelms, gsulliva, zhunting
Target Milestone: 6.15.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: ansible-collection-redhat-satellite-3.15.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-04-23 17:14:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Satellite Content View Screenshot none

Description Glenn Snead 2023-04-25 22:32:48 UTC
Created attachment 1959934 [details]
Satellite Content View Screenshot

Description of problem: The redhat.satellite.content_view_filter or content_view_filter_rule component incorrectly handles duplicate package names when the second entry lists a different architecture


Version-Release number of selected component (if applicable):


How reproducible:
Verified with this playbook:
- hosts: satellite
  gather_facts: no
  become: no
  vars:
    - rules:
        - { name: "cairo", version: "1.15.12-6", arch: "x86_64" }
        - { name: "cairo", version: "1.15.12-6", arch: "i686" }
  tasks:
    - name: Create Content Views
      redhat.satellite.content_view:
        server_url: "{{ server_url }}"
        username: '{{ satellite_username }}'
        password: '{{ satellite_password }}'
        organization: "Default Organization"
        name: RHEL8_Demo
        auto_publish: false
        state: present

    - name: Create Content View Filters
      redhat.satellite.content_view_filter:
        server_url: "{{ server_url }}"
        username: '{{ satellite_username }}'
        password: '{{ satellite_password }}'
        organization: "Default Organization"
        name: "{{ item.name }}"
        content_view: RHEL8_Demo
        name: "Packages"
        filter_state: present
        filter_type: "rpm"
        original_packages: True
        inclusion: True
        rule_name: "{{ item.name }}"
        version: "{{ item.version }}"
        architecture: "{{ item.arch }}"
      loop: "{{ rules }}"

Steps to Reproduce:
1. Set up Satellite and sync the RHEL 8 BaseOS and AppStream repositories
2. Run the provided playbook, providing the necessary variables for the target Satellite server
3. Check the created content view filter. Instead of two entries for cairo showing different architectures and a specific package release, it shows a single entry where the architecture is the last item submitted to Satellite, and the package release is "All versions." 

Actual results:
See screenshot

Expected results:
Two entries for the cario package, each with the specified package release and the specified package architecture.

Comment 1 Brad Buckingham 2023-10-30 11:29:29 UTC
Bulk setting Target Milestone = 6.15.0 where sat-6.15.0+ is set.

Comment 2 Evgeni Golov 2023-11-15 08:54:09 UTC
Two things:

1. your playbook has "name" twice for the filter module, and by default the last one wins.
2. the way you use it right now it overwrites the x86_64 filter with the i686 one in the loop, as you pass the same name for the filter in both cases (either "packages" or after fixing 1/ "cairo").

Now, you will notice that there is no other way to pass multiple rules into one filter with the content_view_filter module.
This is why we created the content_view_filter_rule module, but even that has a bug with architecture handling, so let's fix that :)

Comment 4 Griffin Sullivan 2024-01-03 14:24:50 UTC
Verified in 6.15.0 snap 4.0

content_view_filter_rule is able to create 2 separate rules for the same package that have different architectures.

Comment 7 errata-xmlrpc 2024-04-23 17:14:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.15.0 release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2024:2010