## Appendix A. Command Line Config Management Tools¶

In addition to the options provided in the SUSE Manager website, SUSE Manager offers two command line tools for managing a system's configuration files: the Configuration Client and the Configuration Manager. There is a complementary Actions Control tool that is used to enable and disable configuration management on client systems. If you do not yet have these these tools installed, they can be found within the SUSE Manager Tools child channel for your operating system (package names are: `rhncfg-client`, `rhncfg-management`, and `rhncfg-actions`).

| Tip
Keep in mind, whenever a configuration file is deployed via SUSE Manager, a backup of the previous file including its full path is made in the `/var/lib/rhncfg/backups/` directory on the affected system. The backup retains its filename but has a `.rhn-cfg-backup` extension appended.

## A.1. Actions Control¶

The Actions Control (mgr-actions-control) application is used to enable and disable configuration management of a system. Client systems cannot be managed in this fashion by default. This tool allows SUSE Manager Administrators to enable or disable specific modes of allowable actions such as: deploying a configuration file onto the system, uploading a file from the system, diffing what is currently managed on a system and what is available, or allowing running arbitrary remote commands. These various modes are enabled/disabled by placing/removing files and directories in the `/etc/sysconfig/rhn/allowed-actions/` directory. Due to the default permissions on the `/etc/sysconfig/rhn/` directory, Actions Control will most likely have to be run by someone with root access.

### A.1.1. General command line options¶

There is a man page available, as there are for most command line tools, though the use of this tool is simple enough to describe here briefly. Simply decide what scheduled actions should be enabled for use by system administrators. The following options enable the various scheduled action modes:

Table A.1. mgr-actions-control options

Option | Description
--- | ---
--enable-deploy | Allow mgrcfg-client to deploy files.
--enable-diff | Allow mgrcfg-client to diff files.
--enable-upload | Allow mgrcfg-client to upload files.
--enable-mtime-upload | Allow mgrcfg-client to upload mtime.
--enable-all | Allow mgrcfg-client to do everything.
--enable-run | Enable script run.
--disable-deploy | Disable deployment.
--disable-diff | Disable diff
--disable-upload | Disable upload
--disable-mtime-upload | Disable mtime upload
--disable-all | Disable all options
--disable-run | Disable script run.
--report | Report whether the modes are enabled or disabled.
-f, --force | Force the operation without asking first.
-h, --help | Show help message and exit.

Once a mode is set—and for many, mgr-actions-control --enable-all is common—your system is now ready for config management through SUSE Manager.

## A.2. Configuration Client¶

As the name implies, the Configuration Client (mgrcfg-client) is installed and run from an individual client system. From there you may use it to gain knowledge about how SUSE Manager deploys configuration files to the client.

The Configuration Client offers these primary modes: list, get, channels, diff, and verify.

### A.2.1. Listing Config Files¶

To list the configuration files for the machine and the labels of the config channels containing them, issue the command:

    mgrcfg-client list

The output resembles the following list:

    Config Channel File config-channel-17 /etc/example-config.txt config-channel-17 /var/spool/aalib.rpm config-channel-14 /etc/rhn/rhn.conf

These are the configuration files that apply to your system. However, there may be duplicate files present in the other channels. For example, issue the following command:

    mgrcfg-manager list config-channel-14

and observe the following output:

    Files in config channel 'config-channel-14' /etc/example-config.txt /etc/rhn/rhn.conf

You may then wonder where the second version of `/etc/example-config.txt` went. The rank of the `/etc/example-config.txt` file in config-channel-17 was higher than that of the same file in config-channel-14. As a result, the version of the configuration file in config-channel-14 is not deployed for this system, although the file still resides in the channel. The mgrcfg-client command does not list the file because it will not be deployed on this system.

### A.2.2. Getting a Config File¶

To download the most relevant configuration file for the machine, issue the command:

    mgrcfg-client get /etc/example-config.txt

You should see output resembling:

    Deploying /etc/example-config.txt

You may then view the contents of the file with less or another pager. Note that the file is selected as the most relevant based upon the rank of the config channel containing it. This is accomplished within the Configuration tab of the System Details page. Refer to Section 3.4.2.9, “System Details” for instructions.

### A.2.3. Viewing Config Channels¶

To view the labels and names of the config channels that apply to the system, issue the command:

    mgrcfg-client channels

You should see output resembling:

    Config channels: Label Name ----- ---- config-channel-17 config chan 2 config-channel-14 config chan 1

The following table lists the options available for mgrcfg-client get:

Table A.2. mgrcfg-client get options

Option | Description
--- | ---
--topdir=TOPDIR | Make all file operations relative to this string.
-h, --help | Show help message and exit.

### A.2.4. Differentiating between Config Files¶

To view the differences between the config files deployed on the system and those stored by SUSE Manager, issue the command:

    mgrcfg-client diff

The output resembles the following:

    --- /tmp/@3603.0.rhn-cfg-tmp 2004-01-13 14:18:31.000000000 -0500
    +++ /etc/example-config.txt 2003-12-16 21:35:32.000000000 -0500
    @@ -1,3 +1,5 @@
    +additional text

In addition, you may include the `--topdir` option to compare config files with those located in an arbitrary (and unused) location on the client system, like so:

    # mgrcfg-client diff --topdir /home/test/blah/
    /usr/bin/diff: /home/test/blah/etc/example-config.txt: No such file or directory
    /usr/bin/diff: /home/test/blah/var/spool/aalib.rpm: No such file or directory

### A.2.5. Verifying Config Files¶

To quickly determine if client configuration files are different than those associated with it via SUSE Manager, issue the command:

    mgrcfg-client verify

The output resembles the following:

    modified /etc/example-config.txt /var/spool/aalib.rpm

The file `example-config.txt` is locally modified, while `aalib.rpm` is not.

The following table lists the options available for mgrcfg-client verify:

Table A.3. mgrcfg-client verify options

Option | Description
--- | ---
-v, --verbose | Increase the amount of output detail. Displays differences in the mode, owner, and group permissions for the specified config file.
-h, --help | Show help message and exit.

## A.3. Configuration Manager¶

Unlike the Configuration Client, the Configuration Manager (mgrcfg-manager) is designed to maintain SUSE Manager's central repository of config files and channels, not those located on client systems. This tool offers a command line alternative to the configuration management features within the SUSE Manager website, as well as the ability to script some or all of the related maintenance.

It is intended for use by Config Administrators and requires an SUSE Manager username and password that has the appropriate permission set. The username may be specified in `/etc/sysconfig/rhn/rhncfg-manager.conf` or in the [rhncfg-manager] section of `~/.rhncfgrc`.

When the Configuration Manager is run as root, it attempts to pull in needed configuration values from the Red Hat Update Agent. When run as a user other than root, you may have to make configuration changes within the `~/.rhncfgrc` file. The session file is cached in `~/.rhncfg-manager-session` to prevent logging in for every command.

The default timeout for the Configuration Manager is 30 minutes. To alter this, add the `server.session_lifetime` option and new value to the `/etc/rhn/rhn.conf` file on the server running the manager, like so:

    server.session_lifetime = 120

The Configuration Manager offers these primary modes: add, create-channel, diff, diff-revisions, download-channel, get, list, list-channels, remove, remove-channel, revisions, update, and upload-channel.

Each mode offers its own set of options, which can be seen by issuing the following command:

    mgrcfg-manager mode --help

Replace `mode` with the name of the mode to be inspected:

    mgrcfg-manager diff-revisions --help

You can see such a list of options for the add mode at Table A.4, “mgrcfg-manager add options”.

### A.3.1. Creating a Config Channel¶

To create a config channel for your organization, issue the command:

    mgrcfg-manager create-channel channel-label

If prompted for your SUSE Manager username and password, provide them.

Once you have created a config channel, use the remaining modes listed above to populate and maintain that channel.

### A.3.2. Adding Files to a Config Channel¶

To add a file to a config channel, specify the channel label as well as the local file to be uploaded, such as:

    mgrcfg-manager add --channel=channel-label /path/to/file

In addition to the required channel label and the path to the file, you may use the available options for modifying the file during its addition. For instance, you may alter the path and file name by including the `--dest-file` option in the command, like:

    mgrcfg-manager add --channel=channel-label--dest-file=/new/path/to/file.txt /path/to/file

The output resembles the following:

    Pushing to channel example-channel Local file >/path/to/file -> remote file /new/path/to/file.txt

The following table lists the options available for mgrcfg-manager add:

Table A.4. mgrcfg-manager add options ¶

Option | Description
--- | ---
-cCHANNEL --channel=CHANNEL | Upload files in this config channel
-dDEST_FILE --dest-file=DEST_FILE | Upload the file as this path
--delim-start=DELIM_START | Start delimiter for variable interpolation
--delim-end=DELIM_END | End delimiter for variable interpolation
-h, --help | show help message and exit

By default, the maximum file size for confiugration files is 128KB. If you need to change that value, find or create the following line in the `/etc/rhn/rhn.conf` file:

    web.maximum_config_file_size=128

Change the value from 128 to whatever limit you want in bytes.

### A.3.3. Differentiating between Latest Config Files¶

To view the differences between the config files on disk and the latest revisions in a channel, issue the command:

    mgrcfg-manager diff --channel=channel-label --dest-file=/path/to/file.txt \
    /local/path/to/file

You should see output resembling:

    /tmp/dest_path/example-config.txt /home/test/blah/hello_world.txt
    --- /tmp/dest_path/example-config.txt config_channel: example-channel revision: 1
    +++ /home/test/blah/hello_world.txt 2003-12-14 19:08:59.000000000 -0500
    @@ -1 +1 @@
    -foo
    +hello, world

The following table lists the options available for mgrcfg-manager diff:

Table A.5. mgrcfg-manager diff options

Option | Description
--- | ---
-cCHANNEL, --channel=CHANNEL | Get file(s) from this config channel
-rREVISION, --revision=REVISION | Use this revision
-dDEST_FILE, --dest-file=DEST_FILE | Upload the file as this path
-tTOPDIR, --topdir=TOPDIR | Make all files relative to this string
-h, --help | Show help message and exit

### A.3.4. Differentiating between Various Versions¶

To compare different versions of a file across channels and revisions, use the `-r` flag to indicate which revision of the file should be compared and the `-n` flag to identify the two channels to be checked. Refer to Section A.3.11, “Determining the Number of File Revisions” for related instructions. Specify only one file name here, since you are comparing the file against another version of itself. For example:

    mgrcfg-manager diff-revisions -n=channel-label1-r=1-n=channel-label2-r=1/path/to/file.txt

The output resembles the following:

    --- /tmp/dest_path/example-config.txt 2004-01-13 14:36:41 \ config channel: example-channel2 revision: 1
    --- /tmp/dest_path/example-config.txt 2004-01-13 14:42:42 \ config channel: example-channel3 revision: 1
    @@ -1 +1,20 @@
    -foo
    +blaaaaaaaaaaaaaaah
    +-----BEGIN PGP SIGNATURE-----
    +Version: GnuPG v1.0.6 (GNU/Linux)
    +Comment: For info see http://www.gnupg.org
    +
    +iD8DBQA9ZY6vse4XmfJPGwgRAsHcAJ9ud9dabUcdscdcqB8AZP7e0Fua0NmKsdhQCeOWHX
    +VsDTfen2NWdwwPaTM+S+Cow=
    +=Ltp2
    +-----END PGP SIGNATURE-----

The following table lists the options available for mgrcfg-manager diff-revisions:

Table A.6. mgrcfg-manager diff-revisions options

Option | Description
--- | ---
-cCHANNEL, --channel=CHANNEL | Use this config channel
-rREVISION, --revision=REVISION | Use this revision
-h, --help | Show help message and exit

### A.3.5. Downloading All Files in a Channel¶

To download all the files in a channel to disk, create a directory and issue the following command:

    mgrcfg-manager download-channel channel-label --topdir .

The output resembles the following:

    Copying /tmp/dest_path/example-config.txt -> \ blah2/tmp/dest_path/example-config.txt

The following table lists the options available for mgrcfg-manager download-channel:

Table A.7. mgrcfg-manager download-channel options

Option | Description
--- | ---
-tTOPDIR, --topdir=TOPDIR | Directory all the file paths are relative to. This option must be set.
-h, --help | Show help message and exit.

### A.3.6. Getting the Contents of a File¶

To direct the contents of a particular file to stdout, issue the command:

    mgrcfg-manager get --channel=channel-label \
    /tmp/dest_path/example-config.txt

You should see the contents of the file as output.

### A.3.7. Listing All Files in a Channel¶

To list all the files in a channel, issue the command:

    mgrcfg-manager list channel-label

You should see output resembling:

    Files in config channel `example-channel3': /tmp/dest_path/example-config.txt

The following table lists the options available for mgrcfg-manager get:

Table A.8. mgrcfg-manager get options

Option | Description
--- | ---
-cCHANNEL, --channel=CHANNEL | Get file(s) from this config channel
-tTOPDIR, --topdir=TOPDIR | Make all files relative to this string
-rREVISION, --revision=REVISION | Get this file revision
-h, --help | Show help message and exit

### A.3.8. Listing All Config Channels¶

To list all of your organization's configuration channels, issue the command:

    mgrcfg-manager list-channels

The output resembles the following:

    Available config channels: example-channel example-channel2 example-channel3 config-channel-14 config-channel-17

Note that this does not list `local_override` or `server_import` channels.

### A.3.9. Removing a File from a Channel¶

To remove a file from a channel, issue the command:

    mgrcfg-manager remove --channel=channel-label /tmp/dest_path/example-config.txt

If prompted for your SUSE Manager username and password, provide them.

The following table lists the options available for mgrcfg-manager remove:

Table A.9. mgrcfg-manager remove options

Option | Description
--- | ---
-cCHANNEL, --channel=CHANNEL | Remove files from this config channel
-tTOPDIR, --topdir=TOPDIR | Make all files relative to this string
-h, --help | Show help message and exit

### A.3.10. Deleting a Config Channel¶

To destroy a config channel in your organization, issue the command:

    mgrcfg-manager remove-channel channel-label

The output resembles the following:

    Removing config channel example-channel Config channel example-channel removed

### A.3.11. Determining the Number of File Revisions¶

To find out how many revisions (revisions go from 1 to N where N is an integer greater than 0) of a file/path are in a channel, issue the following command:

    mgrcfg-manager revisions channel-label /tmp/dest_path/example-config.txt

The output resembles the following:

    Analyzing files in config channel example-channel \
    /tmp/dest_path/example-config.txt: 1

### A.3.12. Updating a File in a Channel¶

To create a new revision of a file in a channel (or add the first revision to that channel if none existed before for the given path), issue the following command:

    mgrcfg-manager update \
    --channel=channel-label \
    --dest-file=/path/to/file.txt /local/path/to/file

The output resembles the following:

    Pushing to channel example-channel: Local file example-channel/tmp/dest_path/example-config.txt -> \ remote file /tmp/dest_path/example-config.txt

The following table lists the options available for mgrcfg-manager update:

Table A.10. mgrcfg-manager update options

Option | Description
--- | ---
-cCHANNEL, --channel=CHANNEL | Upload files in this config channel
-dDEST_FILE, --dest-file=DEST_FILE | Upload the file as this path
-tTOPDIR, --topdir=TOPDIR | Make all files relative to this string
--delim-start=DELIM_START | Start delimiter for variable interpolation
--delim-end=DELIM_END | End delimiter for variable interpolation
-h, --help | Show help message and exit

### A.3.13. Uploading Multiple Files at Once¶

To upload multiple files to a config channel from local disk at once, issue the command:

    mgrcfg-manager upload-channel --topdir=topdir channel-label

The output resembles the following:

    Using config channel example-channel4 Uploading /tmp/ola_world.txt from blah4/tmp/ola_world.txt

The following table lists the options available for mgrcfg-manager upload-channel:

Table A.11. mgrcfg-manager upload-channel options

Option | Description
--- | ---
-tTOPDIR, --topdir=TOPDIR | Directory all the file paths are relative to
-cCHANNEL, --channel=CHANNEL | List of channels the config info will be uploaded into. Channels delimited by ','. Example: --channel=foo,bar,baz
-h, --help | Show help message and exit