Introduction

In the context of Foreman, content is defined as the software installed on systems. This includes, but is not limited to, the base operating system, middleware services, and end-user applications. With Foreman, you can manage the various types of content for Red Hat Enterprise Linux systems at every stage of the software life cycle.

Important
The Katello plug-in provides content management features to Foreman. You can only use this guide if you have the Katello plug-in installed.

Foreman manages the following content:

Subscription management

This provides organizations with a method to manage their Red Hat subscription information.

Content management

This provides organizations with a method to store Red Hat content and organize it in various ways.

Content Management Types Overview

With Foreman, you can manage the following Red Hat content types:

RPM Packages

Import RPM files from repositories related to your Red Hat subscriptions. Foreman server downloads the RPM files from Red Hat’s Content Delivery Network and stores them locally. You can use these repositories and their RPM files in Content Views.

Kickstart Trees

Import the kickstart trees for creating a system. New systems access these kickstart trees over a network to use as base content for their installation. Foreman also contains some predefined kickstart templates as well as the ability to create your own, which are used to provision systems and customize the installation.

You can also manage other types of content in Foreman. For example:

ISO and KVM Images

Download and manage media for installation and provisioning. For example, Foreman downloads, stores and manages ISO images and guest images for specific Red Hat Enterprise Linux and non-Red Hat operating systems.

Puppet Modules

You can upload Puppet modules alongside RPM content so that Puppet can configure the system’s state after provisioning. Users can also manage Puppet classes and parameters as part of the provisioning process.

OSTree

You can import OSTree branches and publish this content to an HTTP location.

You can use the procedure to add content for any type of content you require, for example, SSL certificates and OVAL files.

Managing Organizations

Organizations divide Foreman resources into logical groups based on ownership, purpose, content, security level, or other divisions. You can create and manage multiple organizations through Foreman, then divide and assign your Red Hat subscriptions to each individual organization. This provides a method of managing the content of several individual organizations under one management system. Here are some examples of organization management:

Single Organization

A small business with a simple system administration chain. In this case, you can create a single organization for the business and assign content to it.

Multiple Organizations

A large company that owns several smaller business units. For example, a company with separate system administration and software development groups. In this case, you can create organizations for the company and each of the business units it owns. This keeps the system infrastructure for each separate. You can then assign content to each organization based on its needs.

External Organizations

A company that manages external systems for other organizations. For example, a company offering cloud computing and web hosting resources to customers. In this case, you can create an organization for the company’s own system infrastructure and then an organization for each external business. You can then assign content to each organization where necessary.

A default installation of Foreman has a default organization called Default_Organization.

New Users

If a new user is not assigned a default organization, their access is limited. To grant systems rights to users, assign them to a default organization. The next time the user logs on to Foreman, the user’s account has the correct system rights.

Creating an Organization

Use this procedure to create an organization.

Procedure

To create an organization, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Organizations.

  2. Click New Organization.

  3. In the Name field, enter a name for the organization.

  4. In the Label field, enter a unique identifier for the organization. This is used for creating and mapping certain assets, such as directories for content storage. Use letters, numbers, underscores, and dashes, but no spaces.

  5. Optional: in the Description field, enter a description for the organization.

  6. Click Submit.

  7. If you have hosts with no organization assigned, select the hosts that you want to add to the organization, then click Proceed to Edit.

  8. In the Edit page, assign the infrastructure resources that you want to add to the organization. This includes networking resources, installation media, kickstart templates, and other parameters. You can return to this page at any time by navigating to Administer > Organizations and then selecting an organization to edit.

  9. Click Submit.

For CLI Users
  1. To create an organization, enter the following command:

    # hammer organization create \
    --name "your_organization_name" \
    --label "your_organization_label \
    --description "your_organization_description"
  2. Optional: To edit an organization, enter the hammer organization update command. For example, the following command assigns a compute resource to the organization:

    # hammer organization update \
    --name "your_organization_name" \
    --compute-resource-ids 1

Setting the Organization Context

An organization context defines the organization to use for a host and its associated resources.

Procedure

The organization menu is the first menu item in the menu bar, on the upper left of the Foreman web UI. If you have not selected a current organization, the menu says Any Organization. Click the Any Organization button and select the organization to use.

For CLI Users

While using the CLI, include either --organization "your_organization_name" or --organization-label "your_organization_label" as an option. For example:

# hammer subscription list --organization "Default_Organization"

This command outputs subscriptions allocated for the Default_Organization.

Creating an Organization Debug Certificate

If you require a debug certificate for your organization, use the following procedure.

Procedure

To create a debug certificate for an organization, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Organizations.

  2. Select an organization that you want to generate a debug certificate for.

  3. Click Generate and Download.

  4. Save the certificate file in a secure location.

Debug Certificates for Provisioning Templates

Debug Certificates are automatically generated for provisioning template downloads if they do not already exist in the organization for which they are being downloaded.

Browsing Repository Content Using an Organization Debug Certificate

You can view an organization’s repository content using a web browser or using the API if you have a debug certificate for that organization.

Prerequisites
  1. Create and download an organization certificate as described in Creating an Organization Debug Certificate.

  2. Open the X.509 certificate, for example, for the default organization:

    $ vi 'Default Organization-key-cert.pem'
  3. Copy the contents of the file from -----BEGIN RSA PRIVATE KEY----- to -----END RSA PRIVATE KEY-----, into a key.pem file.

  4. Copy the contents of the file from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----, into a cert.pem file.

Procedure

To use a browser, you must first convert the X.509 certificate to a format your browser supports and then import the certificate.

For Firefox Users

To use an organization debug certificate in Firefox, complete the following steps:

  1. To create a PKCS12 format certificate, enter the following command:

    $ openssl pkcs12 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -export -in cert.pem -inkey key.pem -out organization_label.pfx -name organization_name
  2. In the Firefox browser, navigate to Edit > Preferences > Advanced Tab.

  3. Select View Certificates, and click the Your Certificates tab.

  4. Click Import and select the .pfx file to load.

  5. In the address bar, enter a URL in the following format to browse for repositories:

    http://foreman.example.com/pulp/repos/organization_label

    Pulp uses the organization label, therefore, you must enter the organization label into the URL.

For CURL Users

To use the organization debug certificate with CURL, enter the following command:

$ curl -k --cert cert.pem --key key.pem \
http://foreman.example.com/pulp/repos/Default_Organization/Library/content/dist/rhel/server/7/7Server/x86_64/sat-tools/6.7/os/

Ensure that the paths to cert.pem and key.pem are the correct absolute paths otherwise the command fails silently.

Deleting an Organization

You can delete an organization if the organization is not associated with any life cycle environments or host groups. If there are any life cycle environments or host groups associated with the organization you are about to delete, remove them by navigating to Administer > Organizations and clicking the relevant organization. Do not delete the default organization created during installation because the default organization is a placeholder for any unassociated hosts in the Foreman environment. There must be at least one organization in the environment at any given time.

Procedure

To delete an organization, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Organizations.

  2. From the list to the right of the name of the organization you want to delete, select Delete.

  3. Click OK to delete the organization.

For CLI Users
  1. Enter the following command to retrieve the ID of the organization that you want to delete:

    # hammer organization list

    From the output, note the ID of the organization that you want to delete.

  2. Enter the following command to delete an organization:

    # hammer organization delete --id Organization_ID

Managing Locations

Locations function similar to organizations: they provide a method to group resources and assign hosts. Organizations and locations have the following conceptual differences:

  • Locations are based on physical or geographical settings.

  • Locations have a hierarchical structure.

Creating a Location

Use this procedure to create a location so that you can manage your hosts and resources by location.

Procedure

To create a location, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Locations.

  2. Click New Location.

  3. Optional: from the Parent list, select a parent location. This creates a location hierarchy.

  4. In the Name field, enter a name for the location.

  5. Optional: in the Description field, enter a description for the location.

  6. Click Submit.

  7. If you have hosts with no location assigned, add any hosts that you want to assign to the new location, then click Proceed to Edit.

  8. Assign any infrastructure resources that you want to add to the location. This includes networking resources, installation media, kickstart templates, and other parameters. You can return to this page at any time by navigating to Administer > Locations and then selecting a location to edit.

  9. Click Submit to save your changes.

For CLI Users

Enter the following command to create a location:

# hammer location create \
--parent-id "parent_location_id" \
--name "your_location_name" \
--description "your_location_description"

Creating Multiple Locations

The following example Bash script creates three locations - London, Munich, Boston - and assigns them to the Example Organization.

ORG="Example Organization"
LOCATIONS="London Munich Boston"

for LOC in ${LOCATIONS}
do
  hammer location create --name "${LOC}"
  hammer location add-organization --name "${LOC}" --organization "${ORG}"
done

Setting the Location Context

A location context defines the location to use for a host and its associated resources.

Procedure

The location menu is the second menu item in the menu bar, on the upper left of the Foreman web UI. If you have not selected a current location, the menu displays Any Location. Click Any location and select the location to use.

For CLI Users

While using the CLI, include either --location "your_location_name" or --location-id "your_location_id" as an option. For example:

# hammer subscription list --location "Default_Location"

This command outputs subscriptions allocated for the Default_Location.

Deleting a Location

You can delete a location if the location is not associated with any life cycle environments or host groups. If there are any life cycle environments or host groups associated with the location you are about to delete, remove them by navigating to Administer > Locations and clicking the relevant location. Do not delete the default location created during installation because the default location is a placeholder for any unassociated hosts in the Foreman environment. There must be at least one location in the environment at any given time.

Procedure

To delete a location, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Locations.

  2. Select Delete from the list to the right of the name of the location you want to delete.

  3. Click OK to delete the location.

For CLI Users
  1. Enter the following command to retrieve the ID of the location that you want to delete:

    # hammer location list

    From the output, note the ID of the location that you want to delete.

  2. Enter the following command to delete the location:

    # hammer location delete --id Location ID

Managing Subscriptions

Foreman can import content from the Red Hat Content Delivery Network (CDN). Foreman requires a Subscription Manifest to find, access, and download content from the corresponding repositories. You must have a Subscription Manifest containing a subscription allocation for each organization on Foreman server. All subscription information is available in your Red Hat Customer Portal account.

Before you can complete the tasks in this chapter, you must create a Subscription Manifest in the Customer Portal.

To create, manage, and export a Subscription Manifest in the Customer Portal, see Using Manifests in the Using Red Hat Subscription Management guide.

Use this chapter to import a Subscription Manifest and manage the manifest within the Foreman web UI.

Subscription Allocations and Organizations

You can manage more than one organization if you have more than one subscription allocation. Foreman requires a single allocation for each organization configured in Foreman server. The advantage of this is that each organization maintains separate subscriptions so that you can support multiple organizations, each with their own Red Hat accounts.

Future-Dated subscriptions

You can use future-dated subscriptions in a subscription allocation. When you add future-dated subscriptions to content hosts before the expiry date of the existing subscriptions, you can have uninterrupted access to repositories.

Manually attach the future-dated subscriptions to your content hosts before the current subscriptions expire. Do not rely on the auto-attach method because this method is designed for a different purpose and might not work. For more information, see Attaching Subscriptions to Content Hosts.

Importing a Subscription Manifest into Foreman server

Use the following procedure to import a Subscription Manifest into Foreman server.

This is for users of the Katello plug-in and Red Hat operating systems only.

Prerequisites
  • You must have a Subscription Manifest file exported from the Customer Portal. For more information, see Using Manifests in the Using Red Hat Subscription Management guide.

Procedure
  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Content > Subscriptions and click Manage Manifest.

  3. In the Manage Manifest window, click Browse.

  4. Navigate to the location that contains the Subscription Manifest file, then click Open. If the Manage Manifest window does not close automatically, click Close to return to the Subscriptions window.

For CLI Users
  1. Copy the Subscription Manifest file from your client to Foreman server:

    $ scp ~/manifest_file.zip root@foreman.example.com:~/.
  2. Log in to Foreman server as the root user and import the Subscription Manifest file:

    # hammer subscription upload \
    --file ~/manifest_file.zip \
    --organization "organization_name"

You can now enable repositories and import Red Hat content. For more information, see Importing Red Hat Content.

Locating a Subscription in the Foreman Web UI

When you import a Subscription Manifest into Foreman server, the subscriptions from your manifest are listed in the Subscriptions window. If you have a high volume of subscriptions, you can filter the results to find a specific subscription.

Prerequisite

You must have a Subscription Manifest file imported to Foreman server. For more information, see Importing a Subscription Manifest into Foreman server.

Procedure

To locate a subscription, complete the following steps:

  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Content > Subscriptions.

  3. In the Subscriptions window, click the Search field to view the list of search criteria for building your search query.

  4. Select search criteria to display further options.

  5. When you have built your search query, click the search icon.

For example, if you place your cursor in the Search field and select expires, then press the space bar, another list appears with the options of placing a >, <, or = character. If you select > and press the space bar, another list of automatic options appears. You can also enter your own criteria.

Adding Subscriptions to Subscription Allocations in the Foreman Web UI

Use the following procedure to add subscriptions to a subscription allocation in the Foreman web UI.

Prerequisite

You must have a Subscription Manifest file imported to Foreman server. For more information, see Importing a Subscription Manifest into Foreman server.

Procedure

To add subscriptions to a subscription allocation, complete the following steps:

  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Content > Subscriptions.

  3. In the Subscriptions window, click Add Subscriptions.

  4. On the row of each subscription you want to add, enter the quantity in the Quantity to Allocate column.

  5. Click Submit.

Removing Subscriptions from Subscription Allocations in the Foreman Web UI

Use the following procedure to remove subscriptions from a subscription allocation in the Foreman web UI.

Note

Manifests must not be deleted. If you delete the manifest from the Red Hat Customer Portal or in the Foreman web UI, all of the entitlements for all of your content hosts will be removed.

Prerequisite

You must have a Subscription Manifest file imported to Foreman server. For more information, see Importing a Subscription Manifest into Foreman server.

Procedure

To remove subscriptions, complete the following steps:

  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Content > Subscriptions.

  3. On the row of each subscription you want to remove, select the corresponding check box.

  4. Click Delete, and then confirm deletion.

Updating and Refreshing Subscription Manifests

Every time that you change a subscription allocation, you must refresh the manifest to reflect these changes. For example, you must refresh the manifest if you take any of the following actions:

  • Renewing a subscription

  • Adjusting subscription quantities

  • Purchasing additional subscriptions

You can refresh the manifest directly in the Foreman web UI. Alternatively, you can import an updated manifest that contains the changes.

Procedure
  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Content > Subscriptions.

  3. In the Subscriptions window, click Manage Manifest.

  4. In the Manage Manifest window, click Refresh.

Attaching Subscriptions to Content Hosts

Using activation keys is the main method to attach subscriptions to content hosts during the provisioning process. However, an activation key cannot update an existing host. If you need to attach new or additional subscriptions, such as future-dated subscriptions, to one host, use the following procedure.

For more information about updating multiple hosts, see Bulk Updating Content Hosts' Subscriptions.

For more information about activation keys, see Managing Activation Keys.

Smart Management Subscriptions

In Foreman, you must maintain a Red Hat Enterprise Linux Smart Management subscription for every Red Hat Enterprise Linux host that you want to manage.

However, you are not required to attach Smart Management subscriptions to each content host. Smart Management subscriptions cannot attach automatically to content hosts in Foreman because they are not associated with any product certificates. Adding a Smart Management subscription to a content host does not provide any content or repository access. If you want, you can add a Smart Management subscription to a manifest for your own recording or tracking purposes.

Prerequisite

You must have a Subscription Manifest file imported to Foreman server.

Procedure

To attach subscriptions to content hosts, complete the following steps:

  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Hosts > Content Hosts.

  3. On the row of each content host whose subscription you want to change, select the corresponding check box.

  4. From the Select Action list, select Manage Subscriptions.

  5. Optionally, enter a key and value in the Search field to filter the subscriptions displayed.

  6. Select the check box to the left of the subscriptions that you want to add or remove and click Add Selected or Remove Selected as required.

  7. Click Done to save the changes.

For CLI Users
  1. Connect to Foreman server as the root user, and then list the available subscriptions:

    # hammer subscription list \
    --organization-id 1
  2. Attach a subscription to the host:

    # hammer host subscription attach \
    --host host_name \
    --subscription-id subscription_id

Bulk Updating Content Hosts' Subscriptions

Use this procedure for post-installation changes to multiple content hosts at the same time.

Procedure

To update multiple content hosts, complete the following steps:

  1. In the Foreman web UI, ensure the context is set to the organization you want to use.

  2. Navigate to Hosts > Content Hosts.

  3. On the row of each content host whose subscription you want to change, select the corresponding check box.

  4. From the Select Action list, select Manage Subscriptions.

  5. Optionally, enter a key and value in the Search field to filter the subscriptions displayed.

  6. Select the check box to the left of the subscriptions to be added or removed and click Add Selected or Remove Selected as required.

  7. Click Done to save the changes.

Importing Content

This chapter outlines how you can import content of different types to Foreman. If you want to import ISOs, Puppet modules, or different content types to Foreman, it is done with largely the same procedures in this chapter.

For example, you can use the following chapters for information on specific types of content but the underlying procedures are the same:

Using Products in Foreman

Both Red Hat content and non-RH content in Foreman have similarities:

  • The relationship between a product and its repositories is the same and the repositories still require synchronization.

  • products require a subscription for clients to access, similar to subscriptions to Red Hat Products. Foreman creates a subscription for each product you create.

For more information about creating and packaging RPMs, see the RPM Packaging Guide in the Red Hat Enterprise Linux documentation.

Importing SSL Certificates

Before you create content, ensure that you import any SSL certificates that you require.

If you require SSL certificates and keys to download RPMs, you can add them to Foreman.

  1. In the Foreman web UI, navigate to Content > Content Credentials. In the Content Credentials window, click Create Content Credential.

  2. In the Name field, enter a name for your SSL certificate.

  3. From the Type list, select SSL Certificate.

  4. In the Content Credentials Content field, paste your SSL certificate, or click Browse to upload your SSL certificate.

  5. Click Save.

Importing a GPG Key

Before you create content, ensure that you import any GPG keys that you require.

Prerequisites
  1. Download a copy of the version specific repository package to your client system:

    $ wget http://www.example.com/9.5/example-9.5-2.noarch.rpm
  2. Extract the RPM file without installing it:

    $ rpm2cpio example-9.5-2.noarch.rpm | cpio -idmv

The GPG key is located relative to the extraction at etc/pki/rpm-gpg/RPM-GPG-KEY-EXAMPLE-95.

Procedure

To import a GPG key, complete the following procedure:

  1. In the Foreman web UI, navigate to Content > Content Credentials and in the upper-right of the window, click Create Content Credential.

  2. Enter the name of your repository and select GPG Key from the Type list.

  3. Either paste the GPG key into the Content Credential Contents field, or click Browse and select the GPG key file that you want to import.

    If your repository contains content signed by multiple GPG keys, you must enter all required GPG keys in the Content Credential Contents field with new lines between each key, for example:

    -----BEGIN PGP PUBLIC KEY BLOCK-----
    
    mQINBFy/HE4BEADttv2TCPzVrre+aJ9f5QsR6oWZMm7N5Lwxjm5x5zA9BLiPPGFN
    4aTUR/g+K1S0aqCU+ZS3Rnxb+6fnBxD+COH9kMqXHi3M5UNzbp5WhCdUpISXjjpU
    XIFFWBPuBfyr/FKRknFH15P+9kLZLxCpVZZLsweLWCuw+JKCMmnA
    =F6VG
    -----END PGP PUBLIC KEY BLOCK-----
    
    -----BEGIN PGP PUBLIC KEY BLOCK-----
    
    mQINBFw467UBEACmREzDeK/kuScCmfJfHJa0Wgh/2fbJLLt3KSvsgDhORIptf+PP
    OTFDlKuLkJx99ZYG5xMnBG47C7ByoMec1j94YeXczuBbynOyyPlvduma/zf8oB9e
    Wl5GnzcLGAnUSRamfqGUWcyMMinHHIKIc1X1P4I=
    =WPpI
    -----END PGP PUBLIC KEY BLOCK-----
  4. Click Save.

For CLI Users
  1. Copy the GPG key to your Foreman server:

    $ scp ~/etc/pki/rpm-gpg/RPM-GPG-KEY-EXAMPLE-95 root@foreman.example.com:~/.
  2. Upload the GPG key to Foreman:

    # hammer gpg create \
    --key ~/RPM-GPG-KEY-EXAMPLE-95 \
    --name "My_Repository" \
    --organization "My_Organization"

Creating a Product

Use this procedure to create a product that you can then add repositories to.

Procedure

To create a product, complete the following procedure:

  1. In the Foreman web UI, navigate to Content > Products, click Create Product.

  2. In the Name field, enter a name for the product. Foreman automatically completes the Label field based on what you have entered for Name.

  3. Optional: From the GPG Key list, select the GPG key for the product.

  4. Optional: From the SSL CA Cert list, select the SSL CA certificate for the product.

  5. Optional: From the SSL Client Cert list, select the SSL client certificate for the product.

  6. Optional: From the SSL Client Key list, select the SSL client key for the product.

  7. Optional: From the Sync Plan list, select an existing sync plan or click Create Sync Plan and create a sync plan for your product requirements.

  8. In the Description field, enter a description of the product.

  9. Click Save.

For CLI Users

To create the product, enter the following command:

# hammer product create \
--name "My_Product" \
--sync-plan "Example Plan" \
--description "Content from My Repositories" \
--organization "My_Organization"

Adding RPM Repositories

Use this procedure to add RPM repositories in Foreman.

The Products window in the Foreman web UI also provides a Repo Discovery function that finds all repositories from a URL and you can select which ones to add to your product. For example, you can use the Repo Discovery to search, for example, http://yum.postgresql.org/9.5/redhat/ and list all repositories for different Red Hat Enterprise Linux versions and architectures. This helps users save time importing multiple repositories from a single source.

Procedure
  1. In the Foreman web UI, navigate to Content > Products and select the product that you want to use, and then click Create Repository.

  2. In the Name field, enter a name for the repository. Foreman automatically completes the Label field based on what you have entered for Name.

  3. From the Type list, select the type of repository. You can select either a repository for RPM files (yum), Puppet modules (puppet), or Docker images (docker).

  4. In the URL field, enter the URL of the external repository to use as a source.

  5. From the Download Policy list, select the type of synchronization Foreman server performs.

  6. Ensure that the Mirror on Sync check box is selected. This ensures that the content that is no longer part of the upstream repository is removed during synchronization.

  7. From the Checksum list, select the checksum type for the repository.

  8. Optional: If you want, you can clear the Publish via HTTP check box to disable this repository from publishing through HTTP.

  9. Optional: From the GPG Key list, select the GPG key for the product.

  10. Click Save.

If you want to perform an immediate synchronization, in your product window, click Sync Now.

For CLI Users
  1. Enter the following command to create the repository:

    # hammer repository create \
    --name "My_Repository" \
    --content-type "yum" \
    --publish-via-http true \
    --url http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/ \
    --gpg-key "My_Repository" \
    --product "My_Product" \
    --organization "My_Organization"
  2. Synchronize the repository:

    # hammer repository synchronize \
    --name "My_Repository" \
    --product "My Product" \
    --organization "My_Organization"

Uploading Content to RPM Repositories

You can upload individual RPMs and source RPMs to RPM repositories. You can upload RPMs using the Foreman web UI or the Hammer CLI. You must use the Hammer CLI to upload source RPMs.

Procedure
  1. In the Foreman web UI, click Content > Products.

  2. Click the name of the product.

  3. In the Repositories tab, click the name of the RPM repository.

  4. Under Upload Package, click Browse…​ and select the RPM you want to upload.

  5. Click Upload.

To view all RPMs in this repository, click the number next to Packages under Content Counts.

For CLI Users
  • Enter the following command to upload an RPM:

    # hammer repository upload-content \
    --id repo_ID \
    --path /path/to/example-package.rpm
  • Enter the following command to upload a source RPM:

    # hammer repository upload-content \
    --content-type srpm \
    --id repo_ID \
    --path /path/to/example-package.src.rpm

    When the upload is complete, you can view information about a source RPM by using the commands hammer srpm list and hammer srpm info --id srpm_ID.

Importing Red Hat Content

This section describes how to use products and repositories in Foreman, and to create synchronization plans to ensure your Foreman content remains up to date with the content on the Red Hat Content delivery network (CDN).

Products in Foreman

In Foreman, a Product is an organizational unit to group multiple repositories together. For example, Red Hat Enterprise Linux Server is a Product in Foreman, the repositories for that product consist of different versions, different architectures, and different add-ons. Using Products ensures repositories that depend on each other are synchronized together. For Red Hat repositories, products are created automatically after enabling the repository.

Content Synchronization Overview

Foreman server synchronizes its own repositories with the repositories on the Red Hat CDN. This ensures that Foreman server retains an exact copy of Red Hat’s repositories. Foreman server fetches this repository information and stores it on Foreman server’s file system. After an initial synchronization, you can create a synchronization plan that checks to ensure the repositories are up to date with the CDN’s repositories.

You can perform an initial synchronization using ISO images. For more information about using content ISOs, see Importing Content ISOs into a Connected Foreman.

Download Policies Overview

Foreman provides multiple download policies for synchronizing RPM content. For example, you might want to download only the content metadata while deferring the actual content download for later.

Foreman server has the following policies:

Immediate

Foreman server downloads all metadata and packages during synchronization.

On Demand

Foreman server downloads only the metadata during synchronization. Foreman server only fetches and stores packages on the file system when Smart Proxies or directly connected clients request them. This setting has no effect if you set a corresponding repository on a Smart Proxy to Immediate because Foreman server is forced to download all the packages.

Background

Foreman server creates a background task to download all packages after the initial synchronization.

The On Demand and Background policies act as a Lazy Synchronization feature because they save time synchronizing content. The lazy synchronization feature must be used only for yum repositories. You can add the packages to Content Views and promote to life cycle environments as normal.

Smart Proxy server offers the following policies:

Immediate

Smart Proxy server downloads all metadata and packages during synchronization. Do not use this setting if the corresponding repository on Foreman server is set to On Demand as Foreman server is forced to download all the packages.

On Demand

Smart Proxy server only downloads the metadata during synchronization. Smart Proxy server fetches and stores packages only on the file system when directly connected clients request them. When you use an On Demand download policy, content is downloaded from Foreman server if it is not available on Smart Proxy server.

Background

Smart Proxy server creates a background task to download all packages after the initial synchronization.

Inherit

Smart Proxy server inherits the download policy for the repository from the corresponding repository on Foreman server.

These policies are not available if a Smart Proxy was installed or updated with --enable-foreman-proxy-plugin-pulp set to false.

Changing the Default Download Policy

You can set the default download policy that Foreman applies to repositories that you create in all organizations.

Depending on whether it is a Red Hat or non-Red Hat repository, Foreman uses separate settings. Changing the default value does not change existing settings.

Procedure

To change the default download policy for repositories, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Settings.

  2. Click the Content tab.

  3. Change the default download policy depending on your requirements:

    • To change the default download policy for a Red Hat repository, change the value of the Default Red Hat Repository download policy setting.

    • To change the default download policy for a non-Red Hat repository, change the value of the Default Custom Repository download policy setting.

For CLI Users

To change the default download policy for Red Hat repositories to one of immediate, on_demand, or background, enter the following command:

# hammer settings set \
--name default_redhat_download_policy \
--value immediate
# hammer settings set \
--name default_download_policy \
--value immediate

Changing the Download Policy for a Repository

You can also set the download policy for a repository.

Procedure

To set the download policy for a repository, complete the following steps:

  1. In the web UI, navigate to Content > Products, and click the required product name.

  2. On the Repositories tab, click the required repository name, locate the Download Policy field, and click the edit icon.

  3. From the list, select the required download policy and then click Save.

For CLI Users
  1. List the repositories for an organization:

    # hammer repository list \
    --organization-label organization-label
  2. Change the download policy for a repository to one of immediate, on_demand, background:

    # hammer repository update \
    --organization-label organization-label  \
    --product "Red Hat Enterprise Linux Server" \
    --name "Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.5"  \
    --download-policy immediate

Enabling Red Hat Repositories

To select the repositories to synchronize, you must first identify the product that contains the repository, and then enable that repository based on the relevant release version and base architecture. For Red Hat Enterprise Linux 8, you must enable both AppStream and BaseOS repositories.

Repository Versioning

The difference between associating Red Hat Enterprise Linux operating system with either 7 Server repositories or 7.X repositories is that 7 Server repositories contain all the latest updates while Red Hat Enterprise Linux 7.X repositories stop getting updates after the next minor version release. Note that Kickstart repositories only have minor versions.

For Red Hat Enterprise Linux 8 Clients

To provision Red Hat Enterprise Linux 8 clients, you require the Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMS) and Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) repositories.

For Red Hat Enterprise Linux 7 Clients

To provision Red Hat Enterprise Linux 7 clients, you require the Red Hat Enterprise Linux 7 Server (RPMs) repository.

Procedure
  1. In the Foreman web UI, navigate to Content > Red Hat Repositories.

  2. To find repositories, either enter the repository name, or toggle the Recommended Repositories button to the on position to view a list of repositories that you require.

  3. In the Available Repositories pane, click a repository to expand the repository set.

  4. Click the Enable icon next to the base architecture and release version that you want.

For CLI Users
  1. To search for your product, enter the following command:

    # hammer product list --organization "My_Organization"
  2. List the repository set for the product:

    # hammer repository-set list \
    --product "Red Hat Enterprise Linux Server" \
    --organization "My_Organization"
  3. Enable the repository using either the name or ID number. Include the release version, for example,7Server and base architecture, for example, x86_64. For example:

    # hammer repository-set enable \
    --name "Red Hat Enterprise Linux 7 Server (RPMs)" \
    --releasever "7Server" \
    --basearch "x86_64" \
    --product "Red Hat Enterprise Linux Server" \
    --organization "My_Organization"

Synchronizing Red Hat Repositories

Synchronize the repositories with the Red Hat CDN’s repositories.

For Web UI Users
  1. In the Foreman web UI, navigate to Content > Products and select the product that contains the repositories that you want to synchronize.

  2. Select the repositories that you want to synchronize and click Sync Now.

To view the progress of the synchronization in the web UI, navigate to Content > Sync Status and expand the corresponding product or repository tree.

For CLI Users

Synchronize the enabled repositories in the Red Hat Enterprise Linux Server product:

# hammer product synchronize \
--name "Red Hat Enterprise Linux Server" \
--organization "My_Organization"

You can also synchronize each repository individually. List all repositories in the product, then synchronize using the ID number for the corresponding repositories. For example:

# hammer repository list \
--product "Red Hat Enterprise Linux Server" \
--organization "My_Organization"
# hammer repository synchronize \
--name "Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server" \
--product "Red Hat Enterprise Linux Server" \
--organization "My_Organization"

The synchronization duration depends on the size of each repository and the speed of your network connection. The following table provides estimates of how long it would take to synchronize content, depending on the available Internet bandwidth:

Single Package (10Mb) Minor Release (750Mb) Major Release (6Gb)

256 Kbps

5 Mins 27 Secs

6 Hrs 49 Mins 36 Secs

2 Days 7 Hrs 55 Mins

512 Kbps

2 Mins 43.84 Secs

3 Hrs 24 Mins 48 Secs

1 Day 3 Hrs 57 Mins

T1 (1.5 Mbps)

54.33 Secs

1 Hr 7 Mins 54.78 Secs

9 Hrs 16 Mins 20.57 Secs

10 Mbps

8.39 Secs

10 Mins 29.15 Secs

1 Hr 25 Mins 53.96 Secs

100 Mbps

0.84 Secs

1 Min 2.91 Secs

8 Mins 35.4 Secs

1000 Mbps

0.08 Secs

6.29 Secs

51.54 Secs

Create a synchronization plan to ensure updates on a regular basis.

Synchronizing All Repositories in an Organization

Use this procedure to synchronize all repositories within an organization.

Procedure

To synchronize all repositories within an organization, run the following Bash script on your Foreman server:

ORG="Your_Organization"

for i in $(hammer --no-headers --csv repository list --organization $ORG | awk -F, {'print $1'})
do
  hammer repository synchronize --id ${i} --organization $ORG --async
done

Recovering a Repository

In the case of repository corruption, you can recover it by using an advanced synchronization, which has three options:

Optimized Sync

Synchronizes the repository bypassing RPMs that have no detected differences from the upstream RPMs.

Complete Sync

Synchronizes all RPMs regardless of detected changes. Use this option if specific RPMs could not be downloaded to the local repository even though they exist in the upstream repository.

Validate Content Sync

Synchronizes all RPMs and then verifies the checksum of all RPMs locally. If the checksum of an RPM differs from the upstream, it re-downloads the RPM. This option is relevant only for yum repositories. Use this option if you have one of the following errors:

  • Specific RPMs cause a 404 error while synchronizing with yum.

  • Package does not match intended download error, which means that specific RPMs are corrupted.

Procedure

To synchronize a specific repository with an advanced option, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Products.

  2. Select the product containing the corrupted repository.

  3. Select the name of a repository you want to synchronize.

  4. From the Select Action menu, select Advanced Sync.

  5. Select the option and click Sync.

For CLI users
  1. Obtain a list of repository IDs:

    # hammer repository list --organization "My_Organization"
  2. Synchronize a corrupted repository using the necessary option:

    • For the optimized synchronization:

      # hammer repository synchronize --incremental true --id 1
    • For the complete synchronization:

      # hammer repository synchronize --skip-metadata-check true --id 1
    • For the validate content synchronization:

      # hammer repository synchronize --validate-contents true --id 1

Changing the HTTP Proxy Policy for a Product

For granular control over network traffic, you can set an HTTP proxy policy for each Product. A Product’s HTTP proxy policy applies to all repositories in the Product, unless you set a different policy for individual repositories.

To set an HTTP proxy policy for individual repositories, see Changing the HTTP Proxy Policy for a Repository.

Procedure
  1. In the Foreman web UI, navigate to Content > Products and select the check box next to each of the Products that you want to change.

  2. From the Select Action list, select Manage HTTP Proxy.

  3. Select an HTTP Proxy Policy from the list:

    • Global Default: Use the global default proxy setting.

    • No HTTP Proxy: Do not use an HTTP proxy, even if a global default proxy is configured.

    • Use specific HTTP Proxy: Select an HTTP Proxy from the list. You must add HTTP proxies to Foreman before you can select a proxy from this list. For more information, see Adding a New HTTP Proxy.

  4. Click Update.

Changing the HTTP Proxy Policy for a Repository

For granular control over network traffic, you can set an HTTP proxy policy for each repository.

To set the same HTTP proxy policy for all repositories in a Product, see Changing the HTTP Proxy Policy for a Product.

Procedure
  1. In the Foreman web UI, navigate to Content > Products and click the name of the Product that contains the repository.

  2. In the Repositories tab, click the name of the repository.

  3. Locate the HTTP Proxy field and click the edit icon.

  4. Select an HTTP Proxy Policy from the list:

    • Global Default: Use the global default proxy setting.

    • No HTTP Proxy: Do not use an HTTP proxy, even if a global default proxy is configured.

    • Use specific HTTP Proxy: Select an HTTP Proxy from the list. You must add HTTP proxies to Foreman before you can select a proxy from this list. For more information, see Adding a New HTTP Proxy.

  5. Click Save.

For CLI users
  • On Foreman server, enter the following command, specifying the HTTP proxy policy you want to use:

    # hammer repository update --id repository-ID \
    --http-proxy-policy policy

    Specify one of the following options for --http-proxy-policy:

    • none: Do not use an HTTP proxy, even if a global default proxy is configured.

    • global_default_http_proxy: Use the global default proxy setting.

    • use_selected_http_proxy: Specify an HTTP proxy using either --http-proxy proxy-name or --http-proxy-id proxy-ID. To add a new HTTP proxy to Foreman, see Adding a New HTTP Proxy.

Adding a New HTTP Proxy

Use this procedure to add HTTP proxies to Foreman. You can then specify which HTTP proxy to use for Products, repositories, and supported compute resources.

Procedure
  1. In the Foreman web UI, navigate to Infrastructure > HTTP Proxies and select New HTTP Proxy.

  2. In the Name field, enter a name for the HTTP proxy.

  3. In the URL field, enter the URL for the HTTP proxy, including the port number.

  4. If your HTTP proxy requires authentication, enter a Username and Password.

  5. Optional: In the Test URL field, enter the HTTP proxy URL, then click Test Connection to ensure that you can connect to the HTTP proxy from Foreman.

  6. Click the Locations tab and add a location.

  7. Click the Organization tab and add an organization.

  8. Click Submit.

For CLI Users
  • On Foreman server, enter the following command to add a new HTTP proxy:

    # hammer http-proxy create --name proxy-name \
    --url proxy-URL:port-number

    If your HTTP proxy requires authentication, add the --username name and --password password options.

Limiting Synchronization Speed

You can control the speed of synchronization to avoid exhaustion of available bandwidth and to prevent other performance issues. This is done by configuring PULP_CONCURRENCY and max_speed parameters. Note that these settings are overwritten on an upgrade. Back up any changed files prior to an upgrade to be able to restore the configuration.

  1. To control the number of synchronization jobs that run in parallel, configure the PULP_CONCURRENCY parameter in the /etc/default/pulp_workers file. For example, to set the number of jobs that run in parallel to 1, change PULP_CONCURRENCY to 1:

    PULP_CONCURRENCY=1

    By default, on a system with less than 8 CPUs, PULP_CONCURRENCY is set to the number of CPUs. On a system with more than 8 CPUs, it is set to 8.

  2. To set the maximum network speed for synchronizing in bytes per second, configure the max_speed parameter. This parameter must be configured separately for each importer in the /etc/pulp/server/plugins.conf.d/ directory. For example, to set the maximum speed for synchronizing RPM content to 10 bytes per second, set the "max_speed" parameter in the /etc/pulp/server/plugins.conf.d/yum_importer.json file to 10:

    # cat /etc/pulp/server/plugins.conf.d/yum_importer.json
    {
        "proxy_host": null,
        "proxy_port": null,
        "proxy_username": null,
        "proxy_password": null,
        "max_speed": 10
    }
  3. Verify the syntax of the file after editing:

    # json_verify < /etc/pulp/server/plugins.conf.d/yum_importer.json
    JSON is valid
  4. Restart the foreman-maintain services to apply the changes:

    # foreman-maintain service restart

Creating a Synchronization Plan

A synchronization plan checks and updates the content at a scheduled date and time. In Foreman, you can create a synchronization plan and assign products to the plan.

Procedure

To create a synchronization plan, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Sync Plans and click New Sync Plan.

  2. In the Name field, enter a name for the plan.

  3. In the Description field, enter a description of the plan.

  4. From the Interval list, select the interval at which you want the plan to run.

  5. From the Start Date and Start Time lists, select when to start running the synchronization plan.

  6. Click Save.

  7. Click the Products tab, then click Add. Select the Red Hat Enterprise Linux Server product and click Add Selected.

For CLI Users
  1. To create the synchronization plan, enter the following command:

    # hammer sync-plan create \
    --name "Red Hat Products 2" \
    --description "Example Plan for Red Hat Products" \
    --interval daily \
    --sync-date "2016-02-01 01:00:00" \
    --enabled true \
    --organization "My_Organization"
  2. Assign the Red Hat Enterprise Linux Server product to it:

    # hammer product set-sync-plan \
    --name "Red Hat Enterprise Linux Server" \
    --sync-plan "Red Hat Products" \
    --organization "My_Organization"
  3. View the available synchronization plans for an organization to verify that the synchronization plan is created:

    # hammer sync-plan list --organization "Default Organization"

Assigning a Synchronization Plan to Multiple Products

Use this procedure to assign a synchronization plan to the products in an organization that have been synchronized at least once and contain at least one repository

Procedure

To assign a synchronization plan to the selected products, complete the following steps:

  1. Run the following Bash script:

    ORG="Your_Organization"
    SYNC_PLAN="daily_sync_at_3_a.m"
    
    for i in $(hammer --no-headers --csv product list --organization $ORG --per-page 999 | grep -vi not_synced | awk -F, {'{ if ($5!=0) print $1}'})
    do
      hammer sync-plan create --name $SYNC_PLAN --interval daily --sync-date "2018-06-20 03:00:00" --enabled true --organization $ORG
      hammer product set-sync-plan --sync-plan $SYNC_PLAN --organization $ORG --id $i
    done
  2. After executing the script, view the products assigned the synchronization plan:

    # hammer product list --organization $ORG --sync-plan $SYNC_PLAN

Managing Application Life Cycles

This chapter outlines the application life cycle in Foreman and how to create and remove application life cycles for Foreman and Smart Proxy.

Application Life Cycle Overview

The application life cycle is a concept central to Foreman’s content management functions. The application life cycle defines how a particular system and its software look at a particular stage. For example, an application life cycle might be simple; you might only have a development stage and production stage. In this case the application life cycle might look like this:

  • Development

  • Production

However, a more complex application life cycle might have further stages, such as a phase for testing or a beta release. This adds extra stages to the application life cycle:

  • Development

  • Testing

  • Beta Release

  • Production

Foreman provides methods to customize each application life cycle stage so that it suits your specifications.

Each stage in the application life cycle is called an environment in Foreman. Each environment uses a specific collection of content. Foreman defines these content collections as a Content View. Each Content View acts as a filter where you can define what repositories, packages, and Puppet modules to include in a particular environment. This provides a method for you to define specific sets of content to designate to each environment.

For example, an email server might only require a simple application life cycle where you have a production-level server for real-world use and a test server for trying out the latest mail server packages. When the test server passes the initial phase, you can set the production-level server to use the new packages.

Another example is a development life cycle for a software product. To develop a new piece of software in a development environment, test it in a quality assurance environment, pre-release as a beta, then release the software as a production-level application.

The graphics in this section are Red Hat illustrations. Non-Red Hat illustrations are welcome. If you want to contribute alternative images, raise a pull request in the Foreman Documentation GitHub page. Note that in Red Hat terminology, "Satellite" refers to Foreman and "Capsule" refers to Smart Proxy.

The Foreman Application Life Cycle
Figure 1. The Foreman Application Life Cycle

Promoting Content across the Application Life Cycle

In the application life cycle chain, when content moves from one environment to the next, this is called promotion.

Example Content Promotion Across Foreman Life Cycle Environments

Each environment contains a set of systems registered to Foreman. These systems only have access to repositories relevant to their environment. When you promote packages from one environment to the next, the target environment’s repositories receive new package versions. As a result, each system in the target environment can update to the new package versions.

Development Testing Production

example_software-1.1-0.noarch.rpm

example_software-1.0-0.noarch.rpm

example_software-1.0-0.noarch.rpm

After completing development on the patch, you promote the RPM to the Testing environment so the Quality Engineering team can review the patch. The application life cycle then contains the following package versions in each environment:

Development Testing Production

example_software-1.1-0.noarch.rpm

example_software-1.1-0.noarch.rpm

example_software-1.0-0.noarch.rpm

While the Quality Engineering team reviews the patch, the Development team starts work on example_software 2.0. This results in the following application life cycle:

Development Testing Production

exampleware-2.0-0.noarch.rpm

exampleware-1.1-0.noarch.rpm

exampleware-1.0-0.noarch.rpm

The Quality Engineering team completes their review of the patch. Now example_software 1.1 is ready to release. You promote 1.1 to the Production environment:

Development Testing Production

example_software-2.0-0.noarch.rpm

example_software-1.1-0.noarch.rpm

example_software-1.1-0.noarch.rpm

The Development team completes their work on example_software 2.0 and promotes it to the Testing environment:

Development Testing Production

example_software-2.0-0.noarch.rpm

example_software-2.0-0.noarch.rpm

example_software-1.1-0.noarch.rpm

Finally, the Quality Engineering team reviews the package. After a successful review, promote the package to the Production environment:

Development Testing Production

exampleware-2.0-0.noarch.rpm

exampleware-2.0-0.noarch.rpm

exampleware-2.0-0.noarch.rpm

For more information, see Promoting a Content View.

Creating a Life Cycle Environment Path

To create an application life cycle for developing and releasing software, use the Library environment as the initial environment to create environment paths. Then optionally add additional environments to the environment paths.

Procedure
  1. In the Foreman web UI, navigate to Content > Lifecycle Environments.

  2. Click New Environment Path to start a new application life cycle.

  3. In the Name field, enter a name for your environment.

  4. In the Description field, enter a description for your environment.

  5. Click Save.

  6. Optional: To add an environment to the environment path, click Add New Environment, complete the Name and Description fields, and select the prior environment from the Prior Environment list.

For CLI Users
  1. To create an environment path, enter the hammer lifecycle-environment create command and specify the Library environment with the --prior option:

    # hammer lifecycle-environment create \
    --name "Environment Path Name" \
    --description "Environment Path Description" \
    --prior "Library" \
    --organization "My_Organization"
  2. Optional: To add an environment to the environment path, enter the hammer lifecycle-environment create command and specify the parent environment with the --prior option:

    # hammer lifecycle-environment create \
    --name "Environment Name" \
    --description "Environment Description" \
    --prior "Prior Environment Name" \
    --organization "My_Organization"
  3. To view the chain of the life cycle environment, enter the following command:

    # hammer lifecycle-environment paths --organization "My_Organization"

Removing Life Cycle Environments from Foreman server

Use this procedure to remove a life cycle environment.

Procedure

To remove a life cycle environment, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Life Cycle Environments.

  2. Click the name of the life cycle environment that you want to remove, and then click Remove Environment.

  3. Click Remove to remove the environment.

For CLI Users
  1. List the life cycle environments for your organization and note the name of the life cycle environment you want to remove:

    # hammer lifecycle-environment list --organization "My_Organization"
  2. Use the hammer lifecycle-environment delete command to remove an environment:

    # hammer lifecycle-environment delete \
    --name "your_environment" \
    --organization "My_Organization"

Removing Life Cycle Environments from Smart Proxy server

When life cycle environments are no longer relevant to the host system or environments are added incorrectly to Smart Proxy server, you can remove the life cycle environments from Smart Proxy server.

You can use both the Foreman web UI and the Hammer to remove life cycle environments from Smart Proxy.

Procedure

To remove a life cycle environment from Smart Proxy server, complete the following step:

  1. In the Foreman web UI, navigate to Infrastructure > Smart Proxies, and select the Smart Proxy that you want to remove a life cycle from.

  2. Click Edit and click the Life Cycle Environments tab.

  3. From the right menu, select the life cycle environments that you want to remove from Smart Proxy, and then click Submit.

  4. To synchronize Smart Proxy’s content, click the Overview tab, and then click Synchronize.

  5. Select either Optimized Sync or Complete Sync.

For CLI Users

To remove a life cycle environment from Smart Proxy server, complete the following steps:

  1. Select the Smart Proxy server that you want from the list and take note of its id:

    # hammer capsule list
  2. To verify the Smart Proxy server’s details, enter the following command:

    # hammer capsule info --id capsule_id
  3. Verify the list of life cycle environments currently attached to the Smart Proxy server and take note of the environment id:

    # hammer capsule content lifecycle-environments \
    --id capsule_id
  4. Remove the life cycle environment from Smart Proxy server:

    # hammer capsule content remove-lifecycle-environment \
    --id capsule_id \
    --lifecycle-environment-id lifecycle_environment_id

    Repeat this step for every life cycle environment that you want to remove from Smart Proxy server.

  5. Synchronize the content from Foreman server’s environment to Smart Proxy server:

    # hammer capsule content synchronize \
    --id capsule_id

Adding Life Cycle Environments to Smart Proxy servers

This procedure is only for Katello plug-in users.

If your Smart Proxy server has the content functionality enabled, you must add an environment so that Smart Proxy can synchronize content from Foreman server and provide content to host systems.

Do not assign the Library lifecycle environment to your Smart Proxy server because it triggers an automated Smart Proxy sync every time the CDN updates a repository. This might consume multiple system resources on Smart Proxies, network bandwidth between Foreman and Smart Proxies, and available disk space on Smart Proxies.

You can use Hammer CLI on Foreman server or the Foreman web UI.

Procedure

To add a life cycle environment to Smart Proxy server, complete the following steps:

  1. In the Foreman web UI, navigate to Infrastructure > Smart Proxies, and select the Smart Proxy that you want to add a life cycle to.

  2. Click Edit and click the Life Cycle Environments tab.

  3. From the left menu, select the life cycle environments that you want to add to Smart Proxy and click Submit.

  4. To synchronize the content on the Smart Proxy, click the Overview tab and click Synchronize.

  5. Select either Optimized Sync or Complete Sync.

    For definitions of each synchronization type, see Recovering a Repository.

For CLI Users
  1. To display a list of all Smart Proxy servers, on Foreman server, enter the following command:

    # hammer capsule list

    Note the Smart Proxy ID of the Smart Proxy that you want to add a life cycle to.

  2. Using the ID, verify the details of your Smart Proxy:

    # hammer capsule info --id capsule_id
  3. To view the life cycle environments available for your Smart Proxy server, enter the following command and note the ID and the organization name:

    # hammer capsule content available-lifecycle-environments --id capsule_id
  4. Add the life cycle environment to your Smart Proxy server:

    # hammer capsule content add-lifecycle-environment \
    --id capsule_id --organization "My_Organization" \
    --lifecycle-environment-id lifecycle-environment_id

    Repeat for each life cycle environment you want to add to Smart Proxy server.

  5. Synchronize the content from Foreman to Smart Proxy.

    • To synchronize all content from your Foreman server environment to Smart Proxy server, enter the following command:

      # hammer capsule content synchronize --id capsule_id
    • To synchronize a specific life cycle environment from your Foreman server to Smart Proxy server, enter the following command:

      # hammer capsule content synchronize --id external_capsule_id \
      --lifecycle-environment-id lifecycle-environment_id

Managing Content Views

Foreman uses Content Views to create customized repositories from the repositories. To do this, you must define which repositories to use and then apply certain filters to the content. These filters include both package filters, package group filters, errata filters, and module stream filters. You can use Content Views to define which software versions a particular environment uses. For example, a Production environment might use a Content View containing older package versions, while a Development environment might use a Content View containing newer package versions.

Each Content View creates a set of repositories across each environment, which Foreman server stores and manages. When you promote a Content View from one environment to the next environment in the application life cycle, the respective repository on Foreman server updates and publishes the packages.

Development Testing Production

Content View Version and Contents

Version 2 - example_software-1.1-0.noarch.rpm

Version 1 - example_software-1.0-0.noarch.rpm

Version 1 - example_software-1.0-0.noarch.rpm

The repositories for Testing and Production contain the example_software-1.0-0.noarch.rpm package. If you promote Version 2 of the Content View from Development to Testing, the repository for Testing regenerates and then contains the example_software-1.1-0.noarch.rpm package:

Development Testing Production

Content View Version and Contents

Version 2 - example_software-1.1-0.noarch.rpm

Version 2 - example_software-1.1-0.noarch.rpm

Version 1 - example_software-1.0-0.noarch.rpm

This ensures systems are designated to a specific environment but receive updates when that environment uses a new version of the Content View.

The general workflow for creating Content Views for filtering and creating snapshots is as follows:

  1. Create a Content View.

  2. Add the repository and the Puppet modules that you want to the Content View.

  3. Optionally, create one or more filters to refine the content of the Content View.

  4. Optionally, resolve any package dependencies for a Content View.

  5. Publish the Content View.

  6. Optionally, promote the Content View to another environment.

  7. Attach the content host to the Content View.

If a repository is not associated with the Content View, the file /etc/yum.repos.d/redhat.repo remains empty and systems registered to it cannot receive updates.

Hosts can only be associated with a single Content View. To associate a host with multiple Content Views, create a composite Content View. For more information, see Creating a Composite Content View.

Package Dependency Resolution

Package dependency is a complication of package management. For more information about how to manage package dependencies within Content Views, see Resolving Package Dependencies.

Creating a Content View

Use this procedure to create a simple Content View.

Prerequisites

While you can stipulate whether you want to resolve any package dependencies on a Content View by Content View basis, you might want to change the default Foreman settings to enable or disable package resolution for all Content Views. For more information, see Resolving Package Dependencies.

Procedure

To create a content view, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views and click Create New View.

  2. In the Name field, enter a name for the view. Foreman automatically completes the Label field from the name you enter.

  3. In the Description field, enter a description of the view.

  4. Optional: if you want to solve dependencies automatically every time you publish this Content View, select the Solve Dependencies check box. Dependency solving slows the publishing time and might ignore any Content View filters you use. This can also cause errors when resolving dependencies for errata.

  5. Click Save to create the Content View.

  6. In the Repository Selection area, select the repositories that you want to add to your Content View, then click Add Repositories.

  7. Click Publish New Version and in the Description field, enter information about the version to log changes.

  8. Click Save.

  9. Optional: to force metadata regeneration on Yum repositories, from the Actions list for your Content View versions, select Regenerate Repository Metadata.

You can view the Content View in the Content Views window. To view more information about the Content View, click the Content View name.

To register a host to your content view, see Registering Hosts in the Managing Hosts guide.

Creating a Content View with Hammer CLI
  1. Obtain a list of repository IDs:

    # hammer repository list --organization "My_Organization"
  2. Create the Content View and add repositories:

    # hammer content-view create \
    --name "Example_Content_View" \
    --description "Example Content View" \
    --repository-ids 1,2 \
    --organization "My_Organization"

    For the --repository-ids option, you can find the IDs in the output of the hammer repository list command.

  3. Publish the view:

    # hammer content-view publish \
    --name "Example_Content_View" \
    --description "Example Content View" \
    --organization "My_Organization"
  4. Optional: To add a repository to an existing Content View, enter the following command:

    # hammer content-view add-repository \
    --name "Example_Content_View" \
    --organization "My_Organization" \
    --repository-id repository_ID

Foreman server creates the new version of the view and publishes it to the Library environment.

Viewing Module Streams

In Foreman, you can view the module streams of the repositories in your Content Views.

Procedure

To view module streams for the repositories in your content view, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views, and select the Content View that contains the modules you want to view.

  2. Click the Versions tab and select the Content View version that you want to view.

  3. Click the Module Streams tab to view the module streams that are available for the Content View.

  4. Use the Filter field to refine the list of modules.

  5. To view the information about the module, click the module.

Creating a Content View with a Puppet Module

Use this procedure to create a Content View using one repository and no filters.

Prerequisites

Before you begin, upload the required Puppet module to a repository within a product. For more information, see Adding Puppet Modules to Foreman in the Puppet Guide.

Procedure

To create a Content View with a Puppet module, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views and click Create New View.

  2. In the Name field, enter a name for the view. Foreman automatically completes the Label field from the name you enter.

  3. In the Description field, enter a description of the view.

  4. Click Save to complete.

  5. In the Repository Selection area, select the repositories that you want to add to your Content View, then click Add Repositories.

  6. Click the Puppet Modules tab, then click Add New Module.

  7. Search for the module that you want to add and click Select a Version.

  8. Navigate to the entry for Use Latest and click Select Version in the Actions column.

  9. To publish, click the Versions tab and click Publish New Version. In the Description field, enter a description to log the changes and click Save.

To register a host to your content view, see Registering Hosts in the Managing Hosts guide.

For CLI Users

To add a Puppet module to a Content View, enter the following command:

# hammer content-view puppet-module add \
--content-view cv_name \
--name module_name

Promoting a Content View

Use this procedure to promote Content Views across different lifecycle environments.

Permission Requirements for Content View Promotion

Non-administrator users require two permissions to promote a Content View to an environment:

  1. promote_or_remove_content_views

  2. promote_or_remove_content_views_to_environment.

The promote_or_remove_content_views permission restricts which Content Views a user can promote.

The promote_or_remove_content_views_to_environment permission restricts the environments to which a user can promote Content Views.

With these permissions you can assign users permissions to promote certain Content Views to certain environments, but not to other environments. For example, you can limit a user so that they are permitted to promote to test environments, but not to production environments.

You must assign both permissions to a user to allow them to promote Content Views.

Procedure

To promote a Content View, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views and select the Content View that you want to promote.

  2. Click the Versions tab for the Content View.

  3. Select the version that you want to promote and in the Actions column, click Promote.

  4. Select the environment where you want to promote the Content View, and click Promote Version.

  5. Click the Promote button again. This time select the Testing environment and click Promote Version.

  6. Finally click on the Promote button again. Select the Production environment and click Promote Version.

Now the repository for the Content View appears in all environments.

For CLI Users
  • Promote the Content View using the hammer content-view version promote each time:

    # hammer content-view version promote \
    --content-view "Database" \
    --version 1 \
    --to-lifecycle-environment "Development" \
    --organization "My_Organization"
    # hammer content-view version promote \
    --content-view "Database" \
    --version 1 \
    --to-lifecycle-environment "Testing" \
    --organization "My_Organization"
    # hammer content-view version promote \
    --content-view "Database" \
    --version 1 \
    --to-lifecycle-environment "Production" \
    --organization "My_Organization"

    Now the database content is available in all environments.

To register a host to your content view, see Registering Hosts in the Managing Hosts guide.

Promoting a Content View Across All Life Cycle Environments within an Organization

Use this procedure to promote Content Views across all lifecycle environments within an organization.

Procedure

To promote a Content Views version across all lifecycle environments within an organization, complete the following steps:

  1. To promote a selected Content View version from Library across all life cycle environments within an organization, run the following Bash script:

    ORG="Your_Organization"
    CVV_ID=3
    
    for i in $(hammer --no-headers --csv lifecycle-environment list --organization $ORG | awk -F, {'print $1'} | sort -n)
    do
       hammer content-view version promote --organization $ORG --to-lifecycle-environment-id $i --id $CVV_ID
    done
  2. Display information about your Content View version to verify that it is promoted to the required lifecycle environments:

    # hammer content-view version info --id 3

Composite Content Views Overview

A Composite Content View combines the content from several Content Views. For example, you might have separate Content Views to manage an operating system and an application individually. You can use a Composite Content View to merge the contents of both Content Views into a new repository. The repositories for the original Content Views still exist but a new repository also exists for the combined content.

If you want to develop an application that supports different database servers. The example_application appears as:

example_software

Application

Database

Operating System

Example of four separate Content Views:

  • Red Hat Enterprise Linux (Operating System)

  • PostgreSQL (Database)

  • MariaDB (Database)

  • example_software (Application)

From the previous Content Views, you can create two Composite Content Views.

Example Composite Content View for a PostgreSQL database:

Composite Content View 1 - example_software on PostgreSQL

example_software (Application)

PostgreSQL (Database)

Red Hat Enterprise Linux (Operating System)

Example Composite Content View for a MariaDB:

Composite Content View 2 - example_software on MariaDB

example_software (Application)

MariaDB (Database)

Red Hat Enterprise Linux (Operating System)

Each Content View is then managed and published separately. When you create a version of the application, you publish a new version of the Composite Content Views. You can also select the Auto Publish option when creating a Composite Content View, and then the Composite Content View is automatically republished when a Content View it includes is republished.

Repository Restrictions

You cannot include more than one of each repository in Composite Content Views. For example, if you attempt to include two Content Views using the same repository in a Composite Content View, Foreman server reports an error.

Creating a Composite Content View

Procedure

To create a Composite Content View, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views and click Create New View.

  2. In the Name field, enter a name for the view. Foreman automatically completes the Label field from the name you enter.

  3. In the Description field, enter a description of the view.

  4. Select the Composite View? check box to create a Composite Content View.

  5. Optional: select the Auto Publish check box if you want the Composite Content View to be republished automatically when a Content View is republished.

  6. Click Save.

  7. In the Add Content Views area, select the Content Views that you want to add to the Composite Content View, and then click Add Content Views.

  8. Click Publish New Version to publish the Composite Content View. In the Description field, enter a description and click Save.

  9. Click Promote and select the lifecycle environments to promote the Composite Content View to, enter a description, and then click Promote Version.

For CLI Users
  1. Before you create the Composite Content Views, list the version IDs for your existing Content Views:

    # hammer content-view version list \
    --organization "My_Organization"
  2. Create a new Composite Content View. When the --auto-publish option is set to yes, the Composite Content View is automatically republished when a Content View it includes is republished:

    # hammer content-view create \
    --composite \
    --auto-publish yes \
    --name "Example_Composite_Content_View" \
    --description "Example Composite Content View" \
    --organization "My_Organization"
  3. Add a component Content View to the Composite Content View. You must include the Content View Version ID and use the --latest option. To include multiple component Content Views to the Composite Content View, repeat this step for every Content View you want to include:

    # hammer content-view component add \
    --component-content-view-id Content_View_Version_ID \
    --latest \
    --composite-content-view "Example_Composite_Content_View"
  4. Publish the Composite Content View:

    # hammer content-view publish \
    --name "Example_Composite_Content_View" \
    --description "Initial version of Composite Content View" \
    --organization "My_Organization"
  5. Promote the Composite Content View across all environments:

    # hammer content-view version promote \
    --content-view "Example_Composite_Content_View" \
    --version 1 \
    --to-lifecycle-environment "Development" \
    --organization "My_Organization"
    # hammer content-view version promote \
    --content-view "Example_Composite_Content_View" \
    --version 1 \
    --to-lifecycle-environment "Testing" \
    --organization "My_Organization"
    # hammer content-view version promote \
    --content-view "Example_Composite_Content_View" \
    --version 1 \
    --to-lifecycle-environment "Production" \
    --organization "My_Organization"

Content Filter Overview

Content Views also use filters to include or restrict certain RPM content. Without these filters, a Content View includes everything from the selected repositories.

There are two types of content filters:

Table 1. Filter Types
Filter Type Description

Include

You start with no content, then select which content to add from the selected repositories. Use this filter to combine multiple content items.

Exclude

You start with all content from selected repositories, then select which content to remove. Use this filter when you want to use most of a particular content repository but exclude certain packages, such as blacklisted packages. The filter uses all content in the repository except for the content you select.

Include and Exclude Filter Combinations

If using a combination of Include and Exclude filters, publishing a Content View triggers the include filters first, then the exclude filters. In this situation, select which content to include, then which content to exclude from the inclusive subset.

Content Types

There are also five types of content to filter:

Table 2. Content Types
Content Type Description

Package

Filter packages based on their name and version number. The Package option filters non-modular RPM packages and errata.

Package Group

Filter packages based on package groups. The list of package groups is based on the repositories added to the Content View.

Erratum (by ID)

Select which specific errata to add to the filter. The list of Errata is based on the repositories added to the Content View.

Erratum (by Date and Type)

Select a issued or updated date range and errata type (Bugfix, Enhancement, or Security) to add to the filter.

Module Streams

Select whether to include or exclude specific module streams. The Module Streams option filters modular RPMs and errata, but does not filter non-modular content that is associated with the selected module stream.

Resolving Package Dependencies

In Foreman, you can use the package dependency resolution feature to ensure that any dependencies that packages have within a Content View are added to the dependent repository as part of the Content View publication process.

You can select to resolve package dependencies for any Content View that you want, or you can change the default setting to enable or disable resolving package dependencies for all new Content Views.

Note that resolving package dependencies can cause significant delays to Content View promotion. The package dependency resolution feature does not consider packages that are installed on your system independently of the Content View or solve dependencies across repositories.

Resolving Package Dependencies and Filters

Filters do not resolve any dependencies of the packages listed in the filters. This might require some level of testing to determine what dependencies are required.

If you add a filter that excludes some packages that are required and the Content View has dependency resolution enabled, Foreman ignores the rules you create in your filter in favor of resolving the package dependency.

If you create a content filter for security purposes, to resolve a package dependency, Foreman can add packages that you might consider insecure.

Procedure

To resolve package dependencies by default, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Settings and click the Content tab.

  2. Locate the Content View Dependency Solving Default, and select Yes.

You can also set the default level of dependency resolution that you want. You can select between adding packages to solve dependencies only if the required package does not exist, or to add the latest packages to resolve the dependency even if the package exists in the repository.

To set the default level of dependency resolution, complete the following steps:

  1. In the Foreman web UI, navigate to Administer > Settings and click the Content tab.

  2. Locate the Content View Dependency Solving Algorithm and select one of the following options:

    • To add the package that resolves the dependency only if it does not exist in the repository, select Conservative.

    • To add the package that resolves the dependency regardless of whether or not it exists in the repository, select Greedy.

Content Filter Examples

Use any of the following examples with the procedure that follows to build custom content filters.

Example 1

Create a repository with the base Red Hat Enterprise Linux packages. This filter requires a Red Hat Enterprise Linux repository added to the Content View.

Filter:

  • Inclusion Type: Include

  • Content Type: Package Group

  • Filter: Select only the Base package group

Example 2

Create a repository that excludes all errata, except for security updates, after a certain date. This is useful if you want to perform system updates on a regular basis with the exception of critical security updates, which must be applied immediately. This filter requires a Red Hat Enterprise Linux repository added to the Content View.

Filter:

  • Inclusion Type: Exclude

  • Content Type: Erratum (by Date and Type)

  • Filter: Select only the Bugfix and Enhancement errata types, and clear the Security errata type. Set the Date Type to Updated On. Set the Start Date to the date you want to restrict errata. Leave the End Date blank to ensure any new non-security errata is filtered.

Example 3

A combination of Example 1 and Example 2 where you only require the operating system packages and want to exclude recent bug fix and enhancement errata. This requires two filters attached to the same Content View. The Content View processes the Include filter first, then the Exclude filter.

Filter 1:

  • Inclusion Type: Include

  • Content Type: Package Group

  • Filter: Select only the Base package group

Filter 2:

  • Inclusion Type: Exclude

  • Content Type: Erratum (by Date and Type)

  • Filter: Select only the Bugfix and Enhancement errata types, and clear the Security errata type. Set the Date Type to Updated On. Set the Start Date to the date you want to restrict errata. Leave the End Date blank to ensure any new non-security errata is filtered.

Example 4

Filter a specific module stream in a Content View.

Filter 1:

  • Inclusion Type: Include

  • Content Type: Module Stream

  • Filter: Select only the specific module stream that you want for the Content View, for example ant, and click Add Module Stream.

Filter 2:

  • Inclusion Type: Exclude

  • Content Type: Package

  • Filter: Add a rule to filter any non-modular packages that you want to exclude from the Content View. If you do not filter the packages, the Content View filter includes all non-modular packages associated with the module stream ant. Add a rule to exclude all * packages, or specify the package names that you want to exclude.

For another example of how content filters work, see the following article: "How do content filters work in Satellite 6"

Creating a Content Filter

Use this procedure to create a content filter. For examples of how to build a filter, see Content Filter Examples

Procedure

To create a content filter, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views and select a Content View.

  2. Navigate to Yum Content > Filters and click New Filter.

  3. In the Name field, enter a name for your filter.

  4. From the Content Type list, select the content type that you want to filter. Depending on what you select for the new filter’s content type, different options appear.

  5. From the Inclusion Type list, select either Include or Exclude.

  6. In the Description field, enter a description for the filter, and click Save.

  7. Depending on what you enter for Content Type, add rules to create the filter that you want.

  8. Click the Affected repositories tab to select which specific repositories use this filter.

  9. Click Publish New Version to publish the filtered repository. In the Description field, enter a description of the changes, and click Save.

You can promote this Content View across all environments.

For CLI Users
  1. Add a filter to the Content View. Use the --inclusion false option to set the filter to an Exclude filter:

    # hammer content-view filter create \
    --name "Errata Filter" \
    --type erratum --content-view "Example_Content_View" \
    --description "My latest filter" \
    --inclusion false \
    --organization "My_Organization"
  2. Add a rule to the filter:

    # hammer content-view filter rule create \
    --content-view "Example_Content_View" \
    --content-view-filter "Errata Filter" \
    --start-date "YYYY-MM-DD" \
    --types enhancement,bugfix \
    --date-type updated \
    --organization "My_Organization"
  3. Publish the Content View:

    # hammer content-view publish \
    --name "Example_Content_View" \
    --description "Adding errata filter" \
    --organization "My_Organization"
  4. Promote the view across all environments:

    # hammer content-view version promote \
    --content-view "Example_Content_View" \
    --version 1 \
    --to-lifecycle-environment "Development" \
    --organization "My_Organization"
    # hammer content-view version promote \
    --content-view "Example_Content_View" \
    --version 1 \
    --to-lifecycle-environment "Testing" \
    --organization "My_Organization"
    # hammer content-view version promote \
    --content-view "Example_Content_View" \
    --version 1 \
    --to-lifecycle-environment "Production" \
    --organization "My_Organization"

Synchronizing Content Between Foreman servers

Foreman 6.7 uses Inter-Foreman Synchronization (ISS) to synchronize content Foreman servers, or between organizations on Foreman server.

You can use ISS in the following scenarios:

  • If you want to copy some but not all content from your Foreman server to other Foreman servers. For example, you have Content Views that your IT department validates on Foreman server, and you want to copy content from those Content Views to other Foreman servers.

  • If you want to clone a Content View from one organization to another organization on Foreman server.

You cannot use ISS to synchronize content from Foreman server to Smart Proxy server. Smart Proxy server supports synchronization natively. For more information, see Smart Proxy server Overview in Planning for Foreman.

Exporting a Content View Version

You can export a version of a Content View to an archive file from Foreman server and use this archive file to create the same Content View version on another Foreman server or on another Foreman server organization. Foreman does not export composite Content Views. The exported archive file contains the following data:

  • A JSON file containing Content View version metadata

  • An archive file containing all the repositories included into the Content View version

Foreman server exports only RPM and kickstart files added to a version of a Content View. Foreman does not export the following content:

  • Puppet content

  • Docker content

  • OSTree content

  • Content View definitions and metadata, such as package filters.

Changes to the hammer content-view version export command

The new hammer content-view version export and hammer content-view version import commands work differently from the commands in the previous versions of Foreman. The old feature is still available with the hammer content-view version export-legacy command. The old feature has the following functionality that does not exist in the new feature:

  • When exporting a Content View that contains non-yum content, hammer content-view version export-legacy skips the non-yum content and exports the Content View, while hammer content-view version export prompts you to remove a non-yum repository and fails.

Prerequisites

To export a Content View, ensure that the Foreman server where you want to export meets the following conditions:

  • Ensure that the export directory has free storage space to accommodate the export.

  • Ensure that the /var/lib/pulp/ directory has free storage space equivalent to the size of the repositories being exported for temporary files created during the export process.

  • Ensure that the /var/cache/pulp directory has free storage space equivalent to twice of the size of the repository being exported for temporary files created during the export process.

  • Ensure that you set download policy to Immediate for all repositories within the Content View you export. For more information, see Download Policies Overview.

  • Ensure that you clear the Mirror on Sync check box for the repositories that you import on the repository settings page.

  • Ensure that you synchronize Products that you export to the required date.

To Export a Content View Version:
  1. List Content Views to determine the ID of a Content View version you want to export:

    # hammer content-view version list \
    --organization "Default Organization"
  2. Export the version of a Content View. Specify the directory where to store the export with the --export-dir option and the ID of the Content View version that you export with the --id option. The pulp_export_destination setting does not work for this procedure.

    # hammer content-view version export --export-dir export_directory \
    --id content_view_version_ID
  3. Verify that the archive containing the exported version of a Content View is located in the export directory:

    # ls export_directory
    export-1.tar

Importing a Content View Version

You can use the archive that the hammer content-view version export command outputs to create a version of a Content View with the same content as the exported Content View version. For more information about exporting a Content View version, see Exporting a Content View Version.

When you import a Content View version, it has the same major and minor version numbers and contains the same repositories with the same packages and errata. You can customize the version numbers by changing the major and minor settings in the json file that is located in the exported archive.

Prerequisites

To import a Content View, ensure that the Foreman server where you want to import meets the following conditions:

  • Ensure that you set download policy to Immediate for all repositories within the Content View you export. For more information, see Download Policies Overview.

  • Ensure that you clear the Mirror on Sync check box for the repositories that you import on the repository settings page.

Procedure
  1. Copy the archived file with the exported Content View version to the /var/lib/pulp/katello-export directory on the Foreman server where you want to import.

  2. On the Foreman server where you want to import, create a Content View with the same name and label as the exported Content View. For more information, see Creating a Content View with Hammer CLI.

  3. Ensure that you enable the repositories that the Products in the exported Content View version include. For more information, see Enabling Red Hat Repositories.

  4. In the Foreman web UI, navigate to Content > Products, click the Yum content tab and add the same Yum content that the exported Content View version includes.

  5. Until BZ#1745081 is resolved, navigate to the /var/lib/pulp/katello-export directory:

    # cd /var/lib/pulp/katello-export
  6. To import the Content View version to Foreman server, enter the following command:

    # hammer content-view version import \
    --export-tar /var/lib/pulp/katello-export/exported_CV_archive.tar \
    --organization-id Your_Organization_ID

    Note that until BZ#1745081 is resolved, you must enter the full path /var/lib/pulp/katello-export/. Relative paths do not work.

  7. To verify that you import the Content View version successfully, list Content Views for your organization:

    # hammer content-view version list --organization "Your_Organization"

Managing Activation Keys

Activation keys provide a method to automate system registration and subscription attachment. You can create multiple keys and associate them with different environments and Content Views. For example, you might create a basic activation key with a subscription for Red Hat Enterprise Linux workstations and associate it with Content Views from a particular environment.

You can use activation keys during content host registration to improve the speed, simplicity and consistency of the process. Note that activation keys are used only when hosts are registered. If changes are made to an activation key, it is applicable only to hosts that are registered with the amended activation key in the future. The changes are not made to existing hosts.

Activation keys can define the following properties for content hosts:

  • Associated subscriptions and subscription attachment behavior

  • Available products and repositories

  • A life cycle environment and a Content View

  • Host collection membership

  • System purpose

Content View Conflicts between Host Creation and Registration

When you provision a host, Foreman uses provisioning templates and other content from the Content View that you set in the host group or host settings. When the host is registered, the Content View from the activation key overwrites the original Content View from the host group or host settings. Then Foreman uses the Content View from the activation key for every future task, for example, rebuilding a host.

When you rebuild a host, ensure that you set the Content View that you want to use in the activation key and not in the host group or host settings.

Using the Same Activation Key with Multiple Content Hosts

You can apply the same activation key to multiple content hosts if it contains enough subscriptions. However, activation keys set only the initial configuration for a content host. When the content host is registered to an organization, the organization’s content can be attached to the content host manually.

Using Multiple Activation Keys with a Content Host

A content host can be associated with multiple activation keys that are combined to define the host settings. In case of conflicting settings, the last specified activation key takes precedence. You can specify the order of precedence by setting a host group parameter as follows:

$ hammer hostgroup set-parameter \
--name kt_activation_keys \
--value name_of_first_key, name_of_second_key,... \
--hostgroup hostgroup_name

Creating an Activation Key

You can use activation keys to define a specific set of subscriptions to attach to hosts during registration. The subscriptions that you add to an activation key must be available within the associated Content View.

Subscription Manager attaches subscriptions differently depending on the following factors:

  • Are there any subscriptions associated with the activation key?

  • Is the auto-attach option enabled?

  • For Red Hat Enterprise Linux 8 hosts: Is there system purpose set on the activation key?

Note that Foreman automatically attaches subscriptions only for the products installed on a host. For subscriptions that do not list products installed on Red Hat Enterprise Linux by default, such as the Extended Update Support (EUS) subscription, use an activation key specifying the required subscriptions and with the auto-attach disabled.

Based on the previous factors, there are three possible scenarios for subscribing with activation keys:

  1. Activation key that attaches subscriptions automatically.

    With no subscriptions specified and auto-attach enabled, hosts using the activation key search for the best fitting subscription from the ones provided by the Content View associated with the activation key. This is similar to entering the subscription-manager --auto-attach command. For Red Hat Enterprise Linux 8 hosts, you can configure the activation key to set system purpose on hosts during registration to enhance the automatic subscriptions attachment.

  2. Activation key providing a custom set of subscription for auto-attach.

    If there are subscriptions specified and auto-attach is enabled, hosts using the activation key select the best fitting subscription from the list specified in the activation key. Setting system purpose on the activation key does not affect this scenario.

  3. Activation key with the exact set of subscriptions.

    If there are subscriptions specified and auto-attach is disabled, hosts using the activation key are associated with all subscriptions specified in the activation key. Setting system purpose on the activation key does not affect this scenario.

Products

If a product, typically containing content not provided by Red Hat, is assigned to an activation key, this product is always enabled for the registered content host regardless of the auto-attach setting.

Procedure

To create an activation key, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Activation keys and click Create Activation Key.

  2. In the Name field, enter the name of the activation key.

  3. If you want to set a limit, clear the Unlimited hosts check box, and in the Limit field, enter the maximum number of systems you can register with the activation key. If you want unlimited hosts to register with the activation key, ensure the Unlimited Hosts check box is selected.

  4. In the Description field, enter a description for the activation key.

  5. From the Environment list, select the environment to use.

  6. From the Content View list, select a Content View to use. If you want to use this activation key to register hosts, the Content View must contain the https://yum.theforeman.org/client/2.0/ repository because it is required to install the katello-agent.

  7. Click Save.

  8. Optional: For Red Hat Enterprise Linux 8 hosts, in the System Purpose section, you can configure the activation key with system purpose to set on hosts during registration to enhance subscriptions auto attachment.

For CLI Users
  1. Create the activation key:

    # hammer activation-key create \
    --name "My_Activation_Key" \
    --unlimited-hosts \
    --description "Example Stack in the Development Environment" \
    --lifecycle-environment "Development" \
    --content-view "Stack" \
    --organization "My_Organization"
  2. Optional: For Red Hat Enterprise Linux 8 hosts, enter the following command to configure the activation key with system purpose to set on hosts during registration to enhance subscriptions auto attachment.

    # hammer activation-key update \
    --organization "My_Organization" \
    --name "My_Activation_Key" \
    --service-level "Standard" \
    --purpose-usage "Development/Test" \
    --purpose-role "Red Hat Enterprise Linux Server" \
    --purpose-addons "addons"
  3. Obtain a list of your subscription IDs:

    # hammer subscription list --organization "My_Organization"
  4. Attach the Red Hat Enterprise Linux subscription UUID to the activation key:

    # hammer activation-key add-subscription \
    --name "My_Activation_Key" \
    --subscription-id ff808181533518d50152354246e901aa \
    --organization "My_Organization"
  5. List the product content associated with the activation key:

    # hammer activation-key product-content \
    --name "My_Activation_Key" \
    --organization "My_Organization"
  6. Override the default auto-enable status for the https://yum.theforeman.org/client/2.0/ repository. The default status is set to disabled. To enable, enter the following command:

    # hammer activation-key content-override \
    --name "My_Activation_Key" \
    --content-label https://yum.theforeman.org/client/2.0/el7/x86_64/foreman-client-release.rpm \
    --value 1 \
    --organization "My_Organization"

Updating Subscriptions Associated with an Activation Key

You can change the subscriptions associated with an activation key using the web UI or using the Hammer command-line tool.

Note that changes to an activation key apply only to machines provisioned after the change. To update subscriptions on existing content hosts, see Bulk Updating Content Hosts' Subscriptions.

Procedure

To update the subscriptions associated with an activation key, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Activation keys and click the name of the activation key.

  2. Click the Subscriptions tab.

  3. To remove subscriptions, select List/Remove, and then select the check boxes to the left of the subscriptions to be removed and then click Remove Selected.

  4. To add subscriptions, select Add, and then select the check boxes to the left of the subscriptions to be added and then click Add Selected.

  5. Click the Repository Sets tab and review the repositories' status settings.

  6. To enable or disable a repository, select the check box for a repository and then change the status using the Select Action list.

  7. Click the Details tab, select a Content View for this activation key, and then click Save.

For CLI Users
  1. List the subscriptions that the activation key currently contains:

    # hammer activation-key subscriptions \
    --name My_Activation_Key \
    --organization "My_Organization"
  2. Remove the required subscription from the activation key:

    # hammer activation-key remove-subscription \
    --name "My_Activation_Key" \
    --subscription-id ff808181533518d50152354246e901aa \
    --organization "My_Organization"

    For the --subscription-id option, you can use either the UUID or the ID of the subscription.

  3. Attach new subscription to the activation key:

    # hammer activation-key add-subscription \
    --name "My_Activation_Key" \
    --subscription-id ff808181533518d50152354246e901aa \
    --organization "My_Organization"

    For the --subscription-id option, you can use either the UUID or the ID of the subscription.

  4. List the product content associated with the activation key:

    # hammer activation-key product-content \
    --name "My_Activation_Key" \
    --organization "My_Organization"
  5. Override the default auto-enable status for the required repository:

    # hammer activation-key content-override \
    --name "My_Activation_Key" \
    --content-label content_label \
    --value 1 \
    --organization "My_Organization"

    For the --value option, enter 1 for enable, 0 for disable.

Using Activation Keys for Host Registration

You can use activation keys to complete the following tasks:

  • Registering new hosts during provisioning through Foreman. The kickstart provisioning templates in Foreman contain commands to register the host using an activation key that is defined when creating a host.

  • Registering existing Red Hat Enterprise Linux hosts. Configure Red Hat Subscription Manager to use Foreman server for registration and specify the activation key when running the subscription-manager register command.

Procedure

To use an activation key for host registration with an existing Red Hat Enterprise Linux 7 host to Foreman server, complete the following steps:

  1. Download the consumer RPM for your Foreman server. This is located in the pub directory on the host’s web server. For example, for a Foreman server with the host name foreman.example.com, enter the following command on the host to register:

    # rpm -Uvh http://foreman.example.com/pub/katello-ca-consumer-latest.noarch.rpm

    This RPM installs the necessary certificates for accessing repositories on Foreman server and configures Red Hat Subscription Manager to use the server’s URL.

  2. On the host, enter the following command to register the host to Foreman using the activation key:

    # subscription-manager register --activationkey="My_Activation_Key" \
    --org="My_Organization"
  3. To view a list of hosts for an organization, on Foreman server, enter the following command:

    # hammer host list --organization "My_Organization"
  4. After registering a host to Foreman server, install the katello-agent package on the host so that it can report back to Foreman server:

    # yum install katello-agent

    The https://yum.theforeman.org/client/2.0/ repository provides this package.

Multiple Activation Keys

You can use multiple activation keys when registering a content host. You can then create activation keys for specific subscription sets and combine them according to content host requirements. For example, the following command registers a content host to your organization with both VDC and OpenShift subscriptions:

# subscription-manager register --org="My_Organization" \
--activationkey="ak-VDC,ak-OpenShift"
Settings Conflicts

If there are conflicting settings in activation keys, the rightmost key takes precedence.

  • Settings that conflict: Service Level, Release Version, Environment, Content View, and Product Content.

  • Settings that do not conflict and the host gets the union of them: Subscriptions and Host Collections.

  • Settings that influence the behavior of the key itself and not the host configuration: Content Host Limit and Auto-Attach.

Enabling Auto-Attach

When auto-attach is enabled on an activation key and there are subscriptions associated with the key, the subscription management service selects and attaches the best-matched associated subscriptions based on a set of criteria like currently installed products, architecture, and preferences like service level.

You can enable auto-attach and have no subscriptions associated with the key. This type of key is commonly used to register virtual machines when you do not want the virtual machine to consume a physical subscription, but to inherit a host-based subscription from the hypervisor. For more information, see Configuring Virtual Machine Subscriptions in Foreman.

Auto-attach is enabled by default. Disable the option if you want to force attach all subscriptions associated with the activation key.

Procedure

To enable auto-attach, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Activation Keys.

  2. Click the activation key name that you want to edit.

  3. Click the Subscriptions tab.

  4. Click the edit icon next to Auto-Attach.

  5. Select or clear the check box to enable or disable auto-attach.

  6. Click Save.

For CLI Users

To enable auto-attach on the activation key:

# hammer activation-key update --name "My_Activation_Key" \
--organization "My_Organization" --auto-attach true

Setting the Service Level

You can configure an activation key to define a default service level for the new host created with the activation key. Setting a default service level selects only the matching subscriptions to be attached to the host. For example, if the default service level on an activation key is set to Premium, only subscriptions with premium service levels are attached to the host upon registration.

Procedure

To set the service level, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Activation Keys.

  2. Click the activation key name you want to edit.

  3. Click the edit icon next to Service Level.

  4. Select the required service level from the list. The list only contains service levels available to the activation key.

  5. Click Save.

For CLI Users

To set a default service level to Premium on the activation key:

# hammer activation-key update --name "My_Activation_Key" \
--organization "My_Organization" --service-level premium

Managing Errata

As a part of Red Hat’s quality control and release process, we provide customers with updates for each release of official Red Hat RPMs. Red Hat compiles groups of related package into an erratum along with an advisory that provides a description of the update. There are three types of advisories (in order of importance):

Security Advisory

Describes fixed security issues found in the package. The security impact of the issue can be Low, Moderate, Important, or Critical.

Bug Fix Advisory

Describes bug fixes for the package.

Product Enhancement Advisory

Describes enhancements and new features added to the package.

Foreman imports this errata information when synchronizing repositories with Red Hat’s Content Delivery Network (CDN). Foreman also provides tools to inspect and filter errata, allowing for precise update management. This way, you can select relevant updates and propagate them through Content Views to selected content hosts.

Errata are labeled according to the most important advisory type they contain. Therefore, errata labeled as Product Enhancement Advisory can contain only enhancement updates, while Bug Fix Advisory errata can contain both bug fixes and enhancements, and Security Advisory can contain all three types.

In Foreman, there are two keywords that describe an erratum’s relationship to the available content hosts:

Applicable

An erratum that applies to one or more content hosts, which means it updates packages present on the content host. Although these errata apply to content hosts, until their state changes to Installable, the errata are not ready to be installed. Installable errata are automatically applicable.

Installable

An erratum that applies to one or more content hosts and is available to install on the content host. Installable errata are available to a content host from life cycle environment and the associated Content View, but are not yet installed.

This chapter shows how to manage errata and apply them to either a single host or multiple hosts.

Inspecting Available Errata

The following procedure describes how to view and filter the available errata and how to display metadata of the selected advisory.

  1. Navigate to Content > Errata to view the list of available errata.

  2. Use the filtering tools at the top of the page to limit the number of displayed errata:

    • Select the repository to be inspected from the list. All Repositories is selected by default.

    • The Applicable check box is selected by default to view only errata applicable to the selected repository. Select the Installable check box to view only errata marked as installable.

    • To search the table of errata, type the query in the Search field in the form of:

      parameter operator value

      See Parameters Available for Errata Search for the list of parameters available for search. Find the list of applicable operators in Supported Operators for Granular Search in Administering Foreman. Automatic suggestion works as you type. You can also combine queries with the use of and and or operators. For example, to display only security advisories related to the kernel package, type:

      type = security and package_name = kernel

      Press Enter to start the search.

  3. Click the Errata ID of the erratum you want to inspect:

    • The Details tab contains the description of the updated package as well as documentation of important fixes and enhancements provided by the update.

    • On the Content Hosts tab, you can apply the erratum to selected content hosts as described in Applying Errata to Multiple Hosts.

    • The Repositories tab lists repositories that already contain the erratum. You can filter repositories by the environment and Content View, and search for them by the repository name.

For CLI Users
  • To view errata that are available for all organizations, enter the following command:

    # hammer erratum list
  • To view details of a specific erratum, enter the following command:

    # hammer erratum info --id erratum_ID
  • You can search errata by entering the query with the --search option. For example, to view applicable errata for the selected product that contains the specified bugs ordered so that the security errata are displayed on top, enter the following command:

    # hammer erratum list \
    --product-id 7 \
    --search "bug = 1213000 or bug = 1207972" \
    --errata-restrict-applicable 1 \
    --order "type desc"

Subscribing to Errata Notifications

You can configure email notifications for Foreman users. Users receive a summary of applicable and installable errata, notifications on Content View promotion or after synchronizing a repository. For more information, see the Configuring Email Notifications section in the Administering Foreman guide.

Limitations to Repository Dependency Resolution

There are a number of challenges to solving repository dependencies in Foreman. This is a known issue. For more information, see BZ#1508169, BZ#1640420, BZ#1508169, and BZ#1629462. With Foreman, using incremental updates to your Content Views solves some repository dependency problems. However, dependency resolution at a repository level still remains problematic on occasion.

When a repository update becomes available with a new dependency, Foreman retrieves the newest version of the package to solve the dependency, even if there are older versions available in the existing repository package. This can create further dependency resolution problems when installing packages.

Example scenario

A repository on your client has the package example_repository-1.0 with the dependency example_repository-libs-1.0. The repository also has another package example_tools-1.0.

A security erratum becomes available with the package example_tools-1.1. The example_tools-1.1 package requires the example_repository-libs-1.1 package as a dependency.

After an incremental Content View update, the example_tools-1.1, example_tools-1.0, and example_repository-libs-1.1 are now in the repository. The repository also has the packages example_repository-1.0 and example_repository-libs-1.0. Note that the incremental update to the Content View did not add the package example_repository-1.1. Because you can install all these packages using yum, no potential problem is detected. However, when the client installs the example_tools-1.1 package, a dependency resolution problem occurs because both example_repository-libs-1.0 and example_repository-libs-1.1 cannot be installed.

There is currently no workaround for this problem. The larger the time frame, and major Y releases between the base set of RPMs and the errata being applied, the higher the chance of a problem with dependency resolution.

Creating a Content View Filter for Errata

You can use content filters to limit errata. Such filters include:

  • ID - Select specific erratum to allow into your resulting repositories.

  • Date Range - Define a date range and include a set of errata released during that date range.

  • Type - Select the type of errata to include such as bug fixes, enhancements, and security updates.

Create a content filter to exclude errata after a certain date. This ensures your production systems in the application life cycle are kept up to date to a certain point. Then you can modify the filter’s start date to introduce new errata into your testing environment to test the compatibility of new packages into your application life cycle.

Prerequisites
  • A Content View with the repositories that contain required errata is created. For more information, see Creating a Content View.

Procedure
  1. In the Foreman web UI, navigate to Content > Content Views and select a Content View that you want to use for applying errata.

  2. Navigate to Yum Content > Filters and click New Filter.

  3. In the Name field, enter Errata Filter.

  4. From the Content Type list, select Erratum - Date and Type.

  5. From the Inclusion Type list, select Exclude.

  6. In the Description field, enter Exclude errata items from YYYY-MM-DD.

  7. Click Save.

  8. For Errata Type, select the check boxes of errata types you want to exclude. For example, select the Enhancement and Bugfix check boxes and clear the Security check box to exclude enhancement and bugfix errata after certain date, but include all the security errata.

  9. For Date Type, select one of two check boxes:

    • Issued On for the issued date of the erratum.

    • Updated On for the date of the erratum’s last update.

  10. Select the Start Date to exclude all errata on or after the selected date.

  11. Leave the End Date field blank.

  12. Click Save.

  13. Click Publish New Version to publish the resulting repository.

  14. Enter Adding errata filter in the Description field.

  15. Click Save.

    When the Content View completes publication, notice the Content column reports a reduced number of packages and errata from the initial repository. This means the filter successfully excluded the all non-security errata from the last year.

  16. Click the Versions tab.

  17. Click Promote to the right of the published version.

  18. Select the environments you want to promote the Content View version to.

  19. In the Description field, enter the description for promoting.

  20. Click Promote Version to promote this Content View version across the required environments.

For CLI Users
  1. Create a filter for the errata:

    # hammer content-view filter create --name "Filter Name" \
    --description "Exclude errata items from the YYYY-MM-DD" \
    --content-view "CV Name" --organization "Default Organization" \
    --type "erratum"
  2. Create a filter rule to exclude all errata on or after the Start Date that you want to set:

    # hammer content-view filter rule create --start-date "YYYY-MM-DD" \
    --content-view "CV Name" --content-view-filter="Filter Name" \
    --organization "Default Organization" --types=security,enhancement,bugfix
  3. Publish the Content View:

    # hammer content-view publish --name "CV Name" \
    --organization "Default Organization"
  4. Promote the Content View to the lifecycle environment so that the included errata are available to that lifecycle environment:

    # hammer content-view version promote \
    --content-view "CV Name" \
    --organization "Default Organization" \
    --to-lifecycle-environment "Lifecycle Environment Name"

Adding Errata to an incremental Content View

If errata are available but not installable, you can create an incremental Content View version to add the errata to your content hosts. For example, if the Content View is version 1.0, it becomes Content View version 1.1, and when you publish, it becomes Content View version 2.0.

  1. In the Foreman web UI, navigate to Content > Errata.

  2. From the Errata list, click the name of the errata that you want to apply.

  3. Select the content hosts that you want to apply the errata to, and click Apply to Hosts. This creates the incremental update to the Content View.

  4. If you want to apply the errata to the content host, select the Apply Errata to Content Hosts immediately after publishing check box.

    Note

    Until BZ#1459807 is resolved, if you apply non-installable errata to hosts registered to Smart Proxy servers, do not select the Apply errata to Content Hosts immediately after publishing check box.

    Instead, after clicking Confirm, wait for the errata Content View to be promoted and for the Smart Proxy synchronization task to finish. Then, the errata will be marked as Installable and you can use the procedure again to apply it.

  5. Click Confirm to apply the errata.

For CLI Users
  1. List the errata and its corresponding IDs:

    # hammer erratum list
  2. List the different content-view versions and the corresponding IDs:

    # hammer content-view version list
  3. Apply a single erratum to content-view version. You can add more IDs in a comma-separated list.

    # hammer content-view version incremental-update \
    --content-view-version-id 319 --errata-ids 34068b

Applying Errata to a Host

Use these procedures to review and apply errata to a host.

Prerequisites
  • Synchronize Foreman repositories with the latest errata available from Red Hat. For more information, see Synchronizing Red Hat Repositories.

  • Register the host to an environment and Content View on Foreman server. For more information, see Registering Hosts in the Managing Hosts guide.

  • For RHEL 7 hosts, ensure that you install the katello-agent package. For more information, see Installing the Katello Agent in the Managing Hosts guide.

    Note that the Katello agent is deprecated and will be removed in a future Foreman version. Migrate your workloads to use the remote execution feature to update clients remotely. For more information, see Host Management Without Goferd and Katello Agent in the Managing Hosts Guide.

For Red Hat Enterprise Linux 8

To apply an erratum to a RHEL 8 host, you can run a remote execution job on Foreman server or update the host. For more information about running remote execution jobs, see Running Jobs on Hosts in the Managing Hosts guide.

To apply an erratum to a RHEL 8 host, complete the following steps:

  1. On Foreman, list all errata for the host:

    # hammer host errata list \
    --host client.example.com
  2. Find the module stream an erratum belongs to:

    # hammer erratum info --id ERRATUM_ID
  3. On the host, update the module stream:

    # yum update Module_Stream_Name
For Red Hat Enterprise Linux 7

To apply an erratum to a RHEL 7 host, complete the following steps:

  1. In the Foreman web UI, navigate to Hosts > Content Hosts and select the host you want to apply errata to.

  2. Navigate to the Errata tab to see the list of errata.

  3. Select the errata to apply and click Apply Selected. In the confirmation window, click Apply.

  4. After the task to update all packages associated with the selected errata completes, click the Details tab to view the updated packages.

For CLI Users

To apply an erratum to a RHEL 7 host, complete the following steps:

  1. List all errata for the host:

    # hammer host errata list \
    --host client.example.com
  2. Apply the most recent erratum to the host. Identify the erratum to apply using the erratum ID:

    # hammer host errata apply --host "Host Name" \
    --errata-ids ERRATUM_ID1,ERRATUM_ID2...

Applying Errata to Multiple Hosts

Use these procedures to review and apply errata to multiple RHEL 7 hosts.

Prerequisites
  • Synchronize Foreman repositories with the latest errata available from Red Hat. For more information, see Synchronizing Red Hat Repositories.

  • Register the hosts to an environment and Content View on Foreman server. For more information, see Registering Hosts in the Managing Hosts guide.

  • Install the katello-agent package on hosts. For more information, see Installing the Katello Agent in the Managing Hosts guide.

    Note that the Katello agent is deprecated and will be removed in a future Foreman version. Migrate your workloads to use the remote execution feature to update clients remotely. For more information, see Host Management Without Goferd and Katello Agent in the Managing Hosts Guide.

Procedure
  1. Navigate to Content > Errata.

  2. Click the name of an erratum you want to apply.

  3. Click to Content Hosts tab.

  4. Select the hosts you want to apply errata to and click Apply to Hosts.

  5. Click Confirm.

For CLI Users

Although the CLI does not have the same tools as the Web UI, you can replicate a similar procedure with CLI commands.

  1. List all installable errata:

    # hammer erratum list \
    --errata-restrict-installable true \
    --organization "Default Organization"
  2. Select the erratum you want to use and list the hosts that this erratum is applicable to:

    # hammer host list \
    --search "applicable_errata = ERRATUM_ID" \
    --organization "Default Organization"
  3. Apply the errata to a single host:

    # hammer host errata apply \
    --host client.example.com \
    --organization "Default Organization" \
    --errata-ids ERRATUM_ID1,ERRATUM_ID2...
  4. The following Bash script applies an erratum to each host for which this erratum is available:

    for HOST in hammer --csv --csv-separator "|" host list --search "applicable_errata = ERRATUM_ID" --organization "Default Organization" | tail -n+2 | awk -F "|" '{ print $2 }' ;
    do
      echo "== Applying to $HOST ==" ; hammer host errata apply --host $HOST --errata-ids ERRATUM_ID1,ERRATUM_ID2 ;
    done

    This command identifies all hosts with erratum_IDs as an applicable erratum and then applies the erratum to each host.

  5. To see if an erratum is applied successfully, find the corresponding task in the output of the following command:

    # hammer task list
  6. View the state of a selected task:

    # hammer task progress --id task_ID

Applying Errata to a Host Collection

To apply selected errata to a host collection, enter the following command:

# hammer host-collection erratum install \
--errata "erratum_ID1,erratum_ID2,..." \
--name "host_collection_name"\
--organization "Your_Organization"

Managing OSTree Content

OSTree is a tool to manage bootable, immutable, versioned file system trees. You can use OSTree content on a build system, then export an OSTree repository to a static HTTP. Red Hat Enterprise Linux Atomic Server uses OSTree content composed from RPM files as a method to keep the operating system up to date.

You can use Foreman to synchronize and manage OSTree branches from an OSTree repository.

In Foreman server 6.7, OSTree management tools are enabled by default. If you ever have a reason to enable the tool, enter the following command:

# foreman-installer --katello-enable-ostree=true

Selecting Red Hat OSTree Content to Synchronize

Red Hat CDN provides OSTree Content for you to select and synchronize.

Procedure

To find and synchronize OSTree content, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Red Hat Repositories.

  2. From the list, select the OSTree content type.

  3. In the Available Repositories pane, locate the OSTree repisotry set you want to use, for example, the Red Hat Enterprise Linux Atomic Host Trees set from the Red Hat Enterprise Linux Atomic Host product group.

  4. Click the Enable icon to enable the repository you want to use.

  5. Navigate to Content > Products and click the product that you want to use, for example Red Hat Enterprise Linux Atomic Host.

  6. Select the upstream synchronization policy for this repository. By default, Foreman synchronizes only the latest OSTree branch.

    1. Click the repository you want to synchronize.

    2. From the Upstream Sync Policy menu, select one of the following policies to synchronize OSTree branches for this repository:

      • Latest Only - synchronize only the latest OSTree branch.

      • All History - synchronize all OSTree branches.

      • Custom - synchronize a custom number of OSTree branches. Enter the required number into the field below.

    3. Click Save.

  7. From the Select Action menu, select Sync Now.

To view the Synchronization Status
  • In the Foreman web UI, navigate to Content > Sync Status and expand, for example, Red Hat Enterprise Linux Atomic Host.

For CLI Users
  1. Search the Red Hat Enterprise Linux Server product for ostree repositories:

    # hammer repository-set list \
    --product "Red Hat Enterprise Linux Atomic Host" \
    --organization "My_Organization" | grep "ostree"
  2. Enable the ostree repository for Red Hat Enterprise Linux Atomic Host or any product that you want to use:

    # hammer repository-set enable \
    --product "Red Hat Enterprise Linux Atomic Host" \
    --name "Red Hat Enterprise Linux Atomic Host (Trees)" \
    --organization "My_Organization"
  3. Locate and synchronize the repository for the product:

    # hammer repository list \
    --product "Red Hat Enterprise Linux Atomic Host" \
    --organization "My_Organization"
    # hammer repository synchronize \
    --name "Red Hat Enterprise Linux Atomic Host Trees" \
    --product "Red Hat Enterprise Linux Atomic Host" \
    --organization "My_Organization"

Importing OSTree Content

In addition to importing OSTree content from Red Hat CDN, you can also import content from other sources. This requires a published HTTP location for the OSTree to import.

Procedure

To import OSTree content, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Products and click Create Product.

  2. In the Name field, enter a name for your OSTree content. This automatically populates the Label field.

  3. Optional: In the GPG Key field, enter a GPG Key for the entire product.

  4. From the Sync Plan menu, select a synchronization plan to associate with the product.

  5. In the Description field, enter a description of the product and click Save.

  6. When the product creation completes, click Create Repository.

  7. In the Name field, enter a name for the repository. This automatically populates the Label field.

  8. From the Type list, select ostree.

  9. In the URL field, enter the URL of the registry to use as a source. For example http://www.example.com/rpm-ostree/.

  10. From the Upstream Sync Policy menu, select one of the following policies to synchronize OSTree branches for this repository:

    • Latest Only - synchronize only the latest OSTree branch.

    • All History - synchronize all OSTree branches.

    • Custom - synchronize a custom number of OSTree branches. Enter the required number into the field below.

  11. Click Save.

  12. When the repository creation completes, select the new repository and click Sync Now to start the synchronization process.

To view the Synchronization Status:
  • In the Foreman web UI, navigate to Content > Sync Status and expand the entry that you want to view.

For CLI Users
  1. Create a product for your OSTree content:

    # hammer product create \
    --name "OSTree Content" \
    --sync-plan "Example_Plan" \
    --description "OSTree Content" \
    --organization "My_Organization"
  2. Create the repository for the OSTree:

    # hammer repository create \
    --name "OSTree" \
    --content-type "ostree" \
    --url "http://www.example.com/rpm-ostree/" \
    --product "OSTree Content" \
    --organization "My_Organization"
  3. Synchronize the repository:

    # hammer repository synchronize \
    --name "OSTree" \
    --product "OSTree Content" \
    --organization "My_Organization"

Managing OSTree Content with Content Views

Use Content Views to manage OSTree branches across the application life cycle. This process uses the same publication and promotion method that RPMs and Puppet modules use.

Procedure

To create a content view for your OSTree and add a repository, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Content Views and click Create New View.

  2. In the Name field, enter a plain text name for the view. This automatically populates the Label field.

  3. In the Description field, enter a description of the OSTree Content View.

  4. If you want to use a Composite Content View, select the Composite View check box.

  5. Click Save to complete.

  6. Navigate to the OSTree Content tab, then click Add.

  7. Select the OSTree repository for that you want to use. Click Add Repository to add the OSTree content from this repository to the Content View.

  8. Navigate to Versions and click Publish New Version.

  9. In the Description field, enter a description for the version, and click Save.

You can also click Promote to promote this Content View across environments in the application life cycle.

For CLI Users
  1. Obtain a list of repository IDs:

    # hammer repository list --organization "_My_Organization_"
  2. Create the Content View and add the repository:

    # hammer content-view create \
    --name "OSTree" \
    --description "OSTree for Red Hat Enterprise Linux Atomic Host" \
    --repository-ids 5 \
    --organization "My_Organization"
  3. Publish the view:

    # hammer content-view publish \
    --name "OSTree" \
    --description "Example Content View for the OSTree" \
    --organization "My_Organization"

Managing Container Images

With Foreman, you can import container images from various sources and distribute them to external containers using Content Views.

For information about containers, see Getting Started with Containers in Red Hat Enterprise Linux Atomic Host 7.

Importing Container Images

You can import container image repositories from Red Hat Registry or from other image registries.

This procedure uses repository discovery to find container images and import them as repositories. For more information about creating a product and repository manually, see Importing Content.

Procedure

To import container image repositories and create or associate them with a product, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Products and click Repo Discovery.

  2. From the Repository Type list, select Container Images.

  3. In the Registry to Discover field, enter the URL of the registry to import images from.

  4. In the Registry Username field, enter the name that corresponds with your user name for the container image registry.

  5. In the Registry Password field, enter the password that corresponds with the user name that you enter.

  6. In the Registry Search Parameter field, enter any search criteria that you want to use to filter your search, and then click Discover.

  7. Optional: To further refine the Discovered Repository list, in the Filter field, enter any additional search criteria that you want to use.

  8. From the Discovered Repository list, select any repositories that you want to import, and then click Create Selected.

  9. Optional: If you want to create a product, from the Product list, select New Product.

  10. In the Name field, enter a product name.

  11. Optional: In the Repository Name and Repository Label columns, you can edit the repository names and labels.

  12. Click Run Repository Creation.

  13. When repository creation is complete, you can click each new repository to view more information.

  14. Optional: To filter the content you import to a repository, click a repository, and then navigate to Limit Sync Tags. Click to edit, and add any tags that you want to limit the content that synchronizes to Foreman.

  15. Navigate to Content > Products and select the name of your product.

  16. Select the new repositories and then click Sync Now to start the synchronization process.

To view the progress of the synchronization navigate to Content > Sync Status and expand the repository tree.

When the synchronization completes, you can click Container Image Manifests to list the available manifests. From the list, you can also remove any manifests that you do not require.

For CLI Users
  1. Create the custom Red Hat Container Catalog product:

    # hammer product create \
    --name "Red Hat Container Catalog" \
    --sync-plan "Example Plan" \
    --description "Red Hat Container Catalog content" \
    --organization "My_Organization"
  2. Create the repository for the container images:

    # hammer repository create \
    --name "RHEL7" \
    --content-type "docker" \
    --url "http://registry.access.redhat.com/" \
    --docker-upstream-name "rhel7" \
    --product "Red Hat Container Catalog" \
    --organization "My_Organization"
  3. Synchronize the repository:

    # hammer repository synchronize \
    --name "RHEL7" \
    --product "Red Hat Container Catalog" \
    --organization "My_Organization"

Managing Container Name Patterns

When you use Foreman to create and manage your containers, as the container moves through Content View versions and different stages of the Foreman lifecycle environment, the container name changes at each stage. For example, if you synchronize a container image with the name ssh from an upstream repository, when you add it to a Foreman product and organization and then publish as part of a Content View, the container image can have the following name: my_organization_production-custom_spin-my_product-custom_ssh. This can create problems when you want to pull a container image because container registries can contain only one instance of a container name. To avoid problems with Foreman naming conventions, you can set a registry name pattern to override the default name to ensure that your container name is clear for future use.

Limitations

If you use a registry name pattern to manage container naming conventions, because registry naming patterns must generate globally unique names, you might experience naming conflict problems. For example:

  • If you set the repository.docker_upstream_name registry name pattern, you cannot publish or promote Content Views with container content with identical repository names to the Production lifecycle.

  • If you set the lifecycle_environment.name registry name pattern, this can prevent the creation of a second container repository with the identical name.

You must proceed with caution when defining registry naming patterns for your containers.

Procedure

To manage container naming with a registry name pattern, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Lifecycle Environments, and either create a lifecycle environment or select a lifecycle environment to edit.

  2. In the Container Image Registry area, click the edit icon to the right of Registry Name Pattern area.

  3. Use the list of variables and examples to determine which registry name pattern you require.

  4. In the Registry Name Pattern field, enter the registry name pattern that you want to use. For example, to use the repository.docker_upstream_name:

    <%= repository.docker_upstream_name %>
  5. Click Save.

Managing Container Registry Authentication

By default, users must authenticate to access containers images in Foreman.

You can specify whether you want users to authenticate to access container images in Foreman in a lifecycle environment. For example, you might want to permit users to access container images from the Production lifecycle without any authentication requirement and restrict access the Development and QA environments to authenticated users.

Procedure

To manage the authentication settings for accessing containers images from Foreman, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Lifecycle Environments and select the lifecycle environment that you want to manage authentication for.

  2. To permit unauthenticated access to the containers in this lifecycle environment, select the Unauthenticated Pull check box. To restrict unauthenticated access, clear the Unauthenticated Pull check box.

  3. Click Save.

Managing ISO Images

You can use Foreman to store ISO images, either from Red Hat’s Content Delivery Network or other sources. You can also upload other files, such as virtual machine images, and publish them in repositories.

Importing ISO Images from Red Hat

The Red Hat Content Delivery Network provides ISO images for certain products. The procedure for importing this content is similar to the procedure for enabling repositories for RPM content.

Procedure

To import Red Hat ISO images, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Red Hat Repositories.

  2. In the Search field, enter an image name, for example, Red Hat Enterprise Linux 7 Server (ISOs).

  3. In the Available Repositories window, expand Red Hat Enterprise Linux 7 Server (ISOs).

  4. For the x86_64 7.2 entry, click the Enable icon to enable the repositories for the image.

  5. Navigate to Content > Products and click Red Hat Enterprise Linux Server.

  6. Click the Repositories tab of the Red Hat Enterprise Linux Server window, and click Red Hat Enterprise Linux 7 Server ISOs x86_64 7.2.

  7. In the upper right of the Red Hat Enterprise Linux 7 Server ISOs x86_64 7.2 window, click Select Action and select Sync Now.

To view the Synchronization Status
  • In the web UI, navigate to Content > Sync Status and expand Red Hat Enterprise Linux Server.

For CLI Users
  1. Locate the Red Hat Enterprise Linux Server product for file repositories:

    # hammer repository-set list \
    --product "Red Hat Enterprise Linux Server" \
    --organization "My_Organization" | grep "file"
  2. Enable the file repository for Red Hat Enterprise Linux 7.2 Server ISO:

    # hammer repository-set enable \
    --product "Red Hat Enterprise Linux Server" \
    --name "Red Hat Enterprise Linux 7 Server (ISOs)" \
    --releasever 7.2 \
    --basearch x86_64 \
    --organization "My_Organization"
  3. Locate and synchronize the repository in the product:

    # hammer repository list \
    --product "Red Hat Enterprise Linux Server" \
    --organization "My_Organization"
    # hammer repository synchronize \
    --name "Red Hat Enterprise Linux 7 Server ISOs x86_64 7.2" \
    --product "Red Hat Enterprise Linux Server" \
    --organization "My_Organization"

Importing Individual ISO Images and Files

Use this procedure to manually import ISO content and other files to Foreman server. To import files, you can complete the following steps in the web UI or using the Hammer CLI. However, if the size of the file that you want to upload is larger than 15 MB, you must use the Hammer CLI to upload it to a repository.

  1. Create a product.

  2. Add a repository for files to the product.

  3. Upload a file to the repository.

Procedure

To import ISO images, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Products, and in the Products window, click Create Product.

  2. In the Name field, enter a name to identify the product. This name populates the Label field.

  3. In the GPG Key field, enter a GPG Key for the product.

  4. From the Sync Plan list, select a synchronization plan for the product.

  5. In the Description field, enter a description of the product.

  6. Click Save.

  7. In the Products window, click the new product and then click Create Repository.

  8. In the Name field, enter a name for the repository. This automatically populates the Label field.

  9. From the Type list, select file.

  10. In the Upstream URL field, enter the URL of the registry to use as a source. Add a corresponding user name and password in the Upstream Username and Upstream Password fields.

  11. Click Save.

  12. Click the new repository.

  13. Navigate to the Upload File and click Browse.

  14. Select the .iso file and click Upload.

For CLI Users
  1. Create the product:

    # hammer product create \
    --name "My_ISOs" \
    --sync-plan "Example Plan" \
    --description "My_Product" \
    --organization "My_Organization"
  2. Create the repository:

    # hammer repository create \
    --name "My_ISOs" \
    --content-type "file" \
    --product "My_Product" \
    --organization "My_Organization"
  3. Upload the ISO file to the repository:

    # hammer repository upload-content \
    --path ~/bootdisk.iso \
    --id repo_ID \
    --organization "My_Organization"

Managing File Type Content

In Foreman, you might require methods of managing and distributing SSH keys and source code files or larger files such as virtual machine images and ISO files. To achieve this, (customproduct)s in Foreman include repositories for file types. This provides a generic method to incorporate arbitrary files in a product.

You can upload files to the repository and synchronize files from an upstream Foreman server. When you add files to a file type repository, you can use the normal Foreman management functions such as adding a specific version to a Content View to provide version control and making the repository of files available on various Smart Proxy servers. Clients must download the files over HTTP or HTTPS using curl -O.

You can create a file type repository in Foreman server only in a (customproduct), but there is flexibility in how you create the file type repository. You can create an independent file type repository in a directory on the system where Foreman is installed, or on a remote HTTP server, and then synchronize the contents of that directory into Foreman. This method is useful when you have multiple files to add to a Foreman repository.

Creating a File Type Repository in Foreman

The procedure for creating a file type repository is the same as the procedure for creating any content, except that when you create the repository, you select the file type. You must create a product and then add a repository.

Procedure

To create a (customproduct), complete the following procedure:

  1. In the Foreman web UI, navigate to Content > Products, click Create Product and enter the following details:

  2. In the Name field, enter a name for the product. Foreman automatically completes the Label field based on what you have entered for Name.

  3. Optional: From the GPG Key list, select the GPG key for the product.

  4. Optional: From the Sync Plan list, select a synchronization plan for the product.

  5. In the Description field, enter a description of the product, and then click Save.

To create a repository for your (customproduct), complete the following procedure:

  1. In the Products window, select the name of a product that you want to create a repository for.

  2. Click the Repositories tab, and then click New Repository.

  3. In the Name field, enter a name for the repository. Foreman automatically completes the Label field based on the name.

  4. From the Type list, select file.

  5. In the Upstream URL field, enter the URL of the upstream repository to use as a source.

  6. Select the Verify SSL check box if you want to verify that the upstream repository’s SSL certificates are signed by a trusted CA.

  7. In the Upstream Username field, enter the user name for the upstream repository if required for authentication. Clear this field if the repository does not require authentication.

  8. In the Upstream Password field, enter the corresponding password for the upstream repository. Clear this field if the repository does not require authentication.

  9. Click Save.

For CLI Users
  1. Create a product

    # hammer product create \
    --name "My File Product" \
    --sync-plan "Example Plan" \
    --description "My files" \
    --organization "My_Organization"
    Table 4. Optional Parameters for the hammer product create Command
    Option Description

    --gpg-key gpg_key_name

    Key name to search by

    --gpg-key-id gpg_key_id

    GPG key numeric identifier

    --sync-plan sync_plan_name

    Sync plan name to search by

    --sync-plan-id sync_plan_id

    Sync plan numeric identifier

  2. Create a File Type Repository

    # hammer repository create \
    --name "My Files" \
    --content-type "file" \
    --product "My File Product" \
    --organization "My_Organization"
    Table 5. Optional Parameters for the hammer repository create Command
    Option Description

    --checksum-type sha_version

    Repository checksum, currently 'sha1' & 'sha256' are supported

    --download-policy policy_name

    Download policy for yum repos (either 'immediate', 'on_demand', or 'background').

    --gpg-key gpg_key_name

    Key name to search by

    --gpg-key-id gpg_key_id

    GPG key numeric identifier

    --mirror-on-sync boolean

    Must this repo be mirrored from the source, and stale RPMs removed, when synced? Set to true or false, yes or no, 1 or 0.

    --publish-via-http boolean

    Must this also be published using HTTP? Set to true or false, yes or no, 1 or 0.

    --upstream-username repository_username

    Upstream repository user, if required for authentication

    --upstream-password repository_password

    Password for the upstream repository user

    --url source_repo_url

    URL of the Source repository

    --verify-ssl-on-sync boolean

    Must Katello verify that the upstream URL’s SSL certificates are signed by a trusted CA? Set to true or false, yes or no, 1 or 0.

Creating a File Type Repository in a Local Directory

You can create a file type repository, from a directory of files, on the base system where Foreman is installed using the pulp-manifest command. You can then synchronize the files into Foreman server. When you add files to a file type repository, you can work with the files as with any other repository.

Use this procedure to configure a repository in a directory on the base system where Foreman is installed. To create a file type repository in a directory on a remote server, see Creating a Remote File Type Repository.

Procedure

To create a file type repository in a local directory, complete the following procedure:

  1. Ensure the Server and https://yum.theforeman.org/client/2.0/ repositories are enabled.

  2. Install the Pulp Manifest package:

    # yum install python-pulp-manifest
  3. Create a directory that you want to use as the file type repository in the HTTP server’s public folder:

    # mkdir my_file_repo
  4. Add files to the directory or create a test file:

    # touch my_file_repo/test.txt
  5. Enter the Pulp Manifest command to create the manifest:

    # pulp-manifest my_file_repo
  6. Verify the manifest was created:

    # ls my_file_repo
    PULP_MANIFEST test.txt
Importing Files from a File Type Repository

To import files from a file type repository in a local directory, complete the following procedure:

  1. Ensure a product exists in Foreman server.

  2. In the Foreman web UI, navigate to Content > Products.

  3. Select the name of a product.

  4. Click the Repositories tab and select New Repository.

  5. In the Name field, enter a name for the repository. Foreman automatically completes this field based on what you enter for Name.

  6. From the Type list, select the content type of the repository.

  7. In the Upstream URL field, enter the local directory with the repository to use as the source, in the form file:///my_file_repo.

  8. Select the Verify SSL check box to check the SSL certificate for the repository or clear the Verify SSL check box.

  9. Optional: In the Upstream Username field, enter the upstream user name that you require.

  10. Optional: In the Upstream Password field, enter the corresponding password for your upstream user name.

  11. Select Save to save this repository entry.

Updating a File Type Repository

To update the file type repository, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Products.

  2. Select the name of a product.

  3. Select the name of the repository you want to update.

  4. From the Select Action menu, select Sync Now.

  5. Visit the URL where the repository is published to see the files.

Creating a Remote File Type Repository

You can create a file type repository from a directory of files that is external to Foreman server using the pulp-manifest command. You can then synchronize the files into Foreman server over HTTP or HTTPS. When you add files to a file type repository, you can work with the files as with any other repository.

Use this procedure to configure a repository in a directory on a remote server. To create a file type repository in a directory on the base system where Foreman server is installed, see Creating a File Type Repository in a Local Directory.

Prerequisites

Before you create a remote file type repository, ensure the following conditions exist:

  • You have a Red Hat Enterprise Linux 7 server registered to your Foreman or the Red Hat CDN.

  • You have installed an HTTP server. For more information about configuring a web server, see The Apache HTTP Server in the Red Hat Enterprise Linux 7 System Administrator’s Guide.

Procedure

To create a file type repository in a remote directory, complete the following procedure:

  1. On your remote server, ensure that the Server and https://yum.theforeman.org/client/2.0/ repositories are enabled.

  2. Install the Pulp Manifest package:

    # yum install python-pulp-manifest
  3. Create a directory that you want to use as the file type repository in the HTTP server’s public folder:

    # mkdir /var/www/html/pub/my_file_repo
  4. Add files to the directory or create a test file:

    # touch /var/www/html/pub/my_file_repo/test.txt
  5. Enter the Pulp Manifest command to create the manifest:

    # pulp-manifest /var/www/html/pub/my_file_repo
  6. Verify the manifest was created:

    # ls /var/www/html/pub/my_file_repo
    PULP_MANIFEST test.txt
Importing Files from a Remote a File Type Repository

To import files from a remote file type repository, complete the following procedure:

  1. Ensure a product exists in Foreman server, or create a product. For more information see Creating a File Type Repository in Foreman

  2. In the Foreman web UI, navigate to Content > Products.

  3. Select the name of a product.

  4. Click the Repositories tab and select New Repository.

  5. In the Name field, enter a name for the repository. Foreman automatically completes this field based on what you enter for Name.

  6. From the Type list, select file.

  7. In the Upstream URL field, enter the URL of the upstream repository to use as a source.

  8. Select the Verify SSL check box if you want to verify that the upstream repository’s SSL certificates are signed by a trusted CA.

  9. In the Upstream Username field, enter the user name for the upstream repository if required for authentication. Clear this field if the repository does not require authentication.

  10. In the Upstream Password field, enter the corresponding password for the upstream repository. Clear this field if the repository does not require authentication.

  11. Click Save.

  12. To update the file type repository, navigate to Content > Products. Select the name of a product that contains the repository that you want to update.

  13. In the product’s window, select the name of the repository you want to update.

  14. From the Select Action menu, select Sync Now.

Visit the URL where the repository is published to view the files.

Uploading Files To a File Type Repository in Foreman

Procedure

To upload files to a file type repository, complete the following steps:

  1. In the Foreman web UI, navigate to Content > Products.

  2. Select a product by name.

  3. Select a file type repository by name.

  4. Click Browse to search and select the file you want to upload.

  5. Click Upload to upload the selected file to Foreman server.

  6. Visit the URL where the repository is published to see the file.

For CLI Users
# hammer repository upload-content \
--id repo_ID \
--organization "My_Organization" \
--path example_file

The --path option can indicate a file, a directory of files, or a glob expression of files. Globs must be escaped by single or double quotes.

Downloading Files to a Host From a File Type Repository in Foreman

You can download files to a client over HTTPS using curl -O, and optionally over HTTP if the Publish via HTTP repository option is selected.

Prerequisites
Procedure

To download files to a host from a file type repository, complete the following procedure:

  1. In the Foreman web UI, navigate to Content > Products.

  2. Select a product by name.

  3. Select a file type repository by name.

  4. Check to see if Publish via HTTP is enabled. If it is not, you require the certificates to use HTTPS.

  5. Copy the URL where the repository is published.

For CLI Users
  1. List the file type repositories.

    # hammer repository list --content-type file
    ---|----------|-----------------|--------------|----
    ID | NAME     | PRODUCT         | CONTENT TYPE | URL
    ---|----------|-----------------|--------------|----
    7  | My Files | My File Product | file         |
    ---|----------|-----------------|--------------|----
  2. Display the repository information.

    # hammer repository info --name "My Files" --product "My File Product" --organization-id 1

    If HTTP is enabled, the output is similar to this:

    Publish Via HTTP:   yes
    Published At:       http://foreman.example.com/pulp/isos/uuid/

    If HTTP is not enabled, the output is similar to this:

    Publish Via HTTP:   no
    Published At:       https://foreman.example.com/pulp/isos/uuid/
  3. On the client, enter a command in the appropriate format for HTTP or HTTPS:

    For HTTP:

    # curl -O foreman.example.com/pulp/isos/uuid/my_file

    For HTTPS:

    # curl -O --cert ./Default\ Organization-key-cert.pem --cacert katello-server-ca.crt foreman.example.com/pulp/isos/uuid/my_file

Managing Puppet Content

In Foreman, if you want to incorporate state configuration of hosts using Puppet modules, you can create a product with repositories for Puppet modules to achieve this.

Creating a Puppet Repository

The procedure for creating a Puppet module repository is the same as the procedure for creating any (customcontent), except that when you create the repository, you select the puppet type. You must create a product and then add a repository.

Procedure
  1. In the Foreman web UI, navigate to Content > Products, and click the product that you want to use.

  2. Click Create Repository.

  3. In the Name field, enter a name for the repository. Foreman automatically completes the Label field based on what you have entered for Name.

  4. From the Type list, select puppet.

  5. In the URL field, enter the URL of the external repository to use as a source. You can use a repository source to synchronize your own Puppet modules.

  6. Click Save.

For CLI Users
  1. Enter the following command to create a Puppet module repository:

    # hammer repository create \
    --name "PostgreSQL Puppet Modules" \
    --content-type "puppet" \
    --product "PostgreSQL" \
    --organization "My_Organization"

Managing Individual Puppet Modules

If you want to create a product that contains both RPM content and a Puppet module to install and configure a server using the RPM content, use the procedure in Creating a Puppet Repository and then use the following procedure to upload Puppet modules.

Prerequisites
  1. From the Puppet Forge website, download the module that you want to use, for example, https://forge.puppetlabs.com/puppetlabs/postgresql.

  2. In your web browser, click download latest tar.gz to save to your local file system.

Procedure
  1. In the Foreman web UI, navigate to Content > Products and select the product that contains the Puppet repository that you want to manage.

  2. In the repository window, click the new Puppet repository, which displays the details page for that repository.

  3. Navigate to the Upload Puppet Module area, click Browse, select the newly downloaded and extracted Puppet module, and click Upload.

To manage and remove Puppet modules from a product, complete the following steps:

  1. In the window for your Puppet Modules repository, navigate to the upper right of the window to the Content Counts area. In the Puppet Modules row, click the numerical value that is displayed for the Puppet Modules.

  2. In the Manage Puppet Modules for your Puppet Module repository window, select the modules that you want to manage and then click Select Action and perform an action, or select Remove Puppet Modules.

For CLI Users
  1. Copy the Puppet module to your Foreman server’s file system:

    $ scp ~/puppet_module.tar.gz root@foreman.example.com:~/.
  2. Import the Puppet module to the Puppet Modules repository:

    # hammer repository upload-content \
    --path ~/puppet_module.tar.gz \
    --id repo_ID \
    --organization "My_Organization"

Synchronizing Puppet Repositories

In addition to creating a repository of uploaded Puppet modules, Foreman server can synchronize a complete Puppet module repository. In this example, Foreman server synchronizes the entire Puppet Forge repository.

Procedure
  1. In the Foreman web UI, navigate to Content > Products and click Create Product.

  2. In the Name field, enter a name for the product. Foreman automatically completes the Label field based on what you have entered for Name.

  3. Optional: From the GPG Key list, select the GPG key for the product.

  4. Optional: From the Sync Plan list, select a synchronization plan for the product.

  5. In the Description field, enter a description of the product.

  6. Click Save.

  7. Click Create Repository, which displays a form for a new repository.

  8. In the Name field, enter a name for the repository. Foreman automatically completes this field based on what you have entered for Name.

  9. From the Type list, select puppet.

  10. In the URL field, enter http://forge.puppetlabs.com/.

  11. Click Save

  12. Select the new Puppet repository and click Sync Now to import all modules from Puppet Forge into Foreman server. This can take a long time.

For CLI Users
  1. Create the product:

    # hammer product create \
    --name "Puppet Forge" \
    --sync-plan "Example Plan" \
    --description "All modules from Puppet Forge" \
    --organization "My_Organization"
  2. Create the Puppet Forge repository:

    # hammer repository create \
    --name "Puppet Forge Modules" \
    --content-type "puppet" \
    --product "Puppet Forge" \
    --organization "My_Organization" \
    --url http://forge.puppetlabs.com/
  3. Synchronize the repository:

    # hammer repository synchronize \
    --name "Puppet Forge Modules" \
    --product "Puppet Forge" \
    --organization "My_Organization"

The Puppet Forge repository contains several thousand modules and can take a long time to synchronize.

Synchronizing Puppet Modules from a Git Repository

Foreman includes a utility called pulp-puppet-module-builder, which you can install on other systems from the pulp-puppet-tools RPM. This tool checks out a Git repository, builds all the modules, and publishes them in a structure that Foreman can synchronize. One common method is to run the utility on Foreman server itself, publish to a local directory, and synchronize against that directory. For example:

# mkdir /modules
# chmod 755 /modules
# pulp-puppet-module-builder \
--output-dir=/modules \
--url=git@mygitserver.com:mymodules.git \
--branch=develop

This example checks out the develop branch of the Git repository from git@mygitserver.com:mymodules.git and publishes it to /modules. Add this directory as the URL (file:///modules) for a new repository on Foreman server.

Publishing Puppet Modules on a Remote HTTP Server

The same process also applies to publishing modules on a remote HTTP server. For example, if you use webserver.example.com as a standard web host to publish the Puppet modules.

# mkdir /var/www/html/modules/
# chmod 755 /var/www/html/modules/
# pulp-puppet-module-builder \
--output-dir=/var/www/html/modules/ \
--url=git@mygitserver.com:mymodules.git \
--branch=develop

On Foreman server, set the repository’s URL to http://webserver.example.com/modules/.

Synchronizing Puppet Modules from a Git repository using the web UI

Use the following procedure to synchronize Puppet modules from a Git repository.

Procedure
  1. Create a product and click Create Repository.

  2. From the Type list, select puppet.

  3. In the URL field, enter the URL of the external Git repository to use as a source in the following format: file:///modules.

For CLI Users
  1. Create the Puppet Forge repository:

    # hammer repository create \
    --name "Modules from Git" \
    --content-type "puppet" \
    --product "MyProduct" \
    --organization "My_Organization" \
    --url file:///modules

Appendix A: Using an NFS Share for Content Storage

Your environment requires adequate hard disk space to fulfill content storage. In some situations, it is useful to use an NFS share to store this content. This appendix shows how to mount the NFS share on your Foreman server’s content management component.

Important
Do not mount the full /var/lib/pulp on an NFS share. Use high-bandwidth, low-latency storage for the /var/lib/pulp file system. Foreman has many I/O-intensive operations; therefore, high-latency, low-bandwidth storage might have issues with performance degradation. Only use the NFS share for the /var/lib/pulp/content directory.
  1. Create the NFS share. This example uses a share at nfs.example.com:/satellite/content. Ensure this share provides the appropriate permissions to Foreman server and its apache user.

  2. Stop the foreman-maintain services on the Foreman host:

    # foreman-maintain service stop
  3. Ensure Foreman server has the nfs-utils package installed:

    # yum install nfs-utils
  4. You need to copy the existing contents of /var/lib/pulp/content to the NFS share. First, mount the NFS share to a temporary location:

    # mkdir /mnt/temp
    # mount -o rw nfs.example.com:/satellite/content /mnt/temp

    Copy the existing contents of /var/lib/pulp/content to the temporary location:

    # cp -r /var/lib/pulp/content/* /mnt/temp/.
  5. Set the permissions for all files on the share to use the apache user. This ID of this user is usually 48.

  6. Unmount the temporary storage location:

    # umount /mnt/temp
  7. Remove the existing contents of /var/lib/pulp/content:

    # rm -rf /var/lib/pulp/content/*
  8. Edit the /etc/fstab file and add the following line:

    nfs.example.com:/satellite/content    /var/lib/pulp/content   nfs    rw,hard,intr,context="system_u:object_r:httpd_sys_rw_content_t:s0"

    This makes the mount persistent across system reboots. Ensure to include the SELinux context.

  9. Enable the mount:

    # mount -a
  10. Confirm the NFS share mounts to var/lib/pulp/content:

    # df
    Filesystem                         1K-blocks     Used Available Use% Mounted on
    ...
    nfs.example.com:/satellite/content 309506048 58632800 235128224  20% /var/lib/pulp/content
    ...

    Also confirm that the existing content exists at the mount on var/lib/pulp/content:

    # ls /var/lib/pulp/content
  11. Start the foreman-maintain services on the Foreman host:

    # foreman-maintain service start

Foreman server now uses the NFS share to store content. Run a content synchronization to ensure the NFS share works as expected. For more information, see Content Synchronization Overview.

Appendix B: Importing Content ISOs into a Connected Foreman

Even if Foreman server can connect directly to the Red Hat Customer Portal, you can perform the initial synchronization from locally mounted content ISOs. When the initial synchronization is completed from the content ISOs, you can switch back to downloading content through the network connection. To accomplish this, download the Content ISOs for Foreman from the Red Hat Customer Portal and import them into Foreman server. For locations with bandwidth limitations, using an On Demand or Background download policy might be more efficient than downloading and importing Content ISOs.

Important
You can only import content ISO images for Red Hat Enterprise Linux 8 because repodata checksum from CDN does not match the repodata checksum from the content ISO images for Red Hat Enterprise Linux 7 and lower.

Note that if you synchronize a Red Hat Enterprise Linux ISO, all minor versions of Red Hat Enterprise Linux also synchronize. You require adequate storage on your Foreman to account for this.

Important
This section is not required if your Foreman server is connected to the Internet.

This example procedure performs the first synchronization of the Red Hat Enterprise Linux 8 repository from content ISO images.

Procedure
  1. Log in to the Red Hat Customer Portal at https://access.redhat.com/.

  2. In the upper left of the window, click Downloads and select Red Hat Satellite.

  3. Click the Content ISOs tab. This page lists all the products that are available in your subscription.

  4. Click the link for the product name, such as RHEL 8 (x86_64), to reveal links to download ISO images.

  5. Download the ISO images.

  6. On Foreman, create a directory to act as a temporary store for all of the required Satellite content ISO images. This example uses /tmp/isos/rhel8:

    # mkdir -p /tmp/isos/rhel8
  7. On your workstation, copy the ISO files to Foreman server:

    $ scp ~/Downloads/iso_file root@foreman.example.com:/tmp/isos/rhel8
  8. On Foreman server, create a directory to serve as a mount point for the ISOs:

    # mkdir /mnt/iso
  9. Create a working directory to store ISO images:

    # mkdir /mnt/rhel8
  10. Temporarily mount the first ISO image:

    # mount -o loop /tmp/isos/iso_file /mnt/iso
  11. Recursively copy the contents of the first ISO to the working directory:

    # cp -ruv /mnt/iso/* /mnt/rhel8/
  12. Unmount the ISO image:

    # umount /mnt/iso
  13. Repeat the above step for each ISO until you have copied all the data from the Content ISO images into /mnt/rhel8.

  14. If required, remove the empty directory used as the mount point:

    # rmdir /mnt/iso
  15. If required, remove the temporary working directory and its contents to regain space:

    # rm -rf /tmp/isos/
  16. Set the owner and the SELinux context for the directory and its contents to be the same as /var/lib/pulp:

    # chcon -R --reference /var/lib/pulp  /mnt/rhel8/
    # chown -R apache:apache /mnt/rhel8/
  17. Create or edit the /etc/pulp/content/sources/conf.d/local.conf file. Append the following text into the file:

    [rhel-8-server]
    enabled: 1
    priority: 0
    expires: 3d
    name: Red Hat Enterprise Linux 8
    type: yum
    base_url: file:///mnt/rhel8/content/dist/rhel/server/8/x86_64/os/

    The base_url path might differ in your content ISO. The directory specified in base_url must contain the repodata directory, otherwise the synchronization fails. To synchronize multiple repositories, create a separate entry for each of them in the configuration file /etc/pulp/content/sources/conf.d/local.conf.

  18. In the Foreman, navigate to Content > Red Hat Repositories and enable the following repositories:

    • Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8

    • Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8

  19. Under Content > Sync Status select the repositories to be synchronized and click Synchronize Now.

Note that the Satellite web UI does not indicate which source is being used. In case of problems with a local source, Satellite pulls content through the network. To monitor the process, enter the following command on Satellite:

# journalctl -f -l SYSLOG_IDENTIFIER=pulp | grep -v worker[\-,\.]heartbeat

The above command displays interactive logs. First, Foreman server connects to the Red Hat Customer Portal to download and process repository metadata. Then, the local repository is loaded. In case of any errors, cancel the synchronization in the Foreman web UI and verify your configuration.

After successful synchronization you can detach the local source by removing its entry from /etc/pulp/content/sources/conf.d/local.conf.