Chapter 10 Controlling and Configuring Client Systems

You can use either the Spacewalk web interface or the spacecmd command to run command scripts on remote client systems. You can also set up configuration channels, subscribe client systems to these channels, and customize client systems by using the channels to deploy configuration files.

10.1 Running Command Scripts on Remote Client Systems by Using the Spacewalk Web Interface

Figure 10.1 Remote Command Page

To run a command on a remote client:

  1. Go to Systems and select the client system from the list.

  2. Select Details and then select the Remote Command tab.

  3. If required, change the user and group ID of the user that should run the command, the command timeout, and a command label of up to 10 characters.

  4. In the Script text box, enter the command script that you want to run. The following example runs the who command:

    #!/bin/sh
    who
  5. If required, change the schedule for the command.

  6. Click Schedule to commit the command script to run according to the schedule that you specify.

    If you have not edited the schedule and you have enabled the OSA daemon on the client, the OSA daemon usually runs the command immediately.

  7. Select Events and then select the Pending or History tab to view scheduled or completed actions. Click the summary name to display the details of the script and any output if it has already run on the client.

10.2 Running Command Scripts on Remote Client Systems by Using the spacecmd Command

To run a command on client systems, use the system_runscript command, as shown in the following example:

spacecmd {SSM:0}> system_runscript group:group3 -s 20150617T0130 -t 60 -f /root/myscript

User:       root
Group:      root
Timeout:    60 seconds
Start Time: 20150617T01:30:00

Script Contents
---------------
#!/bin/sh
yum update

Systems
-------
svr2.mydom.com
svr3.mydom.com

Is this ok [y/N]: y
INFO: Action ID: 343
INFO: Scheduled: 2 system(s)

To specify the date and time when an event should start, use the format YYYYMMDD[hhmm] with the -s option. If you do not specify a start time, Spacewalk assumes 0000 (midnight).

The -t option defines a timeout for a client to confirm that it has run a command. After this time has elapsed, Spacewalk assumes that the command has failed.

10.3 Working With Scheduled Events

To display a list of completed, failed, and pending events, use the schedule_list command:

spacecmd {SSM:0}> schedule_list
ID      Date                 C    F    P     Action
--      ----                ---  ---  ---    ------
...
343     20150617T01:30:00     0    0    2    Run an arbitrary script
...

The C, F, and P columns show the number of systems on which the event has completed, failed, or is pending. To display only completed, failed, or pending events, use the schedule_listcompleted, schedule_listfailed, or schedule_listpending commands.

To display the details of a pending event, use the schedule_details command:

spacecmd {SSM:0}> schedule_details 343
ID:        343
Action:    Run an arbitrary script
User:      swadmin
Date:      20150617T01:30:00

Completed:   0
Failed:      0
Pending:     2

Pending Systems
---------------
svr2.mydom.com
svr3.mydom.com

To cancel a pending event, use the schedule_cancel command:

spacecmd {SSM:0}> schedule_cancel 343
INFO: Canceled action 343
Canceled 1 action(s)

To re-run a failed event, use the schedule_reschedule command:

spacecmd {SSM:0}> schedule_reschedule 382
Rescheduled 1 action(s)

10.4 Working With Configuration Channels

In the same way that a software channel in Spacewalk contains packages for installation on multiple client systems, a configuration channel contains files for configuring client systems. For example, the files might contain configuration information for services, applications, or users.

10.4.1 Using Custom Information Keys

Custom information keys enable you to extract configuration information from clients.

To use a custom information key, follow these steps:

  1. Define the custom information key in Spacewalk as described in Section 10.4.2, “Defining Custom Information Keys by Using the Spacewalk Web Interface” and Section 10.4.3, “Defining Custom Information Keys by Using the spacecmd Command”.

    For example, you could define a custom information key named uptrack-uname to store the value of the Ksplice effective kernel version.

  2. Install the rhn-custom-info package on each client with which you want to use the key.

  3. Use the rhn-custom-info command to make the value of the key available in Spacewalk:

    # rhn-custom-info uptrack-uname `uptrack-uname -r`

    This command makes the value returned by uptrack-uname -r available as the value of the uptrack-uname key. You can then use the macro rhn.system.custom_info(uptrack-uname) to extract the value of uptrack-name within a configuration file.

10.4.2 Defining Custom Information Keys by Using the Spacewalk Web Interface

To define a custom information key and assign it to a system, follow these steps:

  1. Go to Systems and select Custom System Info.

  2. Click + create new key.

  3. On the Create Custom Info Key page, enter a key label (for example, asset_tag) and description, and then click Create Key.

  4. Go to Systems and click the name of the system for which you want to assign a value to the key.

  5. Select the Custom Info tab.

  6. On the Custom System Information page, click + create new value.

  7. On the Edit Custom Info Key page, select the key to which you want to assign a value.

    The page updates to display information about the key and a Value text box.

  8. Enter the key value in the Value text box and click Update Key.

    The Custom System Information page displays the key-value pairs that are associated with a system. You can modify a value by selecting the associated Edit this value link.

Note

You can also define custom information keys for a system by using the Custom Info tab of a system's Kickstart profile.

You can define as many key-value pairs for a system as you require.

10.4.3 Defining Custom Information Keys by Using the spacecmd Command

To create a custom information key, use the custominfo_createkey command as follows:

spacecmd {SSM:0}> custominfo_createkey admin_user "Email of admin contact"

To list the available custom information keys, use the custominfo_listkeys command:

spacecmd {SSM:0}> custominfo_listkeys
asset_tag
admin_user

To assign a custom information key to a system or system group, use the system_addcustomvalue:

spacecmd {SSM:0}> system_addcustomvalue asset_tag "fc01568a" svr3.mydom.com
spacecmd {SSM:0}> system_addcustomvalue admin_user "an.admin@mydom.com" group:group3

To list the custom information keys for a system or system group, use the system_listcustomvalues command:

spacecmd {SSM:0}> system_listcustomvalues svr3.mydom.com
asset_tag = fc01568a
admin_user = an.admin@mydom.com
spacecmd {SSM:0}> system_listcustomvalues group:group3
System: svr3.mydom.com

asset_tag = fc01568a
admin_user = an.admin@mydom.com

##############################

System: svr4.mydom.com

asset_tag = aa10889f
admin_user = an.admin@mydom.com

10.4.4 Working With Configuration Channels by Using the Spacewalk Web Interface

Figure 10.2 New Config Channel Page

To create a configuration channel:

  1. Go to Configuration and select Configuration Channels

  2. On the Centrally Managed Configuration Channels page, click + create new config channel.

  3. Enter a name, label, and description for the channel. The label should be a short representation of the target operating system, architecture (if appropriate), and the purpose of the channel, for example, ol6_generic_configuration.

  4. Click Create Config Channel.

  5. To add files to the configuration channel, on the New Channel page, select the Add Files tab.

    • To create a text file, directory, or symbolic link:

      1. Select the Create File tab.

      2. On the Create New Configuration File page, you can create a text file, directory, or symbolic link.

        For example, to set up a message-of-the-day file that contains configuration information about the client, you might enter the following details:

        File Type

        Select Text file.

        Filename/Path

        Enter /etc/motd.

        Ownership

        Enter root for both the user name and group. (These are the default entries.)

        File Permissions Mode

        Enter 644. (This is the default mode.)

        File Contents

        Select the file type as Shell from the drop-down list, and enter the file contents in the text field.

        For example, the following file uses macros that Spacewalk replaces with the appropriate values for the system on which the file is deployed:

        System Information
        ==================
        Client system: {|rhn.system.hostname|}
        Spacewalk SID: {|rhn.system.sid|}
        Asset tag:     {|rhn.system.custom_info(asset_tag) = 'Asset tag missing'|}
        Profile:       {|rhn.system.profile_name|}
        Description:   {|rhn.system.description|}
        IP address:    {|rhn.system.ip_address(eth0)|}
        MAC address:   {|rhn.system.net_interface.hardware_address(eth0)|}

        The custom macro rhn.system.custom_info substitutes the value of the custom system information key named asset_tag as assigned on the Custom Info tab for the system. Otherwise, it inserts the value Asset tag missing.

        See Section 10.4.2, “Defining Custom Information Keys by Using the Spacewalk Web Interface”.

        See Appendix C, Configuration File Macros.

      3. After entering the details of the file, click Create Configuration File.

    • To import files:

      1. Select the Import Files tab.

        On the Import Configuration File(s) from Another Channel page, you can import configuration files from other configuration channels.

      2. Select the check boxes of the configuration files that you want to import.

      3. Click Import Configuration File(s).

    • To upload files:

      1. Select the Upload File tab.

      2. On the Upload New Configuration File page, click Browse... and select the path of the file to upload.

      3. Select the file type: Text file or Binary file.

      4. Enter other details for the file, such as ownership and permissions, as required.

      5. Click Upload Configuration File.

10.4.5 Working With Configuration Channels by Using the spacecmd Command

To create a configuration channel, use the configchannel_create command, as shown in the following example:

spacecmd {SSM:0}> configchannel_create
Name: Oracle Linux 6 Server Configuration
Label: ol6-server-config
Description: Generic configuration channel for Oracle Linux 6 servers

To add a configuration file to a channel, use the configchannel_addfile command:

spacecmd {SSM:0}> configchannel_addfile ol6-server-config
Path: /etc/motd
Symlink [y/N]: N
Directory [y/N]: N
Owner [root]: [Enter]
Group [root]: [Enter]
Mode [0644]: [Enter]
SELinux Context [None]: [Enter]
Revision [next]: [Enter]
Read an existing file [y/N]: y
File: /var/config_file_templates/ol6-server/etc/motd
Path:            /etc/motd
Directory:       False
Owner:           root
Group:           root
Mode:            0644
SELinux Context: 

Contents
--------
System Information
==================
Client system: {|rhn.system.hostname|}
Spacewalk SID: {|rhn.system.sid|}
Asset tag:     {|rhn.system.custom_info(asset_tag) = 'Asset tag missing'|}
Profile:       {|rhn.system.profile_name|}
Description:   {|rhn.system.description|}
IP address:    {|rhn.system.ip_address(eth0)|}
MAC address:   {|rhn.system.net_interface.hardware_address(eth0)|}

Is this ok [y/N]: y

The custom macro rhn.system.custom_info substitutes the value of the custom system information key named asset_tag as assigned on the Custom Info tab for the system. Otherwise, it inserts the value Asset tag missing.

See Section 10.4.3, “Defining Custom Information Keys by Using the spacecmd Command”.

See Appendix C, Configuration File Macros.

To display the details of a configuration channel, use the configchannel_details command:

spacecmd {SSM:0}> configchannel_details ol6-server-config
Label:       ol6-server-config
Name:        Oracle Linux 6 Server Configuration
Description: Configuration channel for generic Oracle Linux 6 servers

Files
-----
/etc/motd

10.4.6 Subscribing Client Systems to Configuration Channels by Using the Spacewalk Web Interface

To subscribe a client system to a configuration channel:

  1. Go to Systems and click the system name.

  2. Select the Configuration tab, then the Manage Configuration Channels tab, and finally the Subscribe to Channels tab.

  3. For Step 1: Select Channels for Subscription page, select the check boxes for the channels to which you want to subscribe the system and click Continue.

  4. For Step 2: Rank Channels for Subscription page, you can optionally change the order of the configuration channels according to priority. Higher-rank entries override lower-rank entries if several entries can modify the same files or directories.

  5. To save your changes, click Update Channel Rankings.

See Section 10.4.8, “Deploying Configuration Files to Client Systems by Using the Spacewalk Web Interface”.

10.4.7 Subscribing Client Systems to Configuration Channels by Using the spacecmd Command

To list the available configuration channels, use the configchannel_list command as follows:

spacecmd {SSM:0}> configchannel_list
ol6-dns-server-config
ol6-http-server-config
ol6-nfs-server-config
ol6-server-config

To subscribe a system or system group to a configuration channel, use the system_addconfigchannels command:

spacecmd {SSM:0}> system_addconfigchannels svr3.mydom.com ol6-nfs-server-config -t
spacecmd {SSM:0}> system_addconfigchannels group:group3 ol6-server-config -b

To list the configuration channels to which a system or system group is subscribed, use the system_listconfigchannels command:

spacecmd {SSM:0}> system_listconfigchannels group:group3
System: svr3.mydom.com
ol6-nfs-server-config
ol6-server-config

##############################

System: svr4.mydom.com
ol6-server-config

To edit the configuration channels for a system, you can use the system_setconfigchannelorder command as follows:

spacecmd {SSM:0}> system_setconfigchannelorder svr1.mydom.com
Current Selections
------------------
1. ol6-server-config

a[dd], r[emove], c[lear], d[one]: a

Available Configuration Channels
--------------------------------
ol6-dns-server-config
ol6-http-server-config
ol6-nfs-server-config
ol6-server-config

Channel: ol6-dns-server-config
New Rank: 1

Current Selections
------------------
1. ol6-dns-server-config
2. ol6-server-config

a[dd], r[emove], c[lear], d[one]: d

To unsubscribe a system from a configuration channel, use the system_removeconfigchannels command:

spacecmd {SSM:0}> system_removeconfigchannels svr3.mydom.com ol6-server-config

10.4.8 Deploying Configuration Files to Client Systems by Using the Spacewalk Web Interface

Note

You must have previously subscribed the system to the appropriate configuration channel for the configuration files that you want to deploy. See Section 10.4.6, “Subscribing Client Systems to Configuration Channels by Using the Spacewalk Web Interface”.

The first deployment to a client system can fail if the /var/log/rhncfg-actions log file does not exist on the client. If the deployment fails, the log file is created automatically, and you can reschedule the deployment event. Alternatively, run the following command on the client system before deploying any files to it:

# touch /var/log/rhncfg-actions

Oracle recommends using configuration files to deploy SSL and GPG certificates to Spacewalk clients that were not previously provisioned by the Spacewalk server.

Figure 10.3 Deploy Files Page

To deploy a configuration file to a client system:

  1. Go to Systems and click the system name.

  2. Select the Configuration tab and then the Deploy Files tab.

  3. On the Deploy Files page, select the check boxes for the files that you want to deploy, and click Deploy Files.

  4. On the Confirm Deploy Files page, change the schedule if required, and click Schedule Deploy.

  5. Select Events and then select the Pending or History tab to view scheduled or completed actions. Click the summary name to display the details of the deployment event.

10.4.9 Deploying Configuration Files to Client Systems by Using the spacecmd Command

Note

You must have previously subscribed the system to the appropriate configuration channel for the configuration files that you want to deploy. See Section 10.4.7, “Subscribing Client Systems to Configuration Channels by Using the spacecmd Command”.

The first deployment to a client system can fail if the /var/log/rhncfg-actions log file does not exist on the client. If the deployment fails, the log file is created automatically, and you can reschedule the deployment event. Alternatively, run the following command on the client system before deploying any files to it:

# touch /var/log/rhncfg-actions

To deploy all configuration files to a system or system group, use the system_deployconfigfiles command:

spacecmd {SSM:0}> system_deployconfigfiles group:group3
Systems
-------
svr3.mydom.com
svr4.mydom.com

Deploy ALL configuration files to these systems [y/N]: y
INFO: Scheduled deployment for 2 system(s)

To display the details of a pending deployment event, use the schedule_details command.

See Section 10.3, “Working With Scheduled Events”.