Skip to content
Snippets Groups Projects
Select Git revision
0 results

unit_options.pp

Blame
    • Thomas Bellman's avatar
      06e91dc3
      Support comments on sections and options. · 06e91dc3
      Thomas Bellman authored
      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.
      06e91dc3
      History
      Support comments on sections and options.
      Thomas Bellman authored
      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.