Forum: CFEngine Help Subject: Class not being defined correctly Author: raymondcox Link to topic: https://cfengine.com/forum/read.php?3,23121,23121#msg-23121
Hello, I am trying to extend the configurations that I use to add users to my systems to also remove users. I have extended my user array to include a value called valid, this will always be either true or false. The idea is to set a class based upon the value of valid, however the class is always defined no mater what the actual value of valid is. I have tried to use regcmp and strcmp, I believe they should both work in this case, however I am not getting the results I expect. This is my configuration: body common control { bundlesequence => { "test" }; } bundle agent test { vars: "users" string => "Test User 1"; "users" string => "123"; "users" string => "dba"; "users" string => "/home/testuser1"; "users" string => "/bin/bash"; "users" string => "false"; "users" string => "false"; "users" string => "Test User 2"; "users" string => "124"; "users" string => "dba"; "users" string => "/home/testuser2"; "users" string => "/bin/bash"; "users" string => "true"; "users" string => "false"; methods: "any" usebundle => check_user("test.users"); } bundle agent check_user(user) { vars: "index" slist => getindices("$(user)"); classes: #"valid_user" expression => regcmp("true","$($(user)[$(index)])"); "valid_user" expression => strcmp("true","$($(user)[$(index)])"); reports: valid_user:: "USER: $(index) is showing up as valid with a status of $($(user)[$(index)])"; !valid_user:: "USER: $(index) is showing up as invalid with a status of $($(user)[$(index)])"; And this is what it produces: R: USER: testuser2 is showing up as valid with a status of true R: USER: testuser1 is showing up as valid with a status of false Is my use of regcmp and or strcmp correct? Should I be using a different method to define these things? I am about a year out from being able to tie my LINUX and AIX environments into AD, so unfortunately that is not an option. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine