hostlistdat2cfg [ -o ]
hostlistdat2cfg [ -f file ... ][ central_opt ][ action_opt ][ env_opt ]
Example:
# # Format: # # <CUSTOMER>;<ENVIRONMENT>;<GROUPS>;<OPTIONS>;<HOSTS> # ACME;DEVELOPMENT ;@APP ;;host-001 host-002; ACME;DEVELOPMENT ;@DB ;;host-003; ACME;TEST ;@APP ;;host-101 host-103; ACME;PREPRODUCTION ;@APP ;;host-201 host-202 host-205; ACME;PRODUCTION ;@APP ;;host-303 host-308 host-309;
into settings that can be used in the hostlist.cfg file.
This command will significantly simplify the definition of host lists of large environments and will make the more complicated constructs obsolete where using the fmatch(3) command in the hostlist.cfg(4) configuration file.
Despite the many options that the hostlistdat2cfg provides, normally only the -m and the -o options will be used in the hostlist.cfg config file. See also samples in the edrc/var/samples/hostlist directory.
The output is written to a temporary directory that is generated by the maketemp(3) command internally. Therefore the tempfile can be removed using removetemp(3) later:
out=`hostlistdat2cfg -o` . $out removetemp -q -d `dirname ${out}`
The csv files is a semicolon separated file having the format as explained below. Rows can span multiple lines in the file, if they end with a backslash ( \).
To verify the syntax of the csv file, use the command hostlistdat2cfg -a list_dat -f file which will only list the correct rows.
Format:
CUSTOMER;ENVIRONMENT;GROUPS;OPTIONS;HOSTS;
Keys:
The GROUPs @ALL and @_DIST are generated automatically out of all hosts specified in the HOSTS field for the ENVIRONMENTs of a CUSTOMER.
If certain host(s) should be excluded from the @ALL or @_DIST group, specify -@ALL or -@_DIST in the GROUPS field.
This enables to test a configuration for an certain environment without logging in to it.
If this option is not used, the default is the customer name and environment of the server where logged on as returned by server_environment -C (=CUSTOMER) and server_environment (=NAME).
hostlistdat2cfg
hostlistdat2cfg -m
hostlistdat2cfg -m MGRPS_LIST=@LINUX,@SOLARIS,@HPUX
With that the local @ANY.SOLARIS group will contain all hosts that are member of @SOLARIS groups in all customer environments.
USE_HOSTLIST_DAT=True CMAN_ENVIRONMENT="Highlander.ADMIN" if [ "$USE_HOSTLIST_DAT" = True ]; then case `server_environment -C`.`server_environment` in $CMAN_ENVIRONMENT) out=`hostlistdat2cfg -o -m MGRPS_LIST=@LINUX,@SOLARIS,@HPUX`;; *) out=`hostlistdat2cfg -o`;; esac . $out; removetemp -q -d `dirname ${out}`; return 0 fi
edrc/etc/server_environment.cfg
# # server_environment.cfg - config for server_environment # # [00] 24.07.2004 CWa Initial Version # [50] 18.04.2013 CWa chg: cleanup # # Server environment definition. # # If you log on to a system, the <NAME> field of the # first matching <server_regex> will be returned. # # # Format: # <NAME>:<Description>:<server_regex>:<Customer>: # # Highlander (the 'one and only' central administration environment) # ADMIN:Datactr Schaffhausen, Central ADMIN:adm-(linux|hpux|solaris):Highlander: REPORT:Datactr Schaffhausen, Central ADMIN:rpt-[0-9]+):Highlander: # ACME # PRODUCTION:Datacenter Bern, PRODUCTION Env:host-3[0-9][0-9]:ACME: PREPRODUCTION:Datacenter Boston, Integration Env:host-2[0-9][0-9]:ACME: TEST:Datacenter Plano, Test Env:host-1[0-9][0-9]:ACME: DEVELOPMENT:Datacenter San Jose, Development Env:host-0[0-9][0-9]:ACME:
edrc/etc/hostlist.cfg
# # etc/hostlist.cfg - configuration of hostlist # # [00] 16.02.2004 CWa Initial Version # [64] 16.03.2013 CWa chg: use of hostlistdat2cfg # # Set USE_HOSTLIST_DAT to True, if hosts are listed in # the etc/hostlist.dat file, if hosts are defined directly # in etc/hostlist.cfg, set USE_HOSTLIST_DAT to False. # USE_HOSTLIST_DAT=True # Define the central administration environment in the # format CUSTOMER.NAME as defined in server_environment.cfg. # CMAN_ENVIRONMENT="Highlander.ADMIN" # Read hostlist.dat definitions as resolved. # if [ "$USE_HOSTLIST_DAT" = True ]; then case `server_environment -C`.`server_environment` in $CMAN_ENVIRONMENT) out=`hostlistdat2cfg -o -m MGRPS_LIST=@LINUX,@SOLARIS,@HPUX`;; *) out=`hostlistdat2cfg -o`;; esac . $out; removetemp -q -d `dirname ${out}`; return 0 fi # List of hosts when defined directly in the hostlist.cfg # file. # # The only compulsory settings in the hostlist.cfg file are # HOSTLIST and HOSTGRPS, everything else is for convenience # only and could be removed. See also: hostlist.cfg (4). # case `server_environment -C`.`server_environment` in Dummy.DUMMY) HOSTLIST=" " HOSTGRPS="@_DIST: @ALL: " ;; esac
edrc/etc/hostlist.dat
# # etc/hostlist.dat - hostlist csv database file # # [00] 12.08.2008 CWa Initial Version # [58] 16.03.2013 CWa chg: to hostlistdat2cfg structure # # # Format: # # <CUSTOMER>;<ENVIRONMENT>;<GROUPS>;<OPTIONS>;<HOSTS> # # To verify the syntax, use: hostlistdat2cfg -a dat # Only correct entries will be listed. # Highlander ;ADMIN ; ;;adm-linux adm-hpux adm-solaris; Highlander ;REPORT ; ;;rpt-001 rpt-002; ACME ;DEVELOPMENT ;@APP ;;host-001 host-002; ACME ;DEVELOPMENT ;@DB ;;host-003; ACME ;TEST ; ;;host-101 host-103; ACME ;PREPRODUCTION ; ;;host-201 host-203 host-205; ACME ;PRODUCTION ; ;;host-303 host-308 host-309; ACME ; ;@PING ;;ping-001 ping-002 ping-003;
resulting configuration on ACME.TEST
# # hostlist.cfg - configuration for hostlist # # [00] 03.05.2013 root generated by: /opt/edrc/lib/hostlistdat2cfg # # resolved for: # # SERVER_ENVIRONMENT_CUSTOMER: ACME # SERVER_ENVIRONMENT_NAME: TEST # CACHE=True CACHE_DEPENDENCY="etc/hostlist.cfg etc/server_environment.cfg etc/hostlist.dat lib/hostlistdat2cfg" HOSTLIST=" host-101 host-103 " HOSTGRPS=" @_DIST: host-001 host-002 host-003 host-101 host-103 host-201 host-203 host-205 host-303 host-308 host-309 @PING: ping-001 ping-002 ping-003 @ALL: host-001 host-002 host-003 host-101 host-103 host-201 host-203 host-205 host-303 host-308 host-309 ping-001 ping-002 ping-003 " export HOSTLIST HOSTGRPS CACHE CACHE_DEPENDENCY
resulting configuration on Highlander.ADMIN
# # hostlist.cfg - configuration for hostlist # # [00] 03.05.2013 root generated by: /opt/edrc/lib/hostlistdat2cfg # # resolved for: # # SERVER_ENVIRONMENT_CUSTOMER: Highlander # SERVER_ENVIRONMENT_NAME: ADMIN # CACHE=True CACHE_DEPENDENCY="etc/hostlist.cfg etc/server_environment.cfg etc/hostlist.dat lib/hostlistdat2cfg" HOSTLIST=" adm-hpux adm-linux adm-solaris " HOSTGRPS=" @Highlander.ADMIN: adm-hpux adm-linux adm-solaris @ACME.TEST: host-101 host-103 @ACME.PREPRODUCTION: host-201 host-203 host-205 @ACME.PRODUCTION: host-303 host-308 host-309 @ACME.DEVELOPMENT: host-001 host-002 host-003 @ACME.ALL: host-001 host-002 host-003 host-101 host-103 host-201 host-203 host-205 host-303 host-308 host-309 ping-001 ping-002 ping-003 @ANY.ALL: adm-hpux adm-linux adm-solaris host-001 host-002 host-003 host-101 host-103 host-201 host-203 host-205 host-303 host-308 host-309 ping-001 ping-002 ping-003 rpt-001 rpt-002 @ACME.DEVELOPMENT.APP: host-001 host-002 @Highlander.ALL: adm-hpux adm-linux adm-solaris rpt-001 rpt-002 @_DIST: adm-hpux adm-linux adm-solaris rpt-001 rpt-002 @Highlander.REPORT: rpt-001 rpt-002 @ACME.DEVELOPMENT.DB: host-003 @ACME.ANY.PING: ping-001 ping-002 ping-003 @ALL: adm-hpux adm-linux adm-solaris rpt-001 rpt-002 " export HOSTLIST HOSTGRPS CACHE CACHE_DEPENDENCY
This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.