Skip to content

Commit

Permalink
unit_file: allow arbitrary symlink targets
Browse files Browse the repository at this point in the history
Absolutepath is exactly what it says: it forces the link target to be
an absolute path, that is to start with a slash (`/`). But I
actually *want* to have relative symlinks.

This is particularly useful when doing a @.service template where the
instance refers to the template, often in the same directory.

This, for example, should be allowed:

    systemd::unit_file { "pgbackrest-backup-${kind}@${shortname}.service":
      enable => false,
      active => false,
      target => "pgbackrest-backup-${kind}@.service",
    }

Yet it currently crashes with:

    Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Systemd::Unit_file[[email protected]]: parameter 'target' expects a Stdlib::Absolutepath = Variant[Stdlib::Windowspath = Pattern[/\A(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+)).*\z/], Stdlib::Unixpath = Pattern[/\A\/([^\n\/\0]+\/*)*\z/]] value, got String (file: /etc/puppet/code/environments/prom_module_upgrade/3rdparty/modules/pgbackrest/manifests/repository/stanza.pp, line: 77) on node backup-storage-01.torproject.org

I don't know of another way to fix this than to make this a proper string.

Closes: #510
  • Loading branch information
anarcat committed Jan 15, 2025
1 parent 6429d6e commit fd421c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
Stdlib::Absolutepath $path = '/etc/systemd/system',
Optional[Variant[String, Sensitive[String], Deferred]] $content = undef,
Optional[String] $source = undef,
Optional[Stdlib::Absolutepath] $target = undef,
Optional[String] $target = undef,
String $owner = 'root',
String $group = 'root',
String $mode = '0444',
Expand Down

0 comments on commit fd421c9

Please sign in to comment.