-
Notifications
You must be signed in to change notification settings - Fork 24k
add rc service module and sysrc utils #26251
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
Conversation
@bcoca Pinging you for an initial review as this is based on your previous work. This is an initial version, hoping it can be a starting point for a discussion. I called it rc_service for now as that is what you suggested. But the way I see it, this should be named specifically after FreeBSD as the other BSD's work in different ways. However, I see in |
Closing and re-opening to trigger CI. |
@thnee Can you include integration tests in your PR so we have test coverage for this? |
The test
|
@mattclay actually, the 'service' tests on BSD will already cover this as the action plugin should select this module automatically |
@thnee if the name is the issue we have 2 options, port the rest of 'bsd classes' that the old service module uses or alter the facts make the init system BSD flavor specific. I've engaged BUGs in the past about this topic and it seems pretty split with a slight majority in favor of the latter. |
|
||
|
||
def run_service(module, args): | ||
bin_path = module.get_bin_path('service', required=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not all versions of FreeBSD have the 'service' command, we should fallback to the rc script itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which versions are you thinking of specifically? The service
command was added in 7.3, which is not supported any more. Falling back to calling the rc script directly would mean that we would have to re-implement and maintain duplicated logic for finding local rc scripts in various directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had 8 and 9 installs w/o it ... but that was mostly cause previous admin avoided it as a 'linuxism', we do have the code for rc, but we can always add later of someone protests.
so ignore this point for now.
default: null | ||
choices: ['yes', 'no'] | ||
description: | ||
- Whether the service should be enabled using sysrc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some services take extra arguments, should we implement that field here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to suggest a different approach: We remove support for enabled
from this service module, and do not attempt to set any sysrc variables at all. Instead we add another module called sysrc
letting the user set any configuration they like, as sysrc
is only used on FreeBSD. This will simplify the modules and separate the concerns. This is what I am doing locally now, as this makes the most sense for me. What do you think?
In contrast: on OpenBSD, there is the rcctl utility, which does support enable
and disable
actions, if someone makes a module for that, it would make more sense to support enabled
argument in that module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would make it incompatible with the service interface
@bcoca Unfortunately we're not running the service tests on Shippable for FreeBSD. They weren't passing last time I checked, so they've been marked |
@mattclay well, we need those to work if we want BSD test coverage. |
The service integration test only has support for sysv, systemd and upstart currently. @thnee Could you update the test to support bsd-init as part of your PR so we can test in CI? Here's where the init system specific setup occurs: https://github.com/ansible/ansible/blob/devel/test/integration/targets/service/tasks/main.yml#L13 |
Thank you for your interest in Ansible! We are no longer accepting new plugins to ansible/ansible directly. Please re-file this pull request against https://www.github.com/ansible-collections/community.general. If you have further questions please stop by IRC or the mailing list:
|
SUMMARY
Adds a new module
rc_service
. This follows along the lines of separating modules fromservice.py
into new service modules, as previously done with thesystemd
module.ISSUE TYPE
COMPONENT NAME
modules/system/rc_service
module_utils/sysrc
ANSIBLE VERSION
ADDITIONAL INFORMATION