# Looking for guidance for a new \`homebrew\_service\` module

**URL:** <https://forum.ansible.com/t/looking-for-guidance-for-a-new-homebrew-service-module/32124>\
**Category:** Ansible Developer\
**Created:** [February 3, 2020, 9:29pm UTC](https://forum.ansible.com/t/looking-for-guidance-for-a-new-homebrew-service-module/32124 "2020-02-03T21:29:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Bestle](https://avatars.discourse-cdn.com/v4/letter/l/ac91a4/32.png) [@Lukas\_Bestle](https://forum.ansible.com/u/Lukas_Bestle)\
**Post date:** [February 3, 2020, 9:29pm UTC](https://forum.ansible.com/t/looking-for-guidance-for-a-new-homebrew-service-module/32124/1 "2020-02-03T21:29:10Z")

</div>

Hi everyone,

I’m currently working on a module to manage system services with the `homebrew services` command. Basically it allows to start, stop, enable and restart services of packages that have been installed using the Homebrew package manager.

The underlying tool doesn’t support all possible states of the other service-type Ansible modules, so I need to develop a simplified module interface for the `homebrew_service` module. I’m looking for guidance from core devs whether the module would be mergeable with the interface I’m planning.

Here’s a draft of my current module interface:

`

DOCUMENTATION = ‘’’  
module: homebrew\_service  
short\_description: Manage services of Homebrew formulae  
description:

- Controls services of Homebrew formulae using the C(brew services) command.  
version\_added: “2.10”  
author:
- Lukas Bestle (@lukasbestle)  
options:  
name:  
description:
- Name of the Homebrew formula that provides the service.  
type: str  
required: true  
state:  
description:
- C(started)/C(stopped) are idempotent actions that will not run  
commands unless necessary.
- C(restarted) will always bounce the service.  
type: str  
choices: [restarted, started, stopped]  
required: true  
enabled:  
description:
- Whether the service should start on login/boot.
- B(Note) that switching a running service between being enabled and disabled  
requires restarting the service. The restart will be performed automatically.
- B(Note) that you cannot set I(state=stopped) together with I(enabled=yes) as  
stopping a Homebrew service automatically disables it.
- “The default value is: for I(state=started): C(yes); for I(state=stopped): C(no);  
for I(state=restarted): keep the current value.”  
type: bool  
requirements:
- macOS (Homebrew on Linux is _not_ supported).
- Homebrew must already be installed on the target system.  
notes:
- This module supports C(check\_mode).  
‘’’

EXAMPLES = ‘’’

- name: Start service httpd on each login and start it now, if not started  
homebrew\_service:  
name: httpd  
state: started

- name: Start service httpd in this session, if not started  
homebrew\_service:  
name: httpd  
state: started  
enabled: no

- name: Start service dnsmasq as a system service on each boot and start it now, if not started  
homebrew\_service:  
name: dnsmasq  
state: started  
become: yes

- name: Stop service httpd, if started  
homebrew\_service:  
name: httpd  
state: stopped

- name: Stop system service dnsmasq, if started  
homebrew\_service:  
name: dnsmasq  
state: stopped  
become: yes

- name: Restart service httpd, in all cases  
homebrew\_service:  
name: httpd  
state: restarted

- name: Ensure that the service httpd is enabled and restart it, in all cases  
homebrew\_service:  
name: httpd  
state: restarted  
enabled: yes  
‘’’

`

Would this interface be alright for this module to get merged? Or is it a problem that the interface is slightly inconsistent with the other service-type modules? What I want to avoid is that I develop the module and it won’t get merged because the features differ from the other modules (which has happened with the launchd module before).

I look forward to your opinions and your feedback.

Cheers,  
Lukas

---

<div class="post-metadata">

**Author:** ![td784](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@td784](https://forum.ansible.com/u/td784)\
**Post date:** [February 3, 2020, 9:40pm UTC](https://forum.ansible.com/t/looking-for-guidance-for-a-new-homebrew-service-module/32124/2 "2020-02-03T21:40:44Z")

</div>

Hi Lukas,

I would suggest looking to make it an Ansible collection. With talking to the core team, it seems that collections are being pushed more and more due to back ups in the core Ansible project PR process.

Take a look here for more details:

[https://docs.ansible.com/ansible/latest/user\_guide/collections\_using.html](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html)
