You can use Fleet Patching and Provisioning user actions to perform many tasks, such as installing and configuring any type of software and running scripts.
Deploying a Web Server
The following procedure demonstrates automated deployment of Apache Web Server using Fleet Patching and Provisioning:
- Create a script to install Apache Web server, as follows:
- On the Fleet Patching and Provisioning Server, download and extract the Apache Web server installation kit.
- Create the script to install, configure, and start the Apache Web server.
- Register the script as a user action with Fleet Patching and Provisioning by running the following command on the Fleet Patching and Provisioning Server:
rhpctl useraction -useraction apachestart -actionscript /user1/useractions/apacheinstall.sh -post -optype ADD_WORKINGCOPY -onerror ABORT
The preceding command adds the
apachestartuser action for the action script stored in the specified directory. As per the specified properties, the user action runs after the
ADD_WORKINGCOPYoperation and aborts if there is any error.
- Create an image type and associate the user action with the image type, as follows:
rhpctl add imagetype -imagetype apachetype -basetype SOFTWARE -useraction "apachestart"
The preceding command creates a new image type called
apachetype, a derivative of the basic image type,
SOFTWARE, with an associated user action
- Create a gold image of the image type, as follows:
rhpctl import image -image apacheinstall -path /user1/apache2219_kit/ -imagetype apachetype
The preceding command creates a gold image,
apacheinstall, with the script for Apache Web server installation, in the specified path, based on the
imagetypeyou created earlier.
To view the properties of this image, run the
rhpctl query image -image apacheinstallcommand.
- Deploy a working copy of the gold image on the target, as follows:
rhpctl add workingcopy -workingcopy apachecopy -image apacheinstall -path /user1/apacheinstallloc -sudouser user1 -sudopath /usr/local/bin/sudo -node node1 -user user1 -useractiondata "/user1/apachehome:1080:2.2.19"
Fleet Patching and Provisioning provisions the software to the target and runs the
apachestartscript specified in the user action. You can provide the Apache Web server configuration details such as port number with the
useractiondataoption. If the target is a Fleet Patching and Provisioning Client, then you need not specify
Registering Multiple Scripts Using a Single User Action
Run multiple scripts as part of a user action plug-in by registering a wrapper script and bundled custom scripts. The wrapper script extracts the bundled scripts, which are copied under the directory of the wrapper script, and then runs those extracted scripts as necessary, similar to the following procedure:
- The following command creates a user action called
ohadd_ua, and associates a wrapper script,
wc_add.sh, with a zip file containing other scripts:
rhpctl add useraction -useraction ohadd_ua -actionscript /scratch/crsusr/wc_add.sh -actionfile /scratch/crsusr/pack.zip -pre -runscope ALLNODES -optype ADD_WORKINGCOPY
The wrapper script,
wc_add.sh, extracts the
pack.zipfile into the script path, a temporary path to which the user action scripts are copied. The wrapper script can invoke any scripts contained in the file.
- The following command creates an image type,
sw_ua, for the
rhpctl add imagetype -imagetype sw_ua -useractions ohadd_ua -basetype SOFTWARE
- The following command creates an image called
swimguafrom the software specified in the path:
rhpctl import image -image swimgua -path /tmp/custom_sw -imagetype sw_ua
- The following command adds a working copy called
wcuaand runs the
rhpctl add workingcopy -workingcopy wcua -image swimgua -client targetcluster