Sun Update Connection - Enterprise 1.0 User's Guide

Macros

A macro is a short script that outputs a single line. This output replaces a macro sign in a local Configuration file.

The macro value is used to customize a Configuration file for its host machine. You create a job that installs a Configuration file on multiple hosts.

This Configuration file has <^AM^>macro<^AM^> in its content, where macro is the name of the macro in the knowledge base.

Each Agent sees the <^AM^> sign and runs the named macro script. The result of the macro run is a line of local data. The value of the macro is entered in place of the macro sign.


Example 5–9 Using Macros

You are reorganizing your network servers. You will be reconfiguring the /etc/hosts file for multiple hosts, perhaps several times. Instead of changing this file for every host every time, you create versions of this file and upload them as Configuration files. In each version, you replace the specific local host name with: <^AM^>hostname<^AM^>

You create a script named hosname.sh:

#!/bin/sh -f
# find local host name
hostname

You upload hostname.sh as a macro called hostname to the local knowledge base. You send the Configuration file as part of a job. Each agent that receives the file, gets the macro sign, downloads the hostname macro, and executes hostname.sh, which replaces <^AM^>hostname<^AM^> with the real local host name on each host.