monitor attributes of defined type

asked 2016-12-22 01:13:03 -0500

A program running on the node has an internal counter.

 define mytype (
  String foo = undef,
  Integer maxcount = undef,
) {
  file { $title:
    […]
    content => "${foo}\n${maxcount}\n",
  }

  exec { $title:
    command     => [… reset internal counter command …],
    refreshonly => true,
  }
}

How do I make my defined type automatically fire my reset counter command? If $foo changes, I do not have to reset the counter. It doesn't harm though. It is just unnecessary. Making a direct ~> from file to exec is not what I want.

I could introduce a dummy defined type, having $maxcount as a parameter, doing noting else, but audit => ['maxcount'] and get notifications from the dummy type.

define mydummy (
  Integer maxcount = undef,
) {
}

define mytype (
  String foo = undef,
  Integer maxcount = undef,
) {
  file { $title: [… as above …] }

  mydummy { $title:
    maxcount => $maxcount,
    audit    => ['maxcount'],
  }

  exec { $title: [… as above …] }

  Mydummy[$title] ~> Exec[$title]
}

However, that's not nice. Is there some other way, to solve this?

PS: No, I do not have to catch the situation, someone locally edited the maxcount line.

edit retag flag offensive close merge delete