foreman-ansible-modules icon indicating copy to clipboard operation
foreman-ansible-modules copied to clipboard

content_view and content_view_publish roles variable isse

Open maciej-markowski opened this issue 2 years ago • 2 comments

SUMMARY

content_view and content_view_publish are using the same named variable but first one expects a list of dictionaries while second list of strings.

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION
ansible --version
ansible [core 2.12.4]

COLLECTION VERSION
theforeman.foreman   3.4.0

KATELLO/FOREMAN VERSION
foreman-3.3.0-1.el8.noarch
STEPS TO REPRODUCE

Try to use both roles from the same playbook


EXPECTED RESULTS

Unified variable type

ACTUAL RESULTS

maciej-markowski avatar Jul 01 '22 14:07 maciej-markowski

It's unclear to me what you mean exactly.

There are two roles:

  • theforeman.foreman.content_view_publish
  • theforeman.foreman.content_views

There is no role with "content_view".

There is only a module theforeman.foreman.content_view.

The role content_views creates/updates a content view. It uses the content_view module to do so. So obviously the role content_views needs a list of dictionaries to define all parameters needed to set up a content_view.

The role content_view_publish publishes a new version of one or more content views. For this, it only needs to identify the content view to be published, thus it only needs a list of string.

I don't know how else it should be...

gvde avatar Jul 04 '22 06:07 gvde

Sorry for the typo, I meant content_views role. Both roles are using the same named variable, which are of different type so it is confusing and eg. if you want to use both roles from single playbook, you cannot just define the variable in eg. in host vars, but you need to define it separately for each role eg.:

    - role: theforeman.foreman.content_views
      vars:
        foreman_content_views: "{{ create_foreman_content_views }}"
    - role: theforeman.foreman.content_view_publish
      vars:
        foreman_content_views: "{{ publish_foreman_content_views }}"

Basically, if role content_view_publish would use content_view.name inside the loop instead of content_view, you wouldn't need to define the variables separately.

maciej-markowski avatar Jul 04 '22 11:07 maciej-markowski