community.general.homebrew_services module – Services manager for Homebrew

Note

This module is part of the community.general collection (version 9.4.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.homebrew_services.

New in community.general 9.3.0

Synopsis

  • Manages daemons and services via Homebrew.

Requirements

The below requirements are needed on the host that executes this module.

  • homebrew must already be installed on the target system

Parameters

Parameter

Comments

name

aliases: formula

string / required

An installed homebrew package whose service is to be updated.

path

path

A : separated list of paths to search for brew executable. Since a package (formula in homebrew parlance) location is prefixed relative to the actual path of brew command, providing an alternative brew path enables managing different set of packages in an alternative location in the system.

Default: "/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin"

state

string

State of the package’s service.

Choices:

  • "present" ← (default)

  • "absent"

  • "restarted"

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Install foo package
  community.general.homebrew:
    name: foo
    state: present

- name: Start the foo service (equivalent to `brew services start foo`)
  community.general.homebrew_service:
    name: foo
    state: present

- name: Restart the foo service (equivalent to `brew services restart foo`)
  community.general.homebrew_service:
    name: foo
    state: restarted

- name: Remove the foo service (equivalent to `brew services stop foo`)
  community.general.homebrew_service:
    name: foo
    service_state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

pid

integer

If the service is now running, this is the PID of the service, otherwise -1.

Returned: success

Sample: 1234

running

boolean

Whether the service is running after running this command.

Returned: success

Sample: true

Authors

  • Kit Ham (@kitizz)