########################################################
#
# Remote value from server connection to cfServer
#
########################################################

 #
 # run this as follows:
 #
 # cf-serverd -f runtest_1.cf [-d2]
 # cf-agent   -f runtest_2.cf
 #
 # Notice that the same file configures all parts of cfengine

########################################################

body common control

{
bundlesequence  => { "testbundle"  };

version => "1.2.3";
}

########################################################

bundle agent testbundle

{
vars:

 "x" string => "scalar2";
 "remote1" string => remotescalar("test_scalar1","127.0.0.1","yes");
 "remote2" string => remotescalar("test_scalar2","127.0.0.1","yes");
 "remote3" string => remotescalar("test_scalar3","127.0.0.1","yes");
 "remote_error" string => remotescalar("test_$(x)","127.0.0.2","yes");

reports:

  linux::

    "Receive value $(remote1), $(remote2), $(remote3)";

    "And an error gives: $(remote_error)";
}

#########################################################
# Server config
#########################################################

body server control 

{
allowconnects         => { "127.0.0.1" , "::1" };
allowallconnects      => { "127.0.0.1" , "::1" };
trustkeysfrom         => { "127.0.0.1" , "::1" };
allowusers            => { "mark" };
}

#########################################################

bundle server access_rules()

{
vars:

  "localvar" string => "literal string";

access:

  "This is a $(localvar) for remote access"
 
        handle  => "test_scalar1",
  resource_type => "literal",
        admit   => { "127.0.0.1" };



  "Mary had a little lamb whose fleece was white as snow and everywhere that Mary went she wore it lovingly"
 
        handle  => "test_scalar2",
  resource_type => "literal",
        admit   => { "127.0.0.1" };

  "/etc/passwd"
        handle  => "test_scalar3",
        admit   => { "127.0.0.1" };
}
