In this blog post, I’m going to show how to add a new product caled EPEL8 and populate it with a repository from EPEL 8.

There should be 3 main steps:

  1. Create a Content-Credentials which stores the package signing key of the product or repository
  2. Create a new Product
  3. Create a new Repository

Firt thing first, let’s create a new content-credentials named RPM-GPG-KEY-EPEL-8 with the contents from the EPEL 8’s GPG signing key.

[root@foreman gpg-key]# curl -O -L https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1627  100  1627    0     0    919      0  0:00:01  0:00:01 --:--:--   919

Important note: For hammer version 0.19.2, we will create a gpg instead of content-credentials. For new version of hammer, you’re like to use hammer content-credentials command instead of hammer gpg.

[root@foreman gpg-key]# hammer --version
hammer (0.19.2)
 * hammer_cli_foreman (0.19.6)
 * hammer_cli_foreman_bootdisk (0.3.0)
 * hammer_cli_foreman_docker (unknown version)
 * hammer_cli_foreman_remote_execution (unknown version)
 * hammer_cli_foreman_tasks (unknown version)
 * hammer_cli_katello (0.20.2)

[root@foreman gpg-key]# hammer gpg create --help
Usage:
    hammer gpg create [OPTIONS]

Options:
 --key GPG_KEY_FILE                      GPG Key file
 --name NAME                             Identifier of the gpg key
 --organization ORGANIZATION_NAME        Organization name to search by
 --organization-id ORGANIZATION_ID       Organization ID
 --organization-label ORGANIZATION_LABEL Organization label to search by
 -h, --help                              Print help

Let’s create a new GPG (Content-Credential) called RPM-GPG-KEY-EPEL-8 and associated it with Finance organization.

[root@foreman gpg-key]# hammer gpg create --name 'RPM-GPG-KEY-EPEL-8' \
> --key RPM-GPG-KEY-EPEL-8 \
> --organization Finance
GPG Key created.
[root@foreman gpg-key]# hammer gpg list --organization Finance
---|----------------------------
ID | NAME
---|----------------------------
3  | RPM-GPG-KEY-EPEL-8
---|----------------------------

The second step is to create an new product. We’ll name it “EPEL8”.

[root@foreman gpg-key]# hammer product create --name 'EPEL8' \
> --description 'EPEL 8 Repos' \
> --gpg-key 'RPM-GPG-KEY-EPEL-8' \
> --organization Finance
Product created.

[root@foreman gpg-key]# hammer product list --organization Finance
---|-----------------------|--------------|--------------|--------------|------------------
ID | NAME                  | DESCRIPTION  | ORGANIZATION | REPOSITORIES | SYNC STATE
---|-----------------------|--------------|--------------|--------------|------------------
3  | EPEL8                 | EPEL 8 Repos | Finance      | 0            |
---|-----------------------|--------------|--------------|--------------|------------------

The last step is to add a repository to the above newly created product.

[root@foreman ~]# hammer repository create --name 'EPEL8' --label 'EPEL8' \
> --content-type 'yum' \
> --download-policy 'on_demand' \
> --product 'EPEL8' \
> --organization 'Finance' \
> --url 'https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64' \
> --mirror-on-sync 'no'
Repository created.

[root@foreman ~]# hammer repository list --organization Finance --product 'EPEL8'
---|-------|---------|--------------|----------------------------------------------------------
ID | NAME  | PRODUCT | CONTENT TYPE | URL
---|-------|---------|--------------|----------------------------------------------------------
54 | EPEL8 | EPEL8   | yum          | https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64
---|-------|---------|--------------|----------------------------------------------------------

The 3 steps to create a product (with a repository) is finished. However, before we can install a package from this new repository, we need to sync the repository first.

[root@foreman ~]# hammer repository synchronize --help
Usage:
    hammer repository synchronize [OPTIONS]

Options:
 --async                                   Do not wait for the task
 --id ID                                   Repository ID
 --incremental INCREMENTAL                 Perform an incremental import
                                           One of true/false, yes/no, 1/0.
 --name NAME                               Repository name to search by
 --organization ORGANIZATION_NAME          Organization name to search by
 --organization-id ORGANIZATION_ID         Organization ID
 --organization-label ORGANIZATION_LABEL   Organization label to search by
 --product PRODUCT_NAME                    Product name to search by
 --product-id PRODUCT_ID                   Product numeric identifier
 --skip-metadata-check SKIP_METADATA_CHECK Force sync even if no upstream changes are detected. Only used with yum
                                           Repositories.
                                           One of true/false, yes/no, 1/0.
 --source-url SOURCE_URL                   Temporarily override feed URL for sync
 --validate-contents VALIDATE_CONTENTS     Force a sync and validate the checksums of all content. Only used with yum
                                           Repositories.
                                           One of true/false, yes/no, 1/0.
 -h, --help                                Print help


[root@foreman ~]# hammer repository synchronize --async \
> --id 54 --organization Finance --product EPEL8
Repository is being synchronized in task fcb71bbf-7032-4c89-b675-2e72eb29c54e.

We can check the sync status:

[root@foreman ~]# hammer product list --name EPEL8 --organization Finance
---|-------|--------------|--------------|--------------|-----------
ID | NAME  | DESCRIPTION  | ORGANIZATION | REPOSITORIES | SYNC STATE
---|-------|--------------|--------------|--------------|-----------
3  | EPEL8 | EPEL 8 Repos | Finance      | 1            | Running
---|-------|--------------|--------------|--------------|-----------

And about 16 minutes later, the sync was completed.

[root@foreman ~]# hammer product list --name EPEL8 --organization Finance
---|-------|--------------|--------------|--------------|------------------
ID | NAME  | DESCRIPTION  | ORGANIZATION | REPOSITORIES | SYNC STATE
---|-------|--------------|--------------|--------------|------------------
3  | EPEL8 | EPEL 8 Repos | Finance      | 1            | Syncing Complete.
---|-------|--------------|--------------|--------------|------------------

References: