[augeas-devel] Does systemd expose any unit-file-parsing functionality?

Dominic Cleal dcleal at redhat.com
Sun Mar 18 18:19:13 UTC 2012

On 18/03/12 11:51, Richard W.M. Jones wrote:
> On Sat, Mar 17, 2012 at 10:32:22AM -0400, Tom Lane wrote:
>> I have a shell script that needs to dig the values of a couple of
>> "Environment=" settings out of a systemd service file.  Currently
>> it just assumes it knows the search path for such things, finds
>> the file, and greps for the right lines.  This seems unduly friendly
>> with the file format, and it was just pointed out to me that it
>> completely fails to handle .include directives.  So I'm wondering if
>> there is anything in the systemd infrastructure that could help me
>> do this in a more robust way.  Ideas anyone?
> Augeas *ought* to be able to do this.  Unfortunately I don't see any
> lens in upstream augeas git :-(  But it'd be a nice feature to add.

Thanks for the idea Rich, I've added a lens to Augeas to parse unit files:

For Tom's use it still requires knowing unit file paths and it won't
automatically follow .include directives, but it will parse them and
present them in the config tree.

See the unit test in the above commit for an example of the layout, or
this augtool print output of one service with some environment variables
set: http://fpaste.org/PrtY/

You can use the above lens with released versions of Augeas, either
putting it into /usr/share/augeas/lenses or using augtool -I.

Dominic Cleal
Red Hat Consulting
m: +44 (0)7817 878113

More information about the devel mailing list