Hammer cheat sheet

Updated -

For Satellite 6.2

Hammer is a command-line tool provided with Red Hat Satellite 6. You can use Hammer to configure and manage a Red Hat Satellite Server through either CLI commands or automation in shell scripts. The following cheat sheet provides a condensed overview of essential Hammer commands. See the Hammer CLI Guide for more information on Hammer.

General information
--help Display hammer commands and options, append after a subcommand to get more information
org The setting is organization-specific, append --organization org_name, or set default organization with: hammer defaults add --param-name \
organization_id --param-value org_ID

(Satellite 6.2 only)
loc The setting is location-specific, append --location loc_name, or set default loction with: hammer defaults add --param-name location_id \
--param-value loc_ID

(Satellite 6.2 only)
Note: This cheat sheet assumes saved credentials in ~/.hammer/cli_config.yml. See the Authentication section of the Hammer CLI Guide for more information.
Organizations, Locations, and Repositories
Subcommand Description and Tasks
organization
Create an organization
hammer organization create \
--name org_name

List organizations
hammer organization list

location See the options for organization
subscription
org
Upload a subscription manifest
hammer subscription upload \
--file path
repository-set
org
Enable a repository
hammer repository-set enable \
--product "prod_name" \
--basearch "base_arch" \
--releasever "rel_v" \
--name "repo_name"

repository
org
Synchronize a repository
hammer repository synchronize \
--product "prod_name" \
--name "repo_name"

Create a custom repository
hammer repository create \
--product "prod_name" \
--content-type cont_type \
--publish-via-http true \
--url "repo_url" --name "repo_name"

Upload content to a custom repository
hammer repository upload-content \
--product "prod_name" \
--id "repo_id" --path "path_to_dir"

Content life cycle
Subcommand Description and Tasks
lifecycle-environment
org
Create a life cycle environment
hammer lifecycle-environment \
create --name env_name \
--description "env_desc" \
--prior prior_env_name

List life cycle environments
hammer lifecycle-environment \
list

content-view
org
Create a content view
hammer content-view create \
--name cv_n \
--repository-ids repo_ID1,... \
--description "cv_description"

Add repositories to a content view
hammer content-view \
add-repository \
--name cv_n \
--repository-id repo_ID

Add Puppet modules to a content view
hammer content-view \
puppet-module add \
--content-view cv_n \
--name module_name

Publishing a content view
hammer content-view publish \
--id cv_ID

Publishing a content view
hammer content-view version \
promote --content-view cv_n \
--to-lifecycle-environment \
env_name

Incremental update of a content view
hammer content-view version \
incremental-update \
--content-view-version-id \
cv_ID --packages pkg_n1,... \
--environment-ids env_ID1,...

Provisioning environment
Subcommand Description and Tasks
domain Create a domain
hammer domain create \
--name domain_name
subnet
orgloc
Add a subnet
hammer subnet create \
--name subnet_name \
--organization-ids org_ID1,... \
--location-ids loc_ID1,... \
--domain-ids dom_ID1,... \
--boot-mode boot_mode \
--network network_address \
--mask netmask --ipam ipam
compute-resource
orgloc
Create a compute resource
hammer compute-resource create \
--name cr_name \
--organization-ids org_ID1,...
--location-ids loc_ID1,... \
--provider provider_name
medium Add an installation medium
hammer medium create \
--name med_name\
--path path_to_medium
partition-table Add a partition table
hammer partition-table create \
--name tab_name\
--path path_to_file \
--os-family os_family
template Add a provisioning template
hammer template create \
--name tmp_name\
--file path_to_template
os Add an operating system
hammer os create --name os_name\
--version version_num
Activation Keys
Subcommand Description and Tasks
activation-key
org
Create an activation key
hammer activation-key create \
--name ak_name \
--content-view cv_n \
--lifecycle-environment lc_name
Add a subscription to the activation key
hammer activation-key \
add-subscription --id ak_ID \
--subscription-id sub_ID
Users and Permissions
Subcommand Description and Tasks
user
org
Create a user
hammer user create --login user_name \
--mail user_mail --auth-source-id 1 \
--organization-ids org_ID1,org_ID2...

Add a role to a user
hammer user add-role --id user_id \
--role role_name

user-group
Create a user group
hammer user-group create \
--name ug_name

Add a role to a user group
hammer user-group add-role --id ug_id \
--role role_name

role Create a role
hammer role create --name role_name
filter
Create a filter and add it to a role
hammer filter create --name role_name \
--permission-ids perm_ID1,perm_ID2...
Errata
Subcommand Description and Tasks
erratum List errata
hammer erratum list

Find erratum by CVE
hammer erratum list --cve CVE

Inspect erratum
hammer erratum info --id err_ID

host List errata applicable to a host
hammer host errata list \
--host host_name

Apply errata to a host
hammer host errata apply \
--host host_name \
--errata-ids err_ID1,err_ID2...

Docker containers
Subcommand Description and Tasks
docker Create a container
hammer docker container create \
--name container_name \
--compute-resource-id cr_ID \
--repository-name repo_name \
--tag tag --command command

Start a container
hammer docker container start \
--id cont_ID

Hosts
Subcommand Description and Tasks
hostgroup
orgloc
Create a host group
hammer hostgroup create \
--name "hg_name" \
--environment "env_name" \
--architecture "arch_name" \
--domain domain_name \
--subnet subnet_name \
--puppet-proxy proxy_name \
--puppet-ca-proxy ca-proxy_name \
--operatingsystem "os_name" \
--partition-table "table_name" \
--medium "medium_name" \
--organization-ids org_ID1... \
--location-ids loc_ID1...

Add an activation key to a host group
hammer hostgroup set-parameter \
--hostgroup "hg_name" \
--name "kt_activation_keys" \
--value key_name

host
orgloc
Create a host (inheriting parameters from a host group)
hammer host create \
--name "host_name" \
--hostgroup "hg_name" \
--interface="primary=true, \
mac=mac_addr, ip=ip_addr, " \
provision=true \
--organization-id org_ID \
--location-id loc_ID \
--ask-root-password yes
job-template
Add a job template for remote execution
hammer job-template create \
--file "path" --name "template_name" \
--provider-type SSH --job-category \
"category_name"
job-invocation
Invoke a remote job
hammer job-invocation create \
--job-template "template_name" \
--inputs key1="value",... \
--search-query "query"

Monitor the remote job
hammer job-invocation output \
--id job_id --host host_name

Tasks
Subcommand Description and Tasks
task List all tasks
hammer task list

Monitor progress of a running task
hammer task progress --id task_ID

Table of Contents

No

24 Comments

It would be even helpful if it's in pdf file format.

Hi Ken,

I agree. We'll be looking to include a downloadable version as well.

Cheers.

Still no pdf?

I would love this in PDF format as well. waiting patiently....

Hi everyone,

While we have investigated a few potential methods for easily providing a PDF version of this document that is current to the latest version of the article, we do not have a formal method for doing so at current.

I will be starting a discussion with our internal tools team to see what options are available, but I am afraid that the only option at current will be to use PDF renderers such as those native to your web browser.

Let me know if you have any questions or concerns, and I would be happy to follow up.

Kind regards,

Andrew

This documentation needs to be update. The cheat sheet does not seem to be version specific. For example 6.1, 6.1.8, Beta 6.2.

The reason I bring this up is because above the following command is listed:

hammer host errata list --host

The sub command 'errata' does not exists.

[dxc31@rchsat02 satellite_reports]$ hammer host errata list --help Error: No such sub-command 'errata'

See: 'hammer host --help' [dxc31@rchsat02 satellite_reports]$ hammer host --help Usage: hammer host [OPTIONS] SUBCOMMAND [ARG] ...

Parameters: SUBCOMMAND subcommand [ARG] ... subcommand arguments

Subcommands: create Create a host delete Delete a host delete-parameter Delete parameter for a host. facts List all fact values info Show a host list List all hosts puppet-classes List all Puppet classes puppetrun Force a Puppet agent run on the host reboot Reboot a host reports List all reports sc-params List all smart class parameters set-parameter Create or update parameter for a host. start Power a host on status Get status of host stop Power a host off update Update a host

Options: -h, --help print help

Was this functionality there and taken out or planned for the future. Can it be put back in a future release?

Where should I enter a request for this funtionality or should I open a bugzilla?

RFE's can be put into bugzilla. See the link at

https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Satellite%206

Hi David, Thank you for your feedback. The article was written for Satellite 6.2 Beta, I added a subtitle to make it clear. In version 6.2, many sub-commands that were previously under "hammer content-host" moved under "hammer host". So in case you are using Satellite 6.1, "hammer content-host errata ..." should work for you.

Is there any possibility of including content-view filters to the cheat sheet? Adding individual errata to a filter in the WebUI can be painful. I'm using Satellite 6.1.9.

There's been several requests for this to become a pdf file, and also to be updated.

Dear Red Hat folks, request this be made into a pdf document after any necessary updates. Thanks

R. Hinton

There are many different types of templates in Sat6:

iPXE template
Finish template
User data template
Kexec
PXELinux template
Provisioning template

yet there are only 2 flags for templates in hammer:

--config-templates
--provisioning-templates

If I have say one custom PXE linux template and custom ks template I want to use just for one new OS definition (called RH7-pci) I am creating and I have 2 different PXE and KS templates for another OS definition I am creating (called RH7-stig) and BOTH templates are for RH7.3 how do I create these 2 OSs and tell them to use the right templates and defaults for any templates not specified? What I expected was a hammer cli more like this:

--ipxe_template <name>
--finish_template <name>
--user_data_template <name>
--kexec <name>
--pxelinux_template <name>
--provisioning_template <name>

If a template calls a snippet but that snippet isn't in the sat6 system yet does it flag it or give a warning? My guess is no.

Is there a way to list or view the packages, that are part of a published content view version? for e.g I have 1000 packages as part of version 2. I want to may be look at them on satellite server, where they reside and calculate size of them,. Is it possible?

Authentication link https://access.redhat.com/documentation/en/red-hat-satellite/6.2/paged/hammer-cli-guide/12-authentication is broken. Yields a 404.

It should be https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html/hammer_cli_guide/chap-cli_guide-introduction_to_hammer#sect-CLI_Guide-Authentication

Still no PDF

PDF file please :)

https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html/hammer_cli_guide/index

PDF of the Cheat Sheet, not the whole manual

If wanted to capture the facts (custom facts) output for a host in csv format

# hammer host list
# hammer --csv fact list --search "host=<host_fdqn>"  > /tmp/abc.csv

Are we ever going to get a PDF ?

Hi Guys,

Can someone help me with hammer command using which we can fetch information related to subscription details of the host. Example --- If want to know which licenses is associated with host(Production/Developer etc)....In web UI its little confusing

Regards, Mothilal

Hello Mothilal,

Not sure which version of Satellite you are using, in 6.4 subscription information is included in the output of hammer host info --id <host_id>.

Hope this helps, Peter

Hi Peter,

My satellite version is 6.2.12

Hello, the Hammer cheat sheet is now on the main docs page[1], and you can use the " Available Formats" menu to get a PDF version.

[1] https://access.redhat.com/documentation/en-us/red_hat_satellite/