Standardizing and Automating Your ZENworks Linux Management Installations
Installing ZENworks Linux Management on a regular basis?
Need to quickly duplicate your ZENworks Linux Management environment structure?
Then this article is for you.
Your Challenges
Many Consultants will often need to re-install ZENworks Linux Management for different customers, for test environments, etc.
To guarantee your installations provide a consistent quality and approach, you could use the ZLMAN command line tool to set up most of your ZENworks Linux Management environment. Consistently and fast!
But also customers that do not keep a full test environment available at all times can benefit from this approach, as it allows them to quickly add a new test environment.
The ZLMAN Command
The ZLMAN command available with ZENworks Linux Management is quite powerful. If you take the time to get comfortable with its use, you could benefit during installations.
As I use it mainly to provide patch management to customers, this is what the examples in this document are tailored to.
With ZLMAN you can accomplish many tasks, including:
- Adding the license
- Creating Bundle Folders
- Creating Bundle Groups
- Creating Server Folders
- Creating Server Groups
- Associate Bundle Groups to Server Groups or Folders
- Create Registration Rules
- Create Policies
- etc.
Just try it, use
zlman --help
to see what options are available.
In general, the syntax is as follows:
zlman -U Administrator -P MyP@ssw0rd command options
As you can see, using ZLMAN gives you a ton of options that can help you to automate many of the tasks you need to perform on a regular basis.
Using Scripts
In the article ZENworks Linux Management – Advanced Patching I have already introduced many scripts that were used to automate the Patch Management portion of ZLM, by using categories and staging environments.
Some of these scripts are mentioned here as well.
Doing more with Scripts
Since you will most likely be using many similar commands and parameters for different scripts, it is best to use a separate configuration file and source into all of your scripts.
For example, the file zlmsettings.conf could contain the following settings:
# Admin Settings ZLMpass=MyP@ssw0rd ZLMuser=administrator etc.
Your script that needs to reference these settings or variables would reference the configuration file and then use the variables as follows:
#!/bin/bash # Source in all settings . /var/zlmdata/scripts/zlmsettings.conf zlman -U $ZLMuser -P $ZLMpass -V command options
In this case we can use the $ZLMuser and $ZLMpass variables because they are defined in our zlmsettings.conf file.
Other useful scripts and examples
Here is the example script that I used many times for customers. It is easy to modify for each situation and provides a quick set-up for your environment.
First, the complete zlmsettings.conf file with all settings relevant to the build_structure script:
#!/bin/bash #******** Purpose ********** # zlmsettings.conf contains all required variables # # Admin Settings ZLMpass=MyP@ssw0rd ZLMuser=administrator # SLES Settings # SLESLIST, an array for all catagories SLESLIST=(recommended security optional) # Prefixes for production, pre-production and test ProdPref=patch-Prod PreProdPref=patch-PreProd TestPref=patch-Test # SLESCatName = Name for the Catalogs without the SLESLIST extention. SLESCatName=SLES10SP2-Updates # SLESSource = Folder for all catalogs that zlmmirror collects. SLESSource=/zlmmirror/SLES10SP2-Updates # Patches base folder where all Bundle Groups for Test servers will be. SLESTest=/Patches/SLES10SP2-x86_64 # Patches base folder where all Bundle Groups for Production servers will be. SLESProduction=/Patches/SLES10SP2-x86_64 # Patches base folder where all Bundle Groups for Pre-production servers will be. SLESPreProduction=/Patches/SLES10SP2-x86_64
Second, the build_structure script itself. Please note that many more items could be added to zlmsettings.conf and be used as variables. Just modify this to your own liking.
#!/bin/bash #******** Purpose ********** # build_structure.sh builds a new patch management structure inside ZLM # # Source in all settings . /var/zlmdata/scripts/zlmsettings.conf # Activate the product # zlman -U $ZLMuser -P $ZLMpass -V license-activate >license_key< # Create Bundle Folders for SLES10SP2 zlman -U $ZLMuser -P $ZLMpass -V bfc Sources zlman -U $ZLMuser -P $ZLMpass -V bfc SLES10SP2-x86_64 Sources zlman -U $ZLMuser -P $ZLMpass -V bfc Patches zlman -U $ZLMuser -P $ZLMpass -V bfc SLES10SP2-x86_64 Patches # Create Bundle Groups for Category in ${SLESLIST[*]} ; do zlman -U $ZLMuser -P $ZLMpass -V bgc $TestPref-$Category $SLESTest done zlman -U $ZLMuser -P $ZLMpass -V bgc $PreProdPref $SLESPreProduction zlman -U $ZLMuser -P $ZLMpass -V bgc $ProdPref $SLESProduction # Create server folders zlman -U $ZLMuser -P $ZLMpass -V sfc SLES10 # Create server groups Example with both variables and static values zlman -U $ZLMuser -P $ZLMpass -V sgc "$TestPref" SLES10 zlman -U $ZLMuser -P $ZLMpass -V sgc "$ProdPref" SLES10 zlman -U $ZLMuser -P $ZLMpass -V sgc "$PreProdPref" SLES10 zlman -U $ZLMuser -P $ZLMpass -V sgc Production SLES10 zlman -U $ZLMuser -P $ZLMpass -V sgc Pre-production SLES10 zlman -U $ZLMuser -P $ZLMpass -V sgc Test SLES10 # Connect bundelgroups to server groups for Category in ${SLESLIST[*]} ; do zlman -U $ZLMuser -P $ZLMpass -V sab SLES10/"$TestPref" $SLESTest/$TestPref-$Category done zlman -U $ZLMuser -P $ZLMpass -V sab SLES10/"$ProdPref" $SLESProduction/$ProdPref zlman -U $ZLMuser -P $ZLMpass -V sab SLES10/"$PreProdPref" $SLESPreProduction/$PreProdPref # Registration Rules and their Group memberships # Servers will be added to a Normal group for Production, Pre-production and Test, as well as a specific patch-group. # Pre-production servers also need to be a memeber of the Production patch groups # Test servers also need to be a memeber of the Production and Pre-production patch groups zlman -U $ZLMuser -P $ZLMpass -V registration-create-server production_SLES10 SLES10 zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group production_SLES10 SLES10/"$ProdPref" zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group production_SLES10 SLES10/Production zlman -U $ZLMuser -P $ZLMpass -V registration-create-server pre-production_SLES10 SLES10 zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group pre-production_SLES10 SLES10/"$PreProdPref" zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group pre_production_SLES10 SLES10/"$ProdPref" zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group pre-production_SLES10 SLES10/Pre-production # Please note that the Test servers will be added to all patch groups.... zlman -U $ZLMuser -P $ZLMpass -V registration-create-server test_SLES10 SLES10 zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group test_SLES10 SLES10/"$ProdPref" zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group test_SLES10 SLES10/"$PreProdPref" zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group test_SLES10 SLES10/"$TestPref" zlman -U $ZLMuser -P $ZLMpass -V registration-add-server-group test_SLES10 SLES10/Test exit 0
Of course, you can add many additional things to your script(s). For example, I often use the following as well:
Adding Administrators to my environments.
In this case a script on its own, but you could easily integrate this in the build_structure script.
#!/bin/bash # Script to add new admin users. if [ -z $4 ] ; then clear echo -e "\n\n\nUsage: add_admin.sh ZLM_Administrator Password New_admin New_admin_password\n\nPlease note that the new admin is assigned all rights!" else zlman -U "$1" -P "$2" admin-create "$3" "$4" zlman -U "$1" -P "$2" admin-rights-assign -b -c "$3" / zlman -U "$1" -P "$2" admin-rights-assign -s -c "$3" / zlman -U "$1" -P "$2" admin-rights-assign -w -c "$3" / zlman -U "$1" -P "$2" admin-rights-assign -a -c "$3" / zlman -U "$1" -P "$2" admin-rights-assign -p -c "$3" / zlman -U "$1" -P "$2" admin-rights-assign -R -c "$3" / zlman -U "$1" -P "$2" admin-rights-assign -r -c "$3" / fi exit 0
Or modifying the default timeout of the Management console, a job that you could easily add to the end of the build_structure script.
#!/bin/bash # Script to change the default ZCC timeout. # Please replace the default timout (30) with a suitable valuse, or use -1 to remove it sed --in-place=BAK 's/"timeout">-1/"timeout">-1/' /var/opt/novell/zenworks/www/tomcat/base/webapps/zenworks/WEB-INF/config.xml # Restart the zen server /etc/init.d/novell-zenserver restart exit 0
No comments yet