community.general
community.general copied to clipboard
homebrew: Add support for services functions
Summary
I'd like to add support for things like:
brew services start foo
brew services stop foo
brew services restart foo
brew services kill foo
More than happy to implement it myself. But I am looking for some advice from the maintainers.
Issue Type
Feature Idea
Component Name
homebrew
Additional Information
Specifically, should I follow the current pattern of the update
function and add a service parameter to the current homebrew module? Or should I add a new homebrew_services
module?
I personally feel like a new module makes the most sense. Here are my current thoughts on the two choices:
Add a service
parameter
- name: Install foo package
homebrew:
name: foo
state: present
- name: Start the foo service
homebrew:
service: foo
service_state: present # brew services start foo
- name: Restart the foo service
homebrew:
service: foo
service_state: restarted # brew services restart foo
- name: Remove the foo service
homebrew:
service: foo
service_state: absent # brew services stop foo
- 👍 Somewhat consistent with existing patterns (though homebrew_cask module throws me a bit)
- 👍 Smaller PR, not adding a whole new module
- 👎 Kind of weird to allow
name:
andservice:
to both be defined. And while the order of operations is obvious (install before service), that all needs to be defined and maintained.
Add a homebrew_services
module
- name: Install foo package
homebrew:
name: foo
state: present
- name: Start the foo service
homebrew_service:
name: foo
state: present # brew services start foo
- name: Restart the foo service
homebrew_service:
name: foo
state: restarted # brew services restart foo
- name: Remove the foo service
homebrew_service:
name: foo
service_state: absent # brew services stop foo
- 👍 Allows for parameter names that remain consistent with other collections and modules in my (very light) research
- 👍 Organization would also be consistent with other collections (e.g. docker)
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @Akasurde @danieljaouen @indrajitr @kyleabenson @martinm82 click here for bot help
I'm not a homebrew user, but having a separate module is usually a better idea. Otherwise you eventually end up with 'monsters' such as docker_image, which has way too many options for way too many different operations. That makes the module's code pretty complex, and the module's documentation more confusing (you see a looong list of options and have to figure out which ones are actually relevant for your use-case).
!component =plugins/modules/homebrew
Files identified in the description:
-
plugins/modules/homebrew
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
!component =plugins/modules/homebrew.py !component +plugins/modules/homebrew_cask.py !component +plugins/modules/homebrew_tap.py
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @andrew-d @enriclluelles click here for bot help
Yup, sounds good to me. Hopefully be back within the week with a PR