Skip to main content

Configuring Foreman in the terminal

info

This is part of the Foreman tutorial series. Be sure to refer to the first tutorial if you have not already.

Set up hammer variables

Create a *.yml file for to save credentials:

~/.hammer/cli_config.yml
:foreman:
:host: 'https://foreman.internal.virtnet'
:username: 'admin'
:password: 'password'

Protect the password:

chmod 600 ~/.hammer/cli_config.yml

Set the organization:

hammer organization update --name "Default Organization" --new-name "internal.virtnet"

Finally set hammer variables:

hammer defaults add --param-name organization --param-value "internal.virtnet"
note

This was done for ease-of-use. It is not necessary in order to use hammer. However proceeding commands will be omitting specifying the eg. organization.

Setting up GPG keys

Create a product:

hammer product create --name "CentOS 7"

Download and store GPG Keys

First, download the CentOS 7 GPG key:

wget http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

Then store via hammer content-credentials:

hammer content-credentials create --content-type gpg_key --key "RPM-GPG-KEY-CentOS-7" --name "RPM-GPG-KEY-CentOS-7"

Now let's do the same for EPEL 7 GPG key:

wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7Server
hammer content-credentials create --content-type gpg_key --key "RPM-GPG-KEY-EPEL-7Server" --name "RPM-GPG-KEY-EPEL-7Server"

Create Repos

CentOS 7 base repo:

hammer repository create --product "CentOS 7" --name "x86_64" --content-type "yum" --download-policy "on_demand" --gpg-key "RPM-GPG-KEY-CentOS-7" --url "http://mirror.centos.org/centos/7/os/x86_64/" --mirror-on-sync "no"

CentOS 7 extras repo:

hammer repository create --product "CentOS 7" --name "x86_64_extras" --content-type "yum" --download-policy "on_demand" --gpg-key "RPM-GPG-KEY-CentOS-7" --url "http://mirror.centos.org/centos/7/extras/x86_64/" --mirror-on-sync "no"

CentOS 7 updates repo:

hammer repository create --product "CentOS 7" --name "x86_64_updates" --content-type "yum" --download-policy "on_demand" --gpg-key "RPM-GPG-KEY-CentOS-7" --url "http://mirror.centos.org/centos/7/updates/x86_64/" --mirror-on-sync "no"

EPEL 7 repo:

hammer repository create --product "CentOS 7" --name "x86_64_epel" --content-type "yum" --download-policy "on_demand" --gpg-key "RPM-GPG-KEY-EPEL-7Server" --url "https://dl.fedoraproject.org/pub/epel/7Server/x86_64/" --mirror-on-sync "no"

Sync Repos

You can sync the repos using a small loop:

for i in $(seq 1 4); do \
hammer repository synchronize \
--product "CentOS 7" \
--id "$i"; \
done
note

These will take a while to sync.

Sources