Actions

You can manage actions on your clients in a number of different ways.

For Salt clients, you can schedule automated recurring actions to apply the highstate to clients on a specified schedule. You can apply recurring actions to individual clients, to all clients in a system group, or to an entire organization.

On both Salt and traditional clients, you can set actions to be performed in a particular order by creating action chains. Action chains can be created and edited ahead of time, and scheduled to run at a time that suits you.

You can also perform remote commands on one or more of your Salt clients. Remote commands allows you to issue commands to individual Salt clients, or to all clients that match a search term.

Recurring Actions

You can apply recurring actions on individual Salt clients, or to all clients in an organization.

Procedure: Creating a New Recurring Action
  1. To apply a recurring action to an individual client, navigate to Systems, click the client to configure schedules for, and navigate to the States  Recurring States tab.

  2. To apply a recurring action to a system group, navigate to Systems  System Groups, select the group to configure schedules for, and navigate to States  Recurring States tab.

  3. Click Create.

  4. Type a name for the new schedule.

  5. Choose the frequency of the recurring action:

    • Hourly: Type the minute of each hour. For example, 15 will run the action at fifteen minutes past every hour.

    • Daily: Select the time of each day. For example, 01:00 will run the action at 0100 every day, in the timezone of the Uyuni Server.

    • Weekly: Select the day of the week and the time of the day, to execute the action every week at the specified time.

    • Monthly: Select the day of the month and the time of the day, to execute the action every month at the specified time.

    • Custom Quartz format: For more detailed options, enter a custom quartz string. For example, to run a recurring action at 0215 every Saturday of every month, enter:

      0 15 2 ? * 7
  6. OPTIONAL: Toggle the Test mode switch on to run the schedule in test mode.

  7. Click Create Schedule to save, and see the complete list of existing schedules.

Organization Administrators can set and edit recurring actions for all clients in the organization. Navigate to Home  My Organization  Recurring States to see all recurring actions that apply to the entire organization.

Uyuni Administrators can set and edit recurring actions for all clients in all organizations. Navigate to Admin  Organizations, select the organization to manage, and navigate to the States  Recurring States tab.

Recurring actions can only be used with Salt clients. Traditional clients in your group or organization are ignored.

Action Chains

If you need to perform a number of sequential actions on your clients, you can create an action chain to ensure the order is respected.

By default, most clients will execute an action as soon as the command is issued. In some case, actions will take a long time, which could mean that actions issued afterwards fail. For example, if you instruct a client to reboot, then issue a second command, the second action could fail because the reboot is still occurring. To ensure that actions occur in the correct order, use action chains.

You can use action chains on both traditional and Salt clients. Action chains can include any number of these actions, in any order:

  • System Details  Remote Command

  • System Details  Schedule System Reboot

  • System Details  States  Highstate

  • System Details  Software  Packages  List/Remove

  • System Details  Software  Packages  Install

  • System Details  Software  Packages  Upgrade

  • System Details  Software  Patches

  • System Details  Software  Software Channels

  • System Details  Configuration

  • Images  Build

Procedure: Creating a New Action Chain
  1. In the Uyuni Web UI, navigate to the first action you want to perform in the action chain. For example, navigate to System Details for a client, and click Schedule System Reboot.

  2. Check the Add to field and select new action chain.

  3. Confirm the action. This will not perform the action immediately, it will instead create the new action chain, and a blue bar confirming this appears at the top of the screen.

  4. Continue adding actions to your action chain by checking the Add to field and selecting the name of the action chain to add them to.

  5. When you have finished adding actions, navigate to Schedule  Action Chains and selecting the action chain from the list.

  6. Re-order actions by dragging them and dropping them into the correct position. Click the blue plus sign to see the clients an action will be performed on. Click Save to save your changes.

  7. Schedule a time for your action chain to run, and click Save and Schedule. If you leave the page without clicking either Save or Save and Schedule all unsaved changes will be discarded.

If one action in an action chain fails, the action chain stops, and no further actions are executed.

You can see scheduled actions from action chains by navigating to Schedule  Pending Actions.

Remote Commands

You can configure clients to run commands remotely. This allows you to issue scripts or individual commands to a client, without having access to the client directly.

This feature is automatically enabled on Salt clients, and you do not need to perform any further configuration. For traditional clients, the feature is enabled if you have registered the client using a bootstrap script and have enabled remote commands. You can use this procedure to enable it manually, instead.

Before you begin, ensure your client is subscribed to the appropriate tools child channel for its installed operating system. For more information about subscribing to software channels, see client-configuration:channels.adoc.

Procedure: Configuring Traditional Clients to Accept Remote Commands
  1. On the client, at the command prompt, use the package manager to install the rhncfg, rhncfg-client, and rhncfg-actions packages, if not already installed. For example:

    zypper in rhncfg rhncfg-client rhncfg-actions
  2. On the client, at the command prompt, as root, create a path in the local configuration directory:

    mkdir -p /etc/sysconfig/rhn/allowed-actions/script
  3. Create an empty file called run in the new directory. This file grants the Uyuni Server permission to run remote commands:

    touch /etc/sysconfig/rhn/allowed-actions/script/run

For Salt clients, remote commands are run from the /tmp/ directory on the client. To ensure that remote commands work accurately, do not mount /tmp with the noexec option.

All commands run from the Remote Commands page are executed as root on clients. Wildcards can be used to run commands across any number of systems. Always take extra care to check your commands before issuing them.

Procedure: Running Remote Commands on Traditional Clients
  1. In the Uyuni Web UI, navigate to Systems, click the client to run a remote command on, and navigate to the Details  Remote Command tab.

  2. In the Run as user field, type the user ID (UID) of the user on the client that you want to run the command. Alternatively, you can specify a group to run the command, using the group ID (GID) in the Run as group field.

  3. OPTIONAL: In the Timeout field, type a timeout period for the command, in seconds. If the command is not executed within this period, it will not be run.

  4. In the Command label field, type a name for your command.

  5. In the Script field, type the command or script to execute.

  6. Select a date and time to execute the command, or add the remote command to an action chain.

  7. Click Schedule to schedule the remote command.

For more information about action chains, see reference:schedule/action-chains.adoc.

Procedure: Running Remote Commands on Salt Clients
  1. Navigate to Salt  Remote Commands.

  2. In the first field, before the @ symbol, type the command you want to issue.

  3. In the second field, after the @ symbol, type the client you want to issue the command on. You can type the minion-id of an individual client, or you can use wildcards to target a range of clients.

  4. Click Find targets to check which clients you have targeted, and confirm that you have used the correct details.

  5. Click Run command to issue the command to the target clients.