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

Manage units running under systemd --user instance #446

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

traylenator
Copy link
Contributor

@traylenator traylenator commented Apr 7, 2024

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

New defined type `systemd::user_service` has two roles:

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

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

If 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.

```puppet
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,
  enable => true,
  user   => 'steve',
}
```

Note - This merge request does not attempt to notify a
`systemd::daemon-reload{'user': user => 'steve'} instance at
the appropriate points. Solve that with real world experience.
@traylenator traylenator changed the title Manage unit running under systemd --user instance Manage units running under systemd --user instance Apr 7, 2024
manifests/user_service.pp Outdated Show resolved Hide resolved
@traylenator traylenator merged commit 17ccd4e into voxpupuli:master Apr 8, 2024
35 checks passed
@traylenator traylenator deleted the userunit branch April 8, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants