Custom inventory attributes in the reports of Mission Portal

38 views
Skip to first unread message

Christian Linden

unread,
Sep 30, 2015, 7:00:06 AM9/30/15
to help-c...@googlegroups.com
Hi,

my bundle: 

bundle agent setInventoryClass
{
  meta:
    "tags" slist => { "autorun" };

  vars:
  "system_serial_number"
     string => execresult("dmidecode -s system-serial-number", "useshell"),
     meta => { "inventory", "attribute_name=System serial number" };

classes:
    "InventoryClass" or => { "host001" },
     meta => { "inventory", "attribute_name=Roles" };

reports:
    InventoryClass::
       "Class MissionPortal_server ist gesetzt bzw. sollte gesetzt sein.";
}


After this bundle run in the MissionPortal I find in the uncategorizied report "Variables" my bundle "setInventoryClass" with the variable name and the value =)

But I expected a similar effect regarding the class and I can't find it looking in the "Contexts (classes) defined last run" report.
Maybe I don't understand the process of setting a class correctly but shouldn't the class "InventoryClass" be set if this bundle is run on host001?

Thanks!
Chris

Neil Watson

unread,
Sep 30, 2015, 7:55:08 AM9/30/15
to help-cfengine
On Wed, Sep 30, 2015 at 04:00:06AM -0700, Christian Linden wrote:
     meta => { "inventory", "attribute_name=System serial number" };
> classes:
>     "InventoryClass" or => { "host001" },
>      meta => { "inventory", "attribute_name=Roles" };

> Maybe I don't understand the process of setting a class correctly but
> shouldn't the class "InventoryClass" be set if this bundle is run on
> host001?

Hi Chris,

Yes, I would expect InventoryClass to be set on host001, provided that
this bundle is run on the host. Best check verbose output for the bundle
and the class.

--
Neil H Watson
Sr. Partner, Architecture and Infrastructure
CFEngine reporting: https://github.com/evolvethinking/delta_reporting
CFEngine policy: https://github.com/evolvethinking/evolve_cfengine_freelib
CFEngine and vim: https://github.com/neilhwatson/vim_cf3
CFEngine support: http://evolvethinking.com

Christian Linden

unread,
Sep 30, 2015, 8:50:33 AM9/30/15
to help-cfengine, cfen...@watson-wilson.ca
Hi Neil,

did that, but there's nothing about the class:

 verbose: Using bundlesequence =>  {'setInventoryClass'}
 verbose: B: *****************************************************************
 verbose: B: BEGIN bundle setInventoryClass
 verbose: B: *****************************************************************
 verbose: V:     Computing value of "tags"
 verbose: A: Promise was KEPT
 verbose: P: END meta promise (tags...)
 verbose: V: .........................................................
 verbose: V: BEGIN variables (pass 1)
 verbose: V: .........................................................
 verbose: V:     Computing value of "system_serial_number"
 verbose: C: .........................................................
 verbose: C: BEGIN classes / conditions (pass 1)
 verbose: C: .........................................................
 verbose: V:     Computing value of "tags"
 verbose: A: Promise was KEPT
 verbose: P: END meta promise (tags...)
 verbose: V: .........................................................
 verbose: V: BEGIN variables (pass 2)
 verbose: V: .........................................................
 verbose: V:     Computing value of "system_serial_number"
 verbose: C: .........................................................
 verbose: C: BEGIN classes / conditions (pass 2)
 verbose: C: .........................................................
 verbose: V:     Computing value of "tags"
 verbose: A: Promise was KEPT
 verbose: P: END meta promise (tags...)
 verbose: V: .........................................................
 verbose: V: BEGIN variables (pass 3)
 verbose: V: .........................................................
 verbose: V:     Computing value of "system_serial_number"
 verbose: C: .........................................................
 verbose: C: BEGIN classes / conditions (pass 3)
 verbose: C: .........................................................
 verbose:
 verbose: A: ...................................................
 verbose: A: Bundle Accounting Summary for 'setInventoryClass' in namespace default
 verbose: A: Promises kept in 'setInventoryClass' = 6
 verbose: A: Promises not kept in 'setInventoryClass' = 0
 verbose: A: Promises repaired in 'setInventoryClass' = 0
 verbose: A: Aggregate compliance (promises kept/repaired) for bundle 'setInventoryClass' = 100.0%
 verbose: A: ...................................................
 verbose:
 verbose: B: *****************************************************************
 verbose: B: END bundle setInventoryClass

It's just ignoring it =(

c

Aleksey Tsalolikhin

unread,
Sep 30, 2015, 8:52:23 AM9/30/15
to Christian Linden, help-cfengine
I ran into this too, Christian.  Classes need to be global in order to appear in  Enterprise inventory.

You can make your classes global either by changing the bundle type to "common", or by adding the 

    scope =>  "namespace"

attribute to your classes promise.

Have fun!  Glad you're trying Enterprise.

Yours,
-at


On Wed, Sep 30, 2015 at 4:00 AM, Christian Linden <lindo...@gmail.com> wrote:
Hi,

my bundle: 

bundle agent setInventoryClass
{
  meta:
    "tags" slist => { "autorun" };

  vars:
  "system_serial_number"
     string => execresult("dmidecode -s system-serial-number", "useshell"),
     meta => { "inventory", "attribute_name=System serial number" };

classes:
    "InventoryClass" or => { "host001" },
     meta => { "inventory", "attribute_name=Roles" };

reports:
    InventoryClass::
       "Class MissionPortal_server ist gesetzt bzw. sollte gesetzt sein.";
}


After this bundle run in the MissionPortal I find in the uncategorizied report "Variables" my bundle "setInventoryClass" with the variable name and the value =)

But I expected a similar effect regarding the class and I can't find it.
Maybe I don't understand the process of setting a class correctly but shouldn't the class "InventoryClass" be set if this bundle is run on host001?

Thanks!
Chris

--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.



--
Aleksey Tsalolikhin
CFEngine Training & Consulting
Vertical Sysadmin, Inc.

Neil Watson

unread,
Sep 30, 2015, 9:00:56 AM9/30/15
to help-cfengine
Confirm that the class host001 is global and set before your bundle is
called.

Christian Linden

unread,
Sep 30, 2015, 9:53:28 AM9/30/15
to help-cfengine, lindo...@gmail.com
classes:
    "InventoryClass" or => { "host001" },
     meta => { "inventory", "attribute_name=Roles" },
     scope => "namespace";

doesn't work =(

Yours =)
Chris 

Christian Linden

unread,
Sep 30, 2015, 9:55:19 AM9/30/15
to help-cfengine, lindo...@gmail.com
nothing more than  verbose: C: BEGIN classes / conditions (pass 1) in the verbose output as well =(

Aleksey Tsalolikhin

unread,
Sep 30, 2015, 9:56:41 AM9/30/15
to Christian Linden, help-cfengine
Try adding

{{{
reports:
  InventoryClass::
       "DEBUG $(this.bundle):  class 'InventoryClass' is set";

}}}
in the same bundle.  Run it with "cf-agent".  Do you see the report?

If so, go on the hub and run "cf-hub -q delta -H xyz" (where xyz is the hostname of your host).  NOW check Mission Portal. Running cf-agent will populate the report, running cf-hub will collect it.

Christian Linden

unread,
Sep 30, 2015, 10:39:44 AM9/30/15
to help-cfengine, lindo...@gmail.com
No, did that in advance ;-)
I don't see the report because for whatever reason the class is not being set =(

Aleksey Tsalolikhin

unread,
Sep 30, 2015, 12:19:37 PM9/30/15
to Christian Linden, help-cfengine

Okay. Figure out why the class is not getting set and once you fix that then the class will appear in the mission portal inventory.

Christian Linden

unread,
Oct 1, 2015, 4:56:12 AM10/1/15
to help-cfengine, lindo...@gmail.com
I doubt that you will believe me.. but I just removed the "or" in  "InventoryClass" or => { "host001" },
what causes a syntax error.. I reput the or in and rerun the bundle with the same command and now I see:
<<
R: DEBUG i00setInventoryClass:  class 'InventoryClass' is set
..
 verbose: C: BEGIN classes / conditions (pass 2)
 verbose: C: .........................................................
 verbose: Skipping evaluation of classes promise as class 'InventoryClass' is already set
...
>>

Ok, however, I'm used to getting fooled.. but why don't I see the class grepping for it:
[root@host001 autorun]# cf-promises --show-classes | grep -i InventoryClass | grep -v hardclass
[root@host001autorun]#
?

After it's set I expect it showing up here.

Thanks,
Chris
Reply all
Reply to author
Forward
0 new messages