Theforeman.foreman.hostgroup module kickstart_repository

Problem:

I am trying to set up hostgroups with the ansible hostgroup module, however I don’t understand what I have to set as kickstart_repository if I want to use synced content. Whatever I use there, it never finds the repository:

"msg": "Found no results while searching for repositories with name=\"BaseOS_x86_64_os\""

BaseOS_x86_64_os is the label of the repository of the operating system chosen. It exists and it’s exactly the name I get offered in the GUI and which I can choose there (even though it’s ambiguous in the GUI, as it offers both Alma and CentOS repos even though I select only one operating system).

Expected outcome:
Successful configuration of the kickstart repository.

Foreman and Proxy versions:
Foreman 3.2.0, Katello 4.4.0.2 latest.

Distribution and version:
AlmaLinux 8.5 latest.

Other relevant data:

example:

    - role: theforeman.foreman.hostgroups
      vars:
        foreman_hostgroups:
          - name: "alma8-base"
            organization: "ORG"
            lifecycle_environment: "Production"
            content_view: "EL 8"
            content_source: "{{ foreman_content_proxy }}"
            environment: "production"
            puppet_proxy: "{{ foreman_puppet_proxy }}"
            puppet_ca_proxy: "{{ foreman_proxy }}"
            domain: "example.com"
            realm: "EXAMPLE.COM"
            architecture: "x86_64"
            operatingsystem: "AlmaLinux 8"
            kickstart_repository: "BaseOS_x86_64_os"
            activation_keys: "Standard AlmaLinux 8 Server"

fails with

...
"msg": "Found no results while searching for repositories with name=\"BaseOS_x86_64_os\""}

It’s searching by name, not by label.

1 Like

Ahhh… THAT name. Oh, god. Isn’t that extremely misleading, if you choose the label in the GUI but need to specify the name in the module? The label at least is guaranteed to be unique within a product but the name can be anything…

            operatingsystem: "AlmaLinux 8"
            kickstart_repository: "AlmaLinux-8 - BaseOS x86_64 os"
            ptable: "Kickstart default"
            pxe_loader: "Grub2 UEFI"
            activation_keys: "Standard AlmaLinux 8 Server"

Do you have any idea how to deal with the operating system in https://github.com/theforeman/foreman-ansible-modules/issues/1401

I cannot get past that…

It is scoped by content view, so it’s unique.

and no, I didn’t have time to look at that issue

You mean the name? That is still not unique. If I name my baseos repository of alma and centos simply “baseos” it wouldn’t be unique.

And depending on how you search it may even become ambiguous. For instance, my content view “EL8” contains CentOS Stream 8 and Alma Linux 8 (and soon RHEL 8) repositories, because regardless which operating system is actually installed I want to provide them access to all the same additional products like docker, postgresql, etc.

So if the name of my CentOS Stream and AlmaLinux baseos repository was simply “baseos” there wouldn’t be way to distinguish them.

I am not saying it’s a good idea to name repositories of different products identically but it’s possible…

But then the label is also not unique :wink:

# hammer repository list --organization "Default Organization" --search "label=base"
---|------|---------|--------------|----
ID | NAME | PRODUCT | CONTENT TYPE | URL
---|------|---------|--------------|----
2  | base | Rocky   | yum          |    
1  | base | Alma    | yum          |    
---|------|---------|--------------|----

Yes. I know. That’s what I wrote before: the label must be unique within a product. The GUI seems to enforce the same for the name, too. Although, looking into the database at katello_root_repositories.name that can even be null which is weird…

Either way, the correct selection for the module (and in the GUI for that matter in Host - Operating Systems settings are reset/missing when editing and ambiguity) in a host group depends on the operating system which should nail down to the product thus identifying potential repos.