hammer – Administration of Foreman on the command line

Foreman is a lifecycle management tool for physical and virtual servers. Foreman can be administered from the command line with the hammer command.

Foreman is usually administered via the graphical interface. In the newer versions, hammer, a command line tool, is available with which many tasks can also be implemented.

Unfortunately, the documentation for the command is still a bit short; you can get a description with the hammer –help command.

The general syntax of the command looks like this:

hammer [optionen] unterkommando [parameter] ...

A description is available for each subcommand with the -h option. This continues. To see the subcommand options for creating a user, use the following command:

hammer user create -h

Since the hammer command is used for administrative work, you must authenticate yourself accordingly. The two options -u (username) and -p (password) can be passed for this purpose. In this case, the order is important: The authentication options must be listed before all other options.

You can get the list of all existing users with the following command. Authentication takes place as user admin with the password linux:

# hammer -u admin -p linux user list
---|----------|--------------|-------------------------
ID | LOGIN    | NAME         | EMAIL
---|----------|--------------|-------------------------
3  | admin    | Admin User   | root@example.com
5  | jexample | John Example | john.example@example.com
4  | tux      | Tux Pinguin  | tux@example.com
---|----------|--------------|-------------------------

To configure the hammer command, the .hammer directory can be created in a user’s home directory. The file foreman.yml can be created in the subdirectory cli.modules.d, in which the configuration parameters are entered. The following example defines the username (admin) and password (linux) for calling hammer:

:foreman:
  # Credentials. You'll be asked for the interactively if you leave them blank  # here
  :username: 'admin'
  :password: 'linux'

Since both the .hammer directory and the files in it only have read permission for the owner, the risk of the password in plain text is relatively low. If the password is to be requested every time, the entry is left blank:

:foreman:
  # Credentials. You'll be asked for the interactively if you leave them blank
here
  :username: admin
  :password:

In einem weiteren Artikel zu Foreman erfahren Sie, was mit der Foreman REST API alles möglich ist. Hier geht es weiter:
Was kann man mit der Foreman REST API eigentlich alles machen?
The following two tabs change content below.

atixadmin

Latest posts by atixadmin (see all)