Forum: Cfengine Help
Subject: Accessing Module-Declaring Variables
Author: nima
Link to topic: https://cfengine.com/forum/read.php?3,18279,18279#msg-18279

Hi,

Here's my problem: starting with the cf3 config:


bundle agent OpenLDAP {
    classes:
        "OpenLDAPMasterRID" expression => usemodule("OpenLDAPMasterRID", ""); 

    ...

    reports:
        MODOpenLDAPMasterRID::
            "[ svc-openldap    ] $(ansi.blue)[ ou=openldap ]$(ansi.reset)";
            "[ svc-openldap    ] $(ansi.cyan)OpenLDAPMasterRID->commands() 
SUCCEEDED$(ansi.reset)";
            "[ svc-openldap    ] + 
$(ansi.cyan)OpenLDAPMasterRID->commands->RID($(var_MODOpenLDAPMasterRID))$(ansi.reset)";
}


Now, here's the output of the module itself:

darius:/srv/sysconf# /var/lib/cfengine3/modules/OpenLDAPMasterRID
+MODOpenLDAPMasterRID
+MODOpenLDAPMasterRIDSuccess
+MODOpenLDAPMasterRIDMasterRID
+MODOpenLDAPMasterRIDMasterRIDSuccess
=var_MODOpenLDAPMasterRID='0x003'
=_MODOpenLDAPMasterRID='0x003'


Right, now here's the problem: while classes are being defined (and I know this 
because the reports section does print to screen), the variable is not set:

darius:/srv/sysconf# cf-agent -Kb OpenLDAP
R: [ svc-openldap    ] [ ou=openldap ]
R: [ svc-openldap    ] OpenLDAPMasterRID->commands() SUCCEEDED
R: [ svc-openldap    ] + 
OpenLDAPMasterRID->commands->RID($(var_MODOpenLDAPMasterRID))
darius:/srv/sysconf# 


In verbose mode, I can see a possible scope issue, but that hasn't helped 
figure out a fix for it:

cf3 Activated classes: MODOpenLDAPMasterRID
cf3 Activated classes: MODOpenLDAPMasterRIDSuccess
cf3 Activated classes: MODOpenLDAPMasterRIDMasterRID
cf3 Activated classes: MODOpenLDAPMasterRIDMasterRIDSuccess
cf3 Defined variable: var_MODOpenLDAPMasterRID in context OpenLDAPMasterRID 
with value: '0x003'
cf3 Defined variable: _MODOpenLDAPMasterRID in context OpenLDAPMasterRID with 
value: '0x003'


So, how do I go about fixing this?

Nima

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

Reply via email to