At the IBM Technical Symposium in Sydney last week, a person approached me to discuss NIM and some of its capabilities. During the conversation we discussed how NIM could be used to copy files from the NIM master to its NIM clients. I promised to send them some information on how to achieve this ASAP. They were smart and followed up with an email the next day! They’d even tried to configure this on their systems but hit a small problem.
"Hello Chris,
So trying to push out a new netbackup tar file to one of our nim clients (usually we do all sort of stuff via our SSH deployment server). But decided to use NIM.
So I created the resource file_res called netbackup. Where the tar file is placed on the master
# nim -o define -t file_res -a location=/tmp/netbackup -a dest_dir=/tmp/netbackup -a server=master netbackup
# lsnim -l netbackup
netbackup:
class = resources
type = file_res
Rstate = ready for use
prev_state = unavailable for use
location = /tmp/netbackup
alloc_count = 0
server = master
dest_dir = /tmp/netbackup
But for the life of me I cannot find anywhere under NIM to allocate the resource to the client i.e. to push the file out..
I though it would be under install software, but the resource is not listed only lpp_sources.
Do you have any ideas, this one I am stuck on.
Can I actually push files out by themselves? Thanks"
The answer is yes! You can define a file_res resource on the NIM master. From the AIX 7.2 Knowledge Centre:
"A file_res resource is where NIM allows for resource files to be stored on the server. When the resource is allocated to a client, a copy of the directory contents is placed on the client at a location that is specified by the dest_dir attribute."
"-a location=Value Specifies the full path name of the directory on the NIM server. This path is used as a source directory among clients.
-a dest_dir=Value Specifies the full path name of the directory on the NIM client. This path is where the source directory is recursively copied into.
Notes: If the target directory does not exist on the destination machine, the entire source directory contents are copied (including the hidden files in the top-level directory). If the target directory exists on the destination machine, the source directory contents are copied (excluding the hidden files in the top-level directory)."
http://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.install/defining_file_res_resource.htm
Essentially, you can place the files you need to distribute to your NIM clients, into a directory on the NIM master. Then you can create a file_res NIM resource that points to this directory. After that, you can allocate this resource to the NIM client or NIM machine group, and run a NIM customisation operation against the client (or machine group). This will copy the directory and all its files to the NIM client. Pretty cool really!
Here's an example. I want to distribute (copy) all of the files located in /usr/local/etc, to a NIM client. The original (source) directory and files reside on the NIM master.
root@MASTER / # ls –l /usr/local/etc/
total 16
-rw-r--r-- 1 root system 542 Aug 22 09:53 logger.conf
-rw-r--r-- 1 root system 3219 Aug 22 10:41 fugazi.cf
First, I'll create a new file_res NIM resource, called soe_conf.
root@MASTER / # nim -o define -t file_res -a location=/usr/local/etc -a dest_dir=/usr/local/etc -a server=master soe_conf
root@MASTER / # lsnim -t file_res
soe_conf resources file_res
# lsnim -l soe_conf
soe_conf:
class = resources
type = file_res
dest_dir = /usr/local/etc
Rstate = ready for use
prev_state = unavailable for use
location = /usr/local/etc
alloc_count = 0
server = master
Now I can allocate the new resource to the NIM client named AIXmig.
root@MASTER / # nim -o allocate -a file_res=soe_conf AIXmig
root@MASTER / # lsnim -l AIXmig
AIXmig:
class = machines
type = standalone
connect = nimsh
file_res = soe_conf
platform = chrp
netboot_kernel = 64
if1 = VLAN50 AIXmig 0
cable_type1 = N/A
Cstate = ready for a NIM operation
prev_state = not running
Mstate = currently running
cpuid = 00F94F584C00
control = master
Before I customise the client, the /usr/local/etc directory does NOT exist on the NIM client.
root@AIXmig / # ls -ltr /usr/local/etc
ls: 0653-341 The file /usr/local/etc does not exist.
On the NIM master, I issue the "nim -o cust" operation against the NIM client AIXmig.
root@MASTER /# nim -o cust AIXmig
Looking again on the NIM client, I now find the directory and all of its files have been copied to the correct location on the host.
root@AIXmig / # ls –l /usr/local/etc
total 16
-rw-r--r-- 1 root system 542 Aug 22 09:53 logger.conf
-rw-r--r-- 1 root system 3219 Aug 22 10:41 fugazi.cf
The file_res resource, is automatically deallocated from the NIM client.
root@MASTER / # lsnim -l AIXmig
AIXmig:
class = machines
type = standalone
connect = nimsh
platform = chrp
netboot_kernel = 64
if1 = VLAN50 AIXmig 0
cable_type1 = N/A
Cstate = ready for a NIM operation
prev_state = customization is being performed
Mstate = currently running
cpuid = 00F94F584C00
Cstate_result = success
If you’re looking for a fast and cheap way of copying a bunch of files from a central location to one or more servers, then this is a very good option for AIX administrators. It’s like a “poor mans” file collections; similar to what we once had with Cluster System Management (CSM, which is now discontinued) and PowerHA File Collections (but not as powerful or configurable).