I want to use Augeas to modify "/etc/inittab", but this should only happen when the package "sysvinit" is installed. That package is not under Puppet control (and shall not be).

The "onlyif" from Augeas doesn´t seem capable of checking for anything else than Augeas stuff, i.d. Augeas cannot check if file exists.

Is there a way to achieve this without creating a custom fact?

  • 2
    You might be to a point where you are just going to have make yourself a custom fact that tells you if sysvinit is installed. – Zoredache Mar 14 '14 at 17:18

Write an Augeas provider and confine it to a fact which checks for the package's presence.

To sum it up:

  • Write a sysvinit_package fact, with value true or false (or even the package version)
  • Write a type and provider for inittab which is confined to the fact.

Note: the augeasproviders API is being redone to easily create providers outside of the augeasproviders module. See the shellvar standalone provider (PoC for now, the API will probably work this way eventually) for example.

Alternatively, if you just want to use the augeas type instead of writing a provider (which I would recommend though), you can just write a fact and use it in Puppet DSL to avoid declaring the augeas resource when sysvinit is not installed.

  • Probably the best solution, therefore I have marked this as the solution. However, with my basic knowledge I won't try to do it, cause writing a simple lens has already been a pita ;-) – Larsen Sep 4 '18 at 8:28
  • I like to believe that writing Augeas providers is easier than writing lenses. – ℝaphink Sep 5 '18 at 9:33

A horrible alternative would be to ditch the augeas resource type for an exec resource running augtool, and checking for the package in an onlyif command.

I'd go with the custom fact.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.