Skip to content
Snippets Groups Projects
Commit 06e91dc3 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Support comments on sections and options.

In systemd::unit and systemd::unit_options, support a special syntax
in the hash of hashes for specifying comments on sections and on
individual options, where the comments get written to the systemd
unit file.

The syntax is to specify a key with a name prefixed with a hash (#)
sign.  The comment will be inserted just before the corresponding
section or option.  For example:

        options => {
            'Install' => { 'WantedBy' => 'multi-user.target' },
            'Service' => {
                'ExecStart' => '/bin/true'
                'User' => 'laureline',
                '#User' => "Don't run as Valerian",
            },
            '#Service' => [
                "This is a pretty silly service section,",
                "but we can test\nnewlines in the comment.",
            ],
        }

will generate

        [Install]
        WantedBy=multi-user.target

        # This is a pretty silly service section,
        # but we can test
        # newlines in the comment.
        [Service]
        ExecStart=/bin/true
        # Don't run as Valerian
        User=laureline

The idea is to be able to point out subtilities to readers of the
generated unit file, so someone looking at a configured system doesn't
have to go to the Puppet manifests to understand why something is done
in a specific way.

I'm not sure how useful this feature is, though.  Perhaps users will
be satisfied with having normal Puppet comments in the manifest source
code, and reading those.
parent bba0d2ce
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment