New in opsi-cli: Features You Should Know About

New in opsi-cli: Features You Should Know About

It’s been a while since we last talked about opsi-cli, the versatile command-line tool for managing opsi systems. Over the past few months, opsi-cli has received exciting updates, bringing new features and improvements to its plugins.

Let’s take a look at the highlights and see how these changes can bring valuable improvements to your daily workflows.


Package Plugin Updates

Fetch Command

The new fetch command fetches installed products from an opsi-Depotserver, saving them as .opsi packages, e.g., for further distribution to other opsi depots or for backup purposes. It is also possible to directly adjust product properties.

Examples:
  • Fetch all products: opsi-cli package fetch all

  • Fetch a specific product and interactively adjust the properties to your needs: opsi-cli package fetch product1 –properties ask

    Using --properties ask will prompt you to enter new values for product properties during the fetch process. Other options are

    • keep: Use the current defaults from the depot.
    • package: Use the defaults from the package.
Additional Options:
  1. Depot Selection: Specify the depot server to fetch packages from by using the --depot option. Default depot is opsi-Configserver if no depot is specified.
  2. Destination Directory: Use --destination-dir to define where opsi-Packages are created.
  3. Overwrite Existing Packages: Replace existing opsi-Packages with the --overwrite option.

Client-Action Plugin Updates

New opsi-script Option

The new --opsi-script option in opsi-cli client-action execute lets you execute opsi-script directly on selected clients.

Examples:
  • Direct Inline Script with Log Level:

    Simply provide your script as a string via --opsi-script, and set the desired log level for detailed results using --opsi-script-log-level (default: 4).

    opsi-cli client-action execute --opsi-script
  • Script from a File:

    You can also execute an opsi-script stored in a file by providing the file path directly to the --opsi-script option. For example, if you have a script saved as /workspace/test.opsiscript, run:

    opsi-cli client-action --clients test-client.domain.local execute --opsi-script /workspace/test.opsiscript
    

    This command will read the opsi-script content from test.opsiscript and execute it on the specified client. Using a file is helpful for longer scripts or when you want to reuse the same script.

Process-Actions

The new process-actions command in opsi-cli client-action allows processing action requests for selected clients and products.

opsi-cli client-action process-actions --help

Note

The help messages in opsi-cli now includes global and parent options at the beginning, making it easier to understand the hierarchy and options of each command. The usage section has also been updated with placeholders, helping users quickly grasp the structure and position of options and commands.

Examples:
  • Process all pending action requests for a selected client: opsi-cli client-action process-actions You can control how the action processing appears on the client using the --process-visibility option:

    • visible: The client sees a notification or progress.
    • hidden: Actions run silently in the background.

    If not specified, the client’s default visibility setting is used.

  • Dry-run capability:

    You can use the --dry-run option with the process-actions command to simulate actions before making any changes. This is useful for verifying what will happen without actually executing the requests. opsi-cli –dry-run client-action process-actions When running in dry-run mode, opsi-cli displays a warning and provides detailed messages about the simulated actions.

Additional Options:
  • Selective Processing: Specify which products or product groups to process by using options like --products or --product-groups. Exclude specific products or product groups with --exclude-products or --exclude-product-groups.

Note

When setting action requests with set-action-request, you can use the --process option to immediately process the requests after setting them. This combines both steps into a single command:

   opsi-cli client-action --clients test-client.domain.local set-action-request --products opsi-linux-client-agent --process

Use process-actions for more control, or --process with set-action-request for convenience.


With these improvements and new features, opsi-cli continues to enhance both usability and functionality. Try out the new features and let us know your feedback in our forum.

Related Posts

opsi Docker on ARM64: Cost-Efficient Solutions for Small Businesses

opsi Docker on ARM64: Cost-Efficient Solutions for Small Businesses

Build opsi Depot Servers with a Single Board Computer and external Hard Drives.

Read More
opsi-cli: Working faster with the Shell Completion

opsi-cli: Working faster with the Shell Completion

Work faster in the shell! Learn more about the shell autocompletion feature of the opsi-cli command line tool in this article.

Read More
Simplifying Remote Administration: An Introduction to JSON-RPC and opsi-cli

Simplifying Remote Administration: An Introduction to JSON-RPC and opsi-cli

Explore the world of JSON-RPC and learn more about the opsi-cli command jsonrpc. It offers a user-friendly way to execute JSON-RPC methods on an opsi server, simplifying the process of remote administration of your opsi environment.

Read More