bundle agent t { vars: any:: # Lists we get as inputs from ENC "ntp_servers" slist => { "ntp1.conectiv.com", "208.90.144.72 # ntp0.jrc.us", "bonehed.lcs.mit.edu minpoll 9 # server seems to have a strong rate limiting", "timekeeper.isi.edu" } ; # Data transformations, as suggested by Ted Zlatanov, to create an # index for this list (getindices on plan slist doesn't work, so # we build a list in a data container) "ntp_data" data => mergedata("ntp_servers") ; # This list will contain the indexes for all the entries that are # now in both ntp_servers and ntp_data. Using these indexes, it's # easier to transform the strings into something usable "idx" slist => getindices("ntp_data") ; # This will first create an array that maps the index, which is a # valid array key, to a list of two elements: the first element # is the NTP server, the second is whatever follows, if anything. "ntp_data_split[$(idx)]" slist => string_split( nth("ntp_data", "$(idx)"), # idx-th element of ntp_data "\s+", # split at 1 or more spaces 2 # in two pieces at most ) ; # ...then we dig into ntp_data_split and pull out the first # element of each slist into the value, which means: we are # mapping each index with the corresponding NTP server "server_name[$(idx)]" string => nth("ntp_data_split[$(idx)]",0) ; # If everything went well thus far, the values of server_name # are all our NTP servers by now "server_names" slist => getvalues("server_name") ; reports: "DEBUG: server: $(server_names)" ; }