Forum: CFEngine Help
Subject: Strange problem with getindices
Author: raymondcox
Link to topic: https://cfengine.com/forum/read.php?3,22864,22864#msg-22864

Hello all,

I am running into a strange warning message from getindices in a configuration 
I use to manage passwords for DBA's and System Admins on a bunch of LINUX 
servers. 

I use a couple of arrays to maintain information about the system admins and 
DBA's. I use the arrays to both create the users on new systems, and keep the 
passwords in sync. Creating the users works like a charm with no errors. The 
password sync stuff however throws warning messages, but does work.

This is a test file that I am using to try and figure out what is going on, I 
think it should work but running cf-promises against the file produces the 
messages:

Function getindices was promised an array called "users" in scope "dba" but 
this was not found
Function getindices was promised an array called "users" in scope "sysadmins" 
but this was not found



Running cf-agent -KI -f ./passtest.cf produces the following messages:


Function getindices was promised an array called "users" in scope "dba" but 
this was not found
Function getindices was promised an array called "users" in scope "sysadmins" 
but this was not found
Function getindices was promised an array called "users" in scope "dba" but 
this was not found
Function getindices was promised an array called "users" in scope "sysadmins" 
but this was not found
R: x is set to dba1
R: x is set to dba2
R: x is set to sysadm1
R: x is set to sysadm2


This is the contents of passtest.cf:


body common control {
    bundlesequence => { "passwordsync" };
            inputs => { "../cfengine_stdlib.cf",
                        "../site.cf",
                      };
}

bundle agent passwordsync
{
vars:
  any::

    "dba_users" slist => getindices("dba.users"),
            policy => "overridable";

    "admin_users" slist => getindices("sysadmins.users"),
            policy => "overridable";

    "u" slist => { "@(dba_users)", "@(admin_users)",  },
            policy => "overridable";

  aix::
    "pwhost" string => "someaixserver";

  linux::
    "pwhost" string => "somelinuxserver";

methods:
  linux::
    "any" usebundle => linux_pwds("$(pwhost)","passwordsync.u");
}

bundle agent linux_pwds(system,users) {

vars:
  linux::
    "x"    slist => { "@($(users))" };

reports:
  linux::
    "x is set to $(x)";
}

#
# Body to keep the commands quiet
#

body contain standard
{
        useshell  => "true";
        no_output => "true";
}
bundle agent dba
{
vars:

  # Users to create

 "users"   string => "dba1 - DBA Team";
 "users"     string => "123456";
 "users"   string => "dba";
 "users"    string => "/home/dba1";
 "users"   string => "/bin/bash";

 "users"   string => "dba2 - DBA Team";
 "users"     string => "123457";
 "users"   string => "dba";
 "users"    string => "/home/dba2";
 "users"   string => "/bin/bash";
}


bundle agent sysadmins
{
vars:
  # Users to create

  "users"     string => "sysadm1 - UNIX Admin Group";
  "users"       string => "123458";
  "users"      string => "aixadmin";
  "users"      string => "/home/sysadm1";
  "users"     string => "/usr/bin/ksh93";

  "users"     string => "sysadm1 - Server Team";
  "users"       string => "123459";
  "users"      string => "aixadmin";
  "users"      string => "/home/sysadm2";
  "users"     string => "/usr/bin/ksh93";
}



Any ideas? 

Thank you,

Raymond Cox

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

Reply via email to