4

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?

1
  • 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, 2014 at 17:18

2 Answers 2

2

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.

2
  • 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, 2018 at 8:28
  • I like to believe that writing Augeas providers is easier than writing lenses.
    – raphink
    Sep 5, 2018 at 9:33
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .