voxpupuli / puppet-systemd

Puppet module to manage systemd
https://forge.puppet.com/puppet/systemd
Apache License 2.0
52 stars 142 forks source link

Manage units running under `systemd --user` instance #446

Closed traylenator closed 3 months ago

traylenator commented 3 months ago

Pull Request (PR) description

New defined type systemd::user_service has two roles:

It can globally enable a user unit for all users. e.g:

systemd::user_service { 'systemd-tmpfiles-clean.service':
  enable => true,
  global => true,
}

It can start/stop/enable/disable a service running for a particular user. e.g

systemd::user_service { 'ssh-agent.socket':
  ensure => 'running',
  enable => true,
  user   => 'steve',
}

The type instance can also be notified to reload the unit running under a systemd --user instance.

file { '/home/steve/.gpg.conf':
  ensure  => file,
  content => 'custom',
  notify  => Systemd::User_service['steve-gpg-agent.socket'],
}

systemd::user_service { 'steve-gpg-agent.socket':
  ensure => true,
  unit   => 'gpg-agent.socket',
  enable => true,
  user   => 'steve',
}

Note that no notification of systemd::daemon_reload{'me': user => 'me'} is currently made at suitable points. Handle this later.

This Pull Request (PR) fixes the following issues

Fixes: #381 Fixes: #139 Fixes: #328