ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
831 stars 1.53k forks source link

homebrew: Add support for services functions #8286

Closed kitizz closed 3 months ago

kitizz commented 6 months ago

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

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

Code of Conduct

ansibullbot commented 6 months ago

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.

click here for bot help

ansibullbot commented 6 months ago

cc @Akasurde @danieljaouen @indrajitr @kyleabenson @martinm82 click here for bot help

felixfontein commented 6 months ago

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

felixfontein commented 6 months ago

!component =plugins/modules/homebrew

ansibullbot commented 6 months ago

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.

click here for bot help

felixfontein commented 6 months ago

!component =plugins/modules/homebrew.py !component +plugins/modules/homebrew_cask.py !component +plugins/modules/homebrew_tap.py

ansibullbot commented 6 months ago

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.

click here for bot help

ansibullbot commented 6 months ago

cc @andrew-d @enriclluelles click here for bot help

kitizz commented 6 months ago

Yup, sounds good to me. Hopefully be back within the week with a PR