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
(PUP-2153) Add support for FreeBSD profiles #8607
Conversation
When a FreeBSD rc-script has support for profiles, when running it with the `rcvar` parameter the output is modified to list the profiles. With a single profile: ``` root@localhost # /usr/local/etc/rc.d/fcgiwrap rcvar ===> fcgiwrap profile: nagios # fcgiwrap # fcgiwrap_enable="YES" # (default: "") ``` With multiple profiles: ``` root@localhost # /usr/local/etc/rc.d/fcgiwrap rcvar ===> fcgiwrap profile: nagios1 # fcgiwrap # fcgiwrap_enable="YES" # (default: "") ===> fcgiwrap profile: nagios2 # fcgiwrap # fcgiwrap_enable="YES" # (default: "") ===> fcgiwrap profile: nagios3 # fcgiwrap # fcgiwrap_enable="YES" # (default: "") ``` Compare with the output for another service that has no support for profiles: ``` root@localhost # /usr/local/etc/rc.d/nagios rcvar # nagios # nagios_enable="YES" # (default: "") ``` Because the code assumes the rcvar is on a fixed line, the presence of the `===> <service> profile: <profile>` line breaks the parsing of the output. Adjust this by removing the profile information lines too.
Can one of the admins verify this patch? |
This comment has been minimized.
This comment has been minimized.
Thanks for the contribution @smortex! 🎉 Pasting from the ticket description, is this still a concern?
Can you also add a spec test to reflect this behavior? I'm thinking somewhere here: https://github.com/puppetlabs/puppet/blob/main/spec/unit/provider/service/freebsd_spec.rb#L28 Also, if you'd like this to get into puppet 6 as well, please rebase and retarget the PR to the |
Hum, I forgot about this and in my testing I removed unused profile instead of keeping them and disabling them. The profile management code is not a feature provided by the rc subsystem and used by some services, but directly something implemented into some services (with slight differences). The general logic is:
Also, some services have an optional support for profiles (e.g. postgresql)… A trivial one-size-fit-all solution seems complicated to find. However, detecting if a rc-script is using profiles or not seems to be feasible.
e.g. service { 'pounce-freenode':
ensure => stopped,
enable => false,
name => 'pounce',
profile => 'freenode',
}
service { 'pounce-libera':
ensure => running,
enable => true,
name => 'pounce',
profile => 'libera',
}
service { 'pounce-tilde':
ensure => running,
enable => true,
name => 'pounce',
profile => 'tilde',
} It would also make sense to manage the profiles from puppet too (with a feature to add manage custom variable specific to a service): service { 'pounce':
vars => {
profiles => 'freenode libera tilde',
}
} I can for sure work on this if it makes sense. @GabrielNagy can you please tell me what you think about this? |
Having a new However this would be a FreeBSD-only feature, which is why the Either way I think we'd end up with a new feature in the type that will only be implemented by FreeBSD for now, so maybe it would be best to go with the first approach and implement a top-level
In this case shouldn't it start all profiles? |
I've been thinking about this and come to the conclusion that a single service { 'pounce':
ensure => running,
enable => true,
vars => {
profiles => 'freenode libera tilde',
freenode_enable => 'NO',
freenode_user => 'romain',
libera_user => 'romain',
tilde_user => 'romain',
}
} This should produce the following config: pounce_enable="YES"
pounce_profiles="freenode libera tilde"
pounce_freenode_enable="NO"
pounce_freenode_user="romain"
pounce_libera_user="romain"
pounce_tilde_user="romain" and ensure the two enabled profiles are running and the third one is stopped. As a bonus, existing services which are a pain to configure on FreeBSD because the service provider cannot manage all custom variable they use could be enhanced… The code for managing old releases of FreeBSD might make things a bit funny, but I'll start with these requirements and try to do something with them. I'll update this PR when I am happy with the results. Thanks! |
Sounds good, I didn't know multiple variables/settings could be managed per service, so the |
@smortex checking to see if this something you're still wanting to work on as there are some merge conflicts. |
Hum, this is somewhat a niche topic, and while I hit this in 2021, I have lived without support for it since then and am not maintaining local patches so it can probably be ignored for now. |
Oh that is too bad. I'm monkey patching some of my rc.d files (uwsgi e.g.) to let puppet's service class work with them. I will have a look then |
@rvstaveren oh! According to the examples above, I looked into this when using irc/pounce at the time freenode exploded and wanted to have that old config around just in case. It looks like there are much more ports that have support for profiles today, a quick grep in The root issue is that when a profile is stopped, it prevents other profiles from being visible, e.g. romain@agrajag /usr/local/etc/rc.d % sudo service pounce status
===> pounce profile: debian
pounce is running as pid 66374.
===> pounce profile: libera
pounce is running as pid 66384.
===> pounce profile: tilde
pounce is running as pid 66394.
romain@agrajag /usr/local/etc/rc.d % sudo service pounce stop debian
Stopping pounce.
Waiting for PIDS: 66374.
romain@agrajag /usr/local/etc/rc.d % sudo service pounce status
===> pounce profile: debian
pounce is not running.
romain@agrajag /usr/local/etc/rc.d (1) % sudo service pounce start debian
Starting pounce.
romain@agrajag /usr/local/etc/rc.d % sudo service pounce status
===> pounce profile: debian
pounce is running as pid 89668.
===> pounce profile: libera
pounce is running as pid 66384.
===> pounce profile: tilde
pounce is running as pid 66394.
romain@agrajag /usr/local/etc/rc.d % After stopping the "debian" profile, status show this profile as not running and does not list the other two which are still running. Some work on the FreeBSD side seems required, and then work on the Puppet side must be done to cope with this. Given the number of services having profiles today, maybe it makes sense? What is your "monkey patching" doing? Does it work around the above issue? Maybe creating a review on FreeBSD's fabricator would make sense to review it and integrate it? |
When a FreeBSD rc-script has support for profiles, when running it with
the
rcvar
parameter the output is modified to list the profiles.With a single profile:
With multiple profiles:
Compare with the output for another service that has no support for
profiles:
Because the code assumes the rcvar is on a fixed line, the presence of
the
===> <service> profile: <profile>
line breaks the parsing of theoutput.
Adjust this by removing the profile information lines too.