Forum: Cfengine Help
Subject: creating a list from two lists by interpolation
Author: svenXY
Link to topic: https://cfengine.com/forum/read.php?3,21397,21397#msg-21397

Hi,

this might have been asked before, so apologies if so, but due to the generic 
keywords I wasn't able to find a solution:

What I'm trying to achieve here is to programatically create a list of 
nameservers to then feed to the resolver-bundle, but to me it seems that there 
is no obvious way to create this list:


body common control
{
  bundlesequence  => { 'test' };
  inputs          => { 'cfengine_stdlib.cf' };
}

bundle agent test
{
  vars:
    linux::
      "oct4"  slist => { '11', '1' };
      "oct2"   string =>  '21';

    solaris::
      "oct4"  slist => { '1', '11' };
      "oct2"   string => '24';

    any::
      # this is what does not seem to work:
      "namesrv" slist => { "10.${oct2}.20.$(oct4)" };

  reports:
    linux::
      "${oct2} ${oct4}";
      "${namesrv}";
}


The resulting output is:

% ../bin/cf-agent -K -f result.cf 
 !! Redefinition of variable "namesrv" (embedded list in RHS) in context "test"
 !! Redefinition of variable "namesrv" (embedded list in RHS) in context "test"
 !! Redefinition of variable "namesrv" (embedded list in RHS) in context "test"
 !! Redefinition of variable "namesrv" (embedded list in RHS) in context "test"
R: 21 11
R: 21 1
R: 10.21.20.$(oct4)


Thanks a lot,
Sven

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to