Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit_file: allow arbitrary symlink targets #511

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anarcat
Copy link

@anarcat anarcat commented Jan 15, 2025

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[pgbackrest-backup-full@rude.service]: 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

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[pgbackrest-backup-full@rude.service]: 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: voxpupuli#510
@@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string isn't valid here, right?

Suggested change
Optional[String] $target = undef,
Optional[String[1]] $target = undef,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unit_file should accept relative paths
2 participants