Command Line Tools
This chapter provides an overview of essential command line tools for OPSI administration, arranged in alphabetical order for easy reference. The most important tool is the OPSI-CLI, which includes the functionality of almost all command-line tools (see OPSI-CLI). It can also be used outside the OPSI server.
opsi-admin
The opsi-admin command line tool allows you to interact with the OPSI API. It offers both an interactive mode (-i) and a non-interactive mode, suitable for scripting purposes.
Please also refer to the section on OPSI-CLI regarding opsi-cli. This tool is newer, more robust, and versatile, providing functionalities similar to opsi-admin. Since version 4.2.0.187, opsi-cli has been included in the opsi-utils package and is available on Linux, Windows, and macOS.
|
When using opsi-admin to access the OPSI API, specify the service URL (--address), a username (--username), and the corresponding password (--password). If you don’t provide a service URL, opsi-admin defaults to the one specified in /etc/opsi/opsi.conf. If the username and password are not included in the command, authentication will occur using the host ID and the cost key from /etc/opsi/opsi.conf.
| You can store the access data in a personal configuration file (see section Configuration File). |
opsi-admin -i to start the tool in interactive mode.When you launch opsi-admin with the -c parameter, it enables a color-coded display. The complete command for this mode is opsi-admin -ic. While in interactive mode, you can use the [Tab] key for autocompletion of commands. Additionally, opsi-admin maintains a history of previously entered commands, which you can navigate through using the arrow keys.
For script-friendly output, opsi-admin offers -s (shell output) and -S (simple output).
To execute RPC methods of the API, use the command method <method_name>. For executing more complex administrative tasks, the command task <taskname> is appropriate. For further examples and detailed usage of opsi-admin, please refer to the section Examples.
Configuration File
You can save your access credentials for the OPSI web service in a configuration file. This setup allows you to establish a connection without having to input your username and password every time you use the command line.
The file is named opsirc and is located in the hidden folder ~/.opsi.org in the user’s home directory. The structure of this file is as follows:
address = https://<opsi-server>:4447/rpc
username = <opsi-user>
password = <secret>
The information within the opsirc file is entirely optional. If the file is either empty or doesn’t exist, opsi-admin will revert to using the default settings as previously mentioned.
The --opsirc parameter allows you to specify an alternative path to a different configuration file when executing the command. This feature enables you to prepare and use multiple configurations for various connections.
|
OPSI-CLI
Please find the documentation for OPSI-CLI at OPSI-CLI.
opsi-makepackage
Utilize the opsi-makepackage command to create an OPSI package with the .opsi extension from a package source (workbench). First, navigate to the source directory and then execute the command opsi-makepackage.
opsi-makepackage includes several options that modify its behavior.
To view a list of available parameters and their meanings, you can use opsi-makepackage --help.
| You can install an OPSI package on any OPSI depot server using the command opsi-package-manager. |
opsi-outdated-to-setup
You can use the command line tool opsi-outdated-to-setup to set action requests for clients that have localboot products for which a newer version is available in the depot.
opsi-outdated-to-setup --help
usage: opsi-outdated-to-setup [-h] [--version] [--log-level {0,1,2,3,4,5,6,7,8,9}] [--clients CLIENTS] [--dry-run]
[--client-groups CLIENT_GROUPS] [--exclude-products EXCLUDE_PRODUCTS]
[--include-products INCLUDE_PRODUCTS] [--add-failed] [--uninstall-where-only-uninstall]
[--exclude-client-groups EXCLUDE_CLIENT_GROUPS] [--include-product-groups INCLUDE_PRODUCT_GROUPS]
[--exclude-product-groups EXCLUDE_PRODUCT_GROUPS] [--setup-on-action SETUP_ON_ACTION]
Set outdated localboot Products to setup.
[…]
You can also use opsi-outdated-to-setup to set action requests for repeating failed installations by using the --add-failed option.
The parameters --exclude-products, --include-products, --exclude-product-groups, and --include-product-groups allow for more precise definition of the products. Similarly, you can specify the clients more accurately using --clients, --client-groups, and --exclude-client-groups.
The --uninstall-where-only-uninstall option is used to set all installed products to uninstall if they have no registered script (like setup, always, etc.) other than the uninstall script.
Employ the --dry-run parameter to initiate a trial run without making any actual changes.
|
The --setup-on-action is a unique option that enables setting a product to setup on all clients where any change has occurred (i.e., clients that do not have the current package installed). This is particularly useful in scenarios like using shutdownwanted for a shutdown post-installation, or with waudit to refresh the audit data.
opsi-package-manager
Use the opsi-package-manager tool to install and uninstall product packages on an OPSI depot server.
To install a package, it must be readable by the user opsiconfd (refer to the chapter Authorizations for more details). It is recommended to store product packages in /var/lib/opsi.
|
How to install an OPSI package:
opsi-package-manager -i <opsi-package>
To install an OPSI package and interactively set the default values for product properties:
opsi-package-manager -p ask -i <opsi-package>
To install an OPSI package and set it to setup for all clients where it is installed:
opsi-package-manager -S -i <opsi-package>
To install an OPSI package and set it to setup for all clients on which it is installed, including the packages that depend on it:
opsi-package-manager -s -i <opsi-package>
To uninstall an OPSI package:
opsi-package-manager -r <opsi-package>
opsi-package-manager -x <opsi-package> --new-product-id <product-id>
For an overview of all options, use opsi-package-manager --help.
opsi-package-updater
The command line tool opsi-package-updater is designed for downloading OPSI products from one or more repositories and installing them on the OPSI depot server. Its primary function is to automate the updating of OPSI packages on a scheduled basis, e.g. through a cronjob.
| Repositories are defined as sources providing OPSI packages for download. You can configure each repository individually, customizing access and behavior. |
To access the online help, enter the command opsi-package-updater --help:
opsi-package-updater --help
usage: opsi-package-updater [-h] [--version] [--config CONFIGFILE]
[--verbose | --log-level {0,1,2,3,4,5,6,7,8,9}]
[--force-checksum-calculation] [--repo repository_name]
[--use-inactive-repository] [--ignore-errors] [--no-zsync]
{install,update,download,list} ...
Updater for local OPSI products. Operates in different MODEs: install, update, download and list. Each
mode has their own options that can be viewed with MODE -h
[…]
The --repo parameter allows you to limit operations to a specific repository.
opsi-package-updater supports the following commands:
-
list: Displays a list of available repositories or OPSI packages. -
download: Downloads OPSI packages from a repository. -
install: Downloads and installs OPSI packages from a repository. -
update: Updates locally installed OPSI packages from the repositories.
Each command has its own detailed help information, which you can access by entering opsi-package-updater <command> --help.
To get more detailed output, use the -v (verbose) parameter. This switch can be used multiple times for increased verbosity (-vvv, -vvvv, etc.).
|
Examples
To display the activated repositories:
opsi-package-updater list --active-repos
To list the packages available in the repositories (this ignores configured includes/excludes):
opsi-package-updater list --products
To install the package ubuntu from the repository uib_linux, with -vv providing a very detailed output:
opsi-package-updater -vv --repo uib_linux install ubuntu
To download and install all packages available in the activated repositories:
opsi-package-updater install
To display the available updates (this takes into account configured includes/excludes):
opsi-package-updater list --updatable-products
To update the locally installed packages firefox and javavm from the repositories; -vv produces detailed output:
opsi-package-updater -vv update firefox javavm
Repositories
The general settings for the opsi-package-updater are located in the file /etc/opsi/opsi-package-updater.conf. This file includes various sections that specify settings such as the location of the OPSI packages (packageDir), the name of the logfile (logFile), and the directory for the repositories (repositoryConfigDir). Additionally, settings for e-mail notifications and Wake on LAN (WoL) for clients are also configured here.
The configuration files for individual repositories are located in the directory /etc/opsi/package-updater.repos.d/. Within this directory, you’ll find a commented template (file example.repo.template) that lists and explains all the available options.
There are two types of repositories that can be configured: internet repositories and OPSI server repositories.
Internet Repositories
Internet repositories are defined by the following parameters:
-
baseURL: This is the URL of the repository, for example,http://opsipackages.43.opsi.org/stable. -
dirs: A comma-separated list of directories within the repository, such asopsi4.3/products/localboot, opsi4.3/products/netboot. -
usernameandpassword: These are used for repositories that require authentication. -
authcertfileandauthkeyfile: These parameters are for certificate-based authentication. -
verifyCert: This option enables or disables the verification of the server certificate for HTTPS connections. -
excludes: Regular expression specifying package names that should not be handled, for example, ^test.* will exclude anything that starts with "test". -
proxy: This is used to specify a proxy server.
You can set up a proxy server for each individual repository using the proxy option. Alternatively, the proxy server details can be entered in the global configuration file /etc/opsi/opsi-package-updater.conf.
|
OPSI Server Repositories
If you specify the host ID of another OPSI server following opsiDepotId in the repository configuration file, it defines an OPSI server repository. For an OPSI depot server, the central OPSI config server is located at this address. This setup indicates that the depot server acquires packages from the /var/lib/opsi/repository repository on the config server.
Repository Behavior
You can configure specific behaviors for each repository:
-
autoupdate: Automatically downloads and installs more recent versions of already installed packages. -
autoinstall: Automatically downloads and installs available packages that are not yet installed locally. -
autosetup: Sets newly installed and updated packages tosetupfor all clients on which these packages are installed. -
onlyDownload: Only downloads new packages without installing them. -
ignoreErrors: Continues the process even if errors occur with individual packages, preventing the termination of the entire operation.
The onlyDownload option is frequently used in combination with activated notifications. This setup enables automatic email notification after new packages are downloaded, allowing an administrator to oversee the actual installation.
|
Install standard products
To install the OPSI standard products from the uib repositories, use the following command:
opsi-package-updater -v install
The command updates all existing OPSI packages including the templates for operating system installations from the OPSI repositories.
| If you’re using the preconfigured virtual machine, you can simply double-click the desktop icon to install the standard products. |
opsi-setup
Before the release of OPSI 4.3, the opsi-setup tool played a central role in executing various configuration tasks on the OPSI server.
| With OPSI 4.3, many of these tasks have been automated. Other functionalities are now managed by opsiconfd setup. |
opsi-set-rights
The command opsi-set-rights, which is essentially a script executing opsi-setup --set-rights, is used to correct the access rights of files and directories on an OPSI server. When invoked without additional parameters, opsi-set-rights automatically adjusts the permissions for all files and directories relevant for opsi. Alternatively, you can specify a path when executing the command to modify the access rights of a specific directory only.
opsi-wakeup-clients
On the OPSI config server, you can use cronjobs to schedule product installations and updates, allowing you to, for instance, shift critical administrative tasks to nighttime hours. For this to be effective, clients must either support Wake on LAN (WOL) or have a wake-up function in the BIOS that automatically powers the computer on from sleep or energy-saving mode at a pre-set time.
To facilitate this process, the command line tool opsi-wakeup-clients (previously known as wake_clients_for_setup.py) is available.
Almost all parameters of wake_clients_for_setup.py have been retained in opsi-wakeup-clients. The only change is the renaming of the parameter --depotId to --depot-id.
|
To access the online help, use the command opsi-wakeup-clients --help:
opsi-wakeup-clients --help
usage: opsi-wakeup-clients [-h] [--version] [--verbose] [--log-file LOGFILE]
[--log-level {0,1,2,3,4,5,6,7,8,9}] [--wol-timeout WOLTIMEOUT]
[--ping-timeout PINGTIMEOUT] [--connect-timeout CONNECTTIMEOUT]
[--event-timeout EVENTTIMEOUT] [--reboot-timeout REBOOTTIMEOUT]
[--host-group-id HOSTGROUPID] [--depot-id DEPOTID] [--host-file INPUTFILE]
[--product-group-id PRODUCTGROUPID] [--event EVENTNAME] [--reboot]
[--shutdownwanted] [--no-auto-update] [--max-concurrent MAXCONCURRENT]
Wakeup clients for software installation.
[…]
opsi-wakeup-clients primarily carries out the following tasks:
-
For a specified group of clients, it sets
-
a certain group of products to the
setupstatus. -
It then activates the chosen clients using Wake on LAN.
If a client is only woken up but not fully started, opsi-wakeup-clients has the capability to send a signal to trigger a specific event.
The clients to be selected are identified in several ways:
-
Specify a host group that you have created, for example, using
opsi-configed(refer to the section Grouping Clients):
--host-group-id <HOSTGROUPID>
-
Define an OPSI depot, which automatically selects all clients associated with that depot:
--depot-Id <DEPOTID>
-
Specify a file that lists the desired clients:
--host-file <DATEI>
-
To set multiple products to
setup, you can specify a product group that you have previously created usingopsi-configed. For more information on this, see the section Managing Product Groups.
--product-group-id <PRODUCTGROUPID>
-
Finally, enter the event that you want to trigger; the parameter
--eventis used for this:
--event <EVENTNAME>
In opsi, the names of groups must be unique. This applies to both host groups (located in the Directory or Groups areas in opsi-configed) and product groups.
|
The following example illustrates how to set the products from the product group nightly-cron-products to setup for all clients in the host group nightly-cron-group-0:
opsi-wakeup-clients --event=gui_startup --product-group-id=nightly-cron-products --host-group-id=nightly-cron-group-0
The clients are then awakened via Wake on LAN, and after a brief pause, the command is issued to execute the gui_startup event.
Setting up the Cronjob
To schedule the operation at a specific time each day, you need to enter the command in the server’s crontab. To do this, run the command crontab -e as the root user. In the standard editor that opens, you can enter the following:
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
# Cronjobs zum Wecken und Installieren der PCs
5 0 * * * /usr/bin/opsi-wakeup-clients --log-level=5 --event=gui_startup --product-group-id=nightly-cron-prodcts --host-group-id=nightly-cron-group-1 --wol-timeout=120 --event-timeout=120
5 2 * * * /usr/bin/opsi-wakeup-clients --log-level=5 --event=gui_startup --product-group-id=nightly-cron-products --host-group-id=nightly-cron-group-2 --wol-timeout=120 --event-timeout=120
The command opsi-wakeup-clients is scheduled to run at 0:05 for the client group nightly-cron-group-1 and again at 2:05 for the client group nightly-cron-group-2.
When setting up such automation, it is important to ensure that installations do not inadvertently occur outside of the designated "maintenance window". This can be prevented by configuring the Working Window in the opsi-client-agent settings.
|