4 Replies Latest reply on Jun 27, 2012 8:42 PM by Bill Robinson

    Dynamic Property Class References in a Compliance Rule

    Eric Robeson

      I have created a custom property class "My_Sites" which contains sub-classes for each location, i.e. Seattle, Boston, etc. In there I created 3 properties: DNS_Server1, DNS_Server2, and DNS_Server3.


      I would like to create a compliance rule which dynamically selects the correct sub-class to evaluate against based on the value of ??Target.PHYSICAL_LOCATION?? server property. The value of that property is equivalent to the name of the sub-classes.


      Is there any way I can 'nest' a server property value in a reference to a property class? Something like this:


      "Configuration File Entry:/etc/resolv.conf//nameserver"."Value1 as String (All OS)" = ??My_Sites.??Target.PHYSICAL_LOCATION??.DNS_Server1??


      In the right-hand side ??Target.PHYSICAL_LOCATION?? would equate to a value, so that the reference would be to (for example) ??My_Sites.Seattle.DNS_Server1?? custom property if the server is in Seattle.


      This would allow me to define one compliance rule that scales as I add or remove sites to the property class. Is that -- or something equivalent -- possible? The only way I have found to do it so-far is with a bunch of if statements which look at the value of ??Target.PHYSICAL_LOCATION?? and select which sub-class to use based on the value. This is not very elegant as I have a large number of sites and will have to define the same condition comparison for each site, it also doesn't scale as I add new sites.



        • 1. Dynamic Property Class References in a Compliance Rule
          Bill Robinson

          So this might be a bit convoluted but try this:


          Create a PSC called "My_Sites".

          Add a property called "DNS_Server1"

          Create a new Instance of this PSC called "Site1".

          On your server set PHYSICAL_LOCATION to 'Site1"


          Create a Component Template.

          Add the /etc/resolv.conf

          Create a Local Property of type PSC pointed to 'My_Sites' called Site

          Create a Local PSI called 'Site1' w/ the value of 'Site' the Site1 PSI in My_Sites

          Set the discovery condition to '??TARGET.PHYSICAL_LOCATION?? equals "Site.NAME"

          Set your rule to be like:

          "Configuration File Entry:/etc//resolv.conf//nameserver"."Value1 as String (All OS)" = "??Site.DNS_Server1??"


          Run discovery for the template against the servers

          run the compliance job against the servers.

          • 2. Dynamic Property Class References in a Compliance Rule
            Eric Robeson

            I went down that path, but in your example the discovery condition for the Component Template is site-specific, meaning I will have to have one component template per site. That doesn't seem any better than one component template with a bunch of if statements. Perhaps this needs to be done using an NSH script rather than a component template?

            • 3. Re: Dynamic Property Class References in a Compliance Rule
              Daniel Goetzman

              We use the same basic CT configuration Bill is explaining here for this exact same use case, DNS client configuration compliance per site…

              We only have ONE CT! Discovery using PSC will create a Component instance for the correct site based on the Discovery rules.


              But again, ONE CT is all that is required! Each site will attach the correct Component instance and therefore values defined in the PSC.


              It works well for us. A single CT that will compliance check the DNS server values based on the site/location!


              1 of 1 people found this helpful
              • 4. Re: Dynamic Property Class References in a Compliance Rule
                Bill Robinson

                You would need one PSI per site in the CT.  discovery will handle creating the right instance on each host.

                1 of 1 people found this helpful