Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-4629

Augeas onlyif does not work when using arrays to match against

    XMLWordPrintable

    Details

    • Template:
    • Story Points:
      0
    • Sprint:
      Client 2015-07-22
    • Release Notes:
      New Feature
    • Release Notes Summary:
      Hide
      Makes it possible to control execution of an augeas resource based on whether a property in the file being managed has a particular value. For example, you can ensure augeas only applies changes to /etc/nagios/nagios.cfg, if the cfg_file property in the nagios.cfg file does not equal a list of values.

      {code:puppet}
      augeas { 'configure-nagios-cfg_file':
        incl => '/etc/nagios/nagios.cfg',
        lens => 'NagiosCfg.lns',
        changes => [ "rm cfg_file",
                     "ins cfg_file",
                     "set cfg_file[1] /etc/nagios/commands.cfg",
                     "ins cfg_file after /files/etc/nagios/nagios.cfg/cfg_file[last()]",
                     "set cfg_file[2] /etc/nagios/anotherconfig.cfg" ],
        onlyif => "values cfg_file != ['/etc/nagios/commands.cfg', '/etc/nagios/anotherconfig.cfg']"
      }
      {code}
      Show
      Makes it possible to control execution of an augeas resource based on whether a property in the file being managed has a particular value. For example, you can ensure augeas only applies changes to /etc/nagios/nagios.cfg, if the cfg_file property in the nagios.cfg file does not equal a list of values. {code:puppet} augeas { 'configure-nagios-cfg_file':   incl => '/etc/nagios/nagios.cfg',   lens => 'NagiosCfg.lns',   changes => [ "rm cfg_file",                "ins cfg_file",                "set cfg_file[1] /etc/nagios/commands.cfg",                "ins cfg_file after /files/etc/nagios/nagios.cfg/cfg_file[last()]",                "set cfg_file[2] /etc/nagios/anotherconfig.cfg" ],   onlyif => "values cfg_file != ['/etc/nagios/commands.cfg', '/etc/nagios/anotherconfig.cfg']" } {code}

      Description

      According to the type reference, you should be able to use the 'onlyif' metaparameter of the augeas type to check if the results from an augeas path equal an array. The augeas type does not return values, however, so it can never match the values in your array. Instead it returns an array of augeas paths.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              mmarod Michael Marod
              QA Contact:
              Eric Thompson Eric Thompson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 hour
                    1h
                    Remaining:
                    Time Spent - 30 minutes Remaining Estimate - 30 minutes
                    30m
                    Logged:
                    Time Spent - 30 minutes Remaining Estimate - 30 minutes
                    30m