Hello, first time poster, I can't seem to find the archive search
function so hopefully this hasn't been posted before:

First, I am using version 2.1.22 on RHEL5. My solution may be to
upgrade, not sure?

I have a file that I want to do a Replace on and the values are unique
per host, so I thought I'd define a hash and use a short hostname as the
key. I have it working by looking at
http://www.cfengine.org/manuals/cf2-Reference.html#index-Associative-arr
ays_002e-16, but an extra character is coming through, almost like there
may be a bug in getting a length somewhere in the code. Perhaps there is
something I am missing or I not getting in syntax? Perhaps, a namespace
problem?

#######################
# cf.redhat
#######################
control:
     wappservers|pubappservers::
        shortname = ( ExecResult(/bin/hostname -s) )

     zappservers::
                    shortname = ( ExecResult(/bin/hostname -s) )
       jprofiler_configs_hash = ( A(zapp1,110) A(zapp2,109) A(zapp3,108)
A(zapp4,104) )
                          srv = ( ExecResult(/bin/hostname -s) )   
                  jprofilerid = ( $(jprofiler_configs_hash[$(srv)]) )
editfiles:
   zappservers::
      # Do tokenization on .bashrc for jprofilerid
      { /xxxx/zip/.bashrc
        ReplaceAll "JPROFILERID" With "${jprofilerid}"
      }
#######################
# file prior to replace
#######################
export JAVA_OPTS="$JAVA_OPTS
-agentpath:/xxxx/zip/apps/jprofiler6/bin/linux-x86/libjprofilerti.so=off
line,id=JPROFILERID,config=/xxxx/zip/.jprofiler6/config.xml"
#######################
# resultant file has an extra ) BAD should be "104" but is "104)"
#######################
export JAVA_OPTS="$JAVA_OPTS
-agentpath:/xxxx/zip/apps/jprofiler6/bin/linux-x86/libjprofilerti.so=off
line,id=104),config= /xxxx/zip/.jprofiler6/config.xml"
#######################
# debug output snippet that seems relevant
#######################
Scanning variable srv
GetMacroValue(main,srv)
GetMacroValue(main,srv): using scope 'main' for variable 'srv'
Return Macrovalue={zapp4}
Expansion gave (jprofiler_configs_hash[zapp4), len = 3 Returning
varstring (jprofiler_configs_hash[zapp4])
CheckVarID(jprofiler_configs_hash[zapp4])
Scanning variable jprofiler_configs_hash[zapp4]
GetMacroValue(main,jprofiler_configs_hash[zapp4])
GetMacroValue(main,jprofiler_configs_hash[zapp4]): using scope 'main' 
for variable 'jprofiler_configs_hash[zapp4]'
Return Macrovalue={104}
Expansion gave (104), len = 29
Returning varstring (104))
IsInstallable(zappservers) - true
Assign variable [jprofilerid=104)] when


Thanks everybody, James Levinson 
Emeryville, CA, USA
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to