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

homebrew: Add support for services functions #8286

Open
1 task done
kitizz opened this issue Apr 27, 2024 · 9 comments · May be fixed by #8329
Open
1 task done

homebrew: Add support for services functions #8286

kitizz opened this issue Apr 27, 2024 · 9 comments · May be fixed by #8329
Labels
callback callback plugin feature This issue/PR relates to a feature request module module plugins plugin (any type)

Comments

@kitizz
Copy link
Contributor

kitizz commented Apr 27, 2024

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: and service: 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

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

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
Copy link
Collaborator

@ansibullbot ansibullbot added callback callback plugin feature This issue/PR relates to a feature request plugins plugin (any type) labels Apr 27, 2024
@felixfontein
Copy link
Collaborator

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

This comment was marked as outdated.

@ansibullbot

This comment was marked as outdated.

@ansibullbot ansibullbot added the module module label Apr 28, 2024
@felixfontein
Copy link
Collaborator

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

@ansibullbot
Copy link
Collaborator

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
Copy link
Collaborator

@kitizz
Copy link
Contributor Author

kitizz commented Apr 29, 2024

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

kitizz added a commit to kitizz/community.general that referenced this issue May 7, 2024
Fixes ansible-collections#8286.
Add a homebrew.services module for starting and stopping services
that are attached to homebrew packages.
@kitizz kitizz linked a pull request May 7, 2024 that will close this issue
kitizz added a commit to kitizz/community.general that referenced this issue May 7, 2024
Fixes ansible-collections#8286.
Add a homebrew.services module for starting and stopping services
that are attached to homebrew packages.
kitizz added a commit to kitizz/community.general that referenced this issue May 12, 2024
Fixes ansible-collections#8286.
Add a homebrew.services module for starting and stopping services
that are attached to homebrew packages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback callback plugin feature This issue/PR relates to a feature request module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants