Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-1737

improve classmatch to support tags

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.7.0
    • Component/s: Language
    • Labels:
      None

      Description

      When looking to see if a class is defined with classmatch it would be nice to be more selective.

      Consider the following:

      redhat_pure should be defined when redhat.!(centos|oracle)::

      Ok centos is probably not a common name for people to use, but oracle could easily be a hostname, or could easily be a class defined to identify an oracle database server.

      I can with a bit of acrobatics work around this using classesmatching to be more selective.

        vars:
          "oracle_hard_classes"
            slist => classesmatching( "oracle",
                                      "hardclass", "inventory",
                                      "attribute_name=none", "source=agent"),
            comment => "Find out of any hard oracle classes exist, simply using
                        oracle opens the possibilty for an incorrect os
                        classification in the event someone uses oracle as a
                        hostname, or to indicate the presense of an oracle
                        database.";
      
        classes:
            "oracle_linux"
              expression => isgreaterthan(length(oracle_hard_classes), 0);
      
            "redhat_pure" expression => "redhat.!(centos|oracle_linux)",
            comment => "pure Red Hat",
            meta => { "inventory", "attribute_name=none" };
      

      It would be more conveniant to do something like this.

        classes:
            "oracle_linux"
              expression => classmatch("oracle", "hardclass", "inventory",
                                      "attribute_name=none", "source=agent");
      
            "redhat_pure" expression => "redhat.!(centos|oracle_linux)",
            comment => "pure Red Hat",
            meta => { "inventory", "attribute_name=none" };
      

      I am not very inventive when it comes to syntax. I wish that I could use classmatch to do negative tag matches

      something like oracle.!(source=policy). Maybe I could do that with a regular expression for the tags but its not immeadiately obvious to me.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            a10042 Nick Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: