How to give repositories input in content view filter?

Problem:
Unable to provide repositories input in content view filter
Expected outcome:
The repository should be fetched
Other relevant data:
Here is my playbook

  - name: Filter
    theforeman.foreman.content_view_filter:
      username: "admin"
      password: "admin"
      server_url: "myhost.com"
      name: "package filter 1"
      organization: "COT"
      content_view: "Test_cv"
      filter_type: "package_group"
      filter_state: present
      repositories: "[BaseOS]"
      rule_name: "Core"

The error I am getting is

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Elements value for option repositories is of type <class 'str'> and we were unable to convert to dict: dictionary requested, could not parse JSON or key=value"}

The required output is package-group “Core” should be fetched from the BaseOS repository. Any help would be appreciated

Try

  - name: Filter
    theforeman.foreman.content_view_filter:
      username: "admin"
      ...      
      rule_name: "Core"
       repositories:
          - name: "Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8"
            product: "Red Hat Enterprise Linux for x86_64"

@Partha_Aji After making changes as you suggested, now I am facing this error

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Found too many (4) results while searching for package_groups with name=\"Core\""}

Any idea @Partha_Aji ?

Not as familiar with Package Group filters. Do you happen to have 4 repositories in your organization with the same package group name ? From a cursory look at the code (foreman-ansible-modules/content_view_filter.py at develop · theforeman/foreman-ansible-modules · GitHub) the filter seems to look org wide scope. Seems like a bug.
can you file an issue here Issues · theforeman/foreman-ansible-modules · GitHub for more support from the maintainers of Foreman Ansible Modules ?

Okay filing an issue! Thank you @Partha_Aji

1 Like