community.general.homebrew_services 模块 – Homebrew 的服务管理器

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用: ansible-galaxy collection install community.general。您需要更多要求才能使用此模块,请参阅 要求 了解详细信息。

要在 playbook 中使用它,请指定: community.general.homebrew_services

community.general 9.3.0 中的新功能

概要

  • 通过 Homebrew 管理守护程序和服务。

要求

在执行此模块的主机上需要以下要求。

  • 目标系统上必须已安装 Homebrew

参数

参数

注释

name

别名: formula

字符串 / 必需

要更新其服务的已安装 Homebrew 包。

path

path

一个以 : 分隔的路径列表,用于搜索 brew 可执行文件。由于包(在 Homebrew 术语中为 *formula*)的位置是相对于 brew 命令的实际路径添加前缀的,因此提供备用的 brew 路径可以在系统中备用位置管理不同的包集。

默认: "/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin"

state

字符串

软件包服务的状态。

选项

  • "present" ← (默认)

  • "absent"

  • "restarted"

属性

属性

支持

描述

check_mode

支持: 完整

可以在 check_mode 中运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:

当处于 diff 模式时,将返回已更改(或可能需要在 check_mode 中更改)的详细信息。

示例

- 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_services:
    name: foo
    state: present

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

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

返回值

常见的返回值记录在 此处,以下是此模块特有的字段

描述

pid

整数

如果服务现在正在运行,则这是服务的 PID,否则为 -1。

返回: 成功

示例: 1234

running

布尔值

运行此命令后服务是否正在运行。

返回: 成功

示例: true

作者

  • Kit Ham (@kitizz)