Role " theforeman.foreman.os_default_template" not found?

Problem:
ERROR! the role ‘theforeman.foreman.os_default_template’ was not found in “…”

The error appears to be in ‘… tasks/setup.yml’: line 164, column 18, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    ansible.builtin.include_role:
       name: theforeman.foreman.os_default_template
             ^ here

Expected outcome:

a working role !

Foreman and Proxy versions:
foreman 3.5.2
ansible collection 3.9.0

Distribution and version:
RHEL 8.7

There is no such role, what did make you think it is?

We do have a module with that name tho: theforeman.foreman.os_default_template module – Manage Default Template Associations To Operating Systems — Foreman Ansible Modules documentation

what’s the difference for you between role and module ?

https://docs.ansible.com/ansible/latest/module_plugin_guide/modules_intro.html

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html

what is confusing, is that some are role, some are module, some are both in the collection…
what differentiate the usage in foreman context ?

there are no modules with the same name as the role

what there is, sometimes, that there is a role with a simimlar name to a module, where the module is called e.g. content_view (singular) and the role content_views (plural).

depending on your usecase, you might want to manage multiple entities of the same type and then such a role might be useful

for now, trying to do that :

    - name: Create a Provisioning Template
         ansible.builtin.include_role:
            name: theforeman.foreman.provisioning_templates
         vars:
            foreman_server_url: https://10.34.58.90/
            foreman_username: admin
            foreman_password: admin
            foreman_validate_certs: false
            foreman_provisioning_template:
            foreman_provisioning_templates:
              - name: WL-RH8-kickstart_test
                kind: provision
                state: absent
                organizations: "WL-GLOBAL"
              - name: WL-RH8-kickstart
                kind: provision
                file_name: "/var/tmp/provision/WL-RH8-kickstart"
                state: present
                organizations: "WL-GLOBAL"
              - name: "WL-RH8-kickstart custom post"
                kind: snippet
                file_name: "/var/tmp/snippet/WL-RH8-kickstart-custom-post"
                state: present
                organizations: "WL-GLOBAL"
              - name: WL-RH8-PXE
                kind: PXELinux
                file_name: "/var/tmp/PXELinux/WL-RH8-PXE"
                state: present
                organizations: "WL-GLOBAL"
 
     - name: Create an OS
         ansible.builtin.include_role:
            name: theforeman.foreman.operatingsystems
         vars:
            foreman_server_url: https://10.34.58.90/
            foreman_username: admin
            foreman_password: admin
            foreman_validate_certs: false
            foreman_provisioning_template:
            foreman_operatingsystems:
               - name: "WL-RHEL"
                 major: "8"
                 minor: "7"
                 os_family: "Redhat"
                 password_hash: "SHA256"
                 architectures: "x86_64"
                 default_templates:
                   - template_kind: "provision"
                     provisioning_template: "WL-RH8-kickstart"
                   - template_kind: "PXELinux"
                     provisioning_template: "WL-RH8-PXE"
 
       - name: "Create an kickstart Association"
         theforeman.foreman.os_default_template:
           server_url: https://10.34.58.90/
           username: admin
           password: admin
           validate_certs: false
           provisioning_template:
           operatingsystem: "WL-RHEL 8.7"
           template_kind: "provision"
           provisioning_template: "WL-RH8-kickstart"
           state: present

the last one, “association” doesn’t work…
What did I do wrong then ?
did I miss some info ?

what’s the error?

no error is return, but no association seems to be done…
when looking at template “WL-RH8-kickstart”, in the “Association” tab,
in “all items”, I see “RHEL 8.7, WL RHEL 8.7”, but in “Selected”: empty.

Ah, look! You have the provisioning_template parameter twice, and the first one wins:

       - name: "Create an kickstart Association"
         theforeman.foreman.os_default_template:
           server_url: https://10.34.58.90/
           username: admin
           password: admin
           validate_certs: false
           provisioning_template: <<<
           operatingsystem: "WL-RHEL 8.7"
           template_kind: "provision"
           provisioning_template: "WL-RH8-kickstart" <<<
           state: present

I would have expected Ansible to have complained about that tho, like this?

[WARNING]: While constructing a mapping from /tmp/l.yml, line 6, column 9, found a duplicate dict key (provisioning_template). Using last defined value only.