community.general.launchd 模块 – 管理 macOS 服务
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要进一步的要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定:community.general.launchd
。
community.general 1.0.0 中的新功能
概要
管理目标 macOS 主机上的 launchd 服务。
要求
以下要求需要在执行此模块的主机上满足。
由 launchd 管理的系统
plistlib python 库
参数
参数 |
注释 |
---|---|
服务是否应在启动时启动。 至少需要 state 和 enabled 之一。 选项
|
|
该服务是否不应由 launchd 自动重启。 服务可能会在 launchd 配置中将“KeepAlive”属性设置为 true。如果设置为 true,停止服务将导致 launchd 再次启动该服务。 将此选项设置为 选项
|
|
服务名称。 |
|
服务的 默认为 |
|
Launchd 本身不支持
选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持:完全 |
可以在 |
|
支持:无 |
在 diff 模式下运行时,将返回有关已更改的内容(或在 |
注释
注意
用户必须具有特权才能使用此模块管理服务。
示例
- name: Make sure spotify webhelper is started
community.general.launchd:
name: com.spotify.webhelper
state: started
- name: Deploy custom memcached job definition
template:
src: org.memcached.plist.j2
dest: /Library/LaunchDaemons/org.memcached.plist
- name: Run memcached
community.general.launchd:
name: org.memcached
state: started
- name: Stop memcached
community.general.launchd:
name: org.memcached
state: stopped
- name: Stop memcached
community.general.launchd:
name: org.memcached
state: stopped
force_stop: true
- name: Restart memcached
community.general.launchd:
name: org.memcached
state: restarted
- name: Unload memcached
community.general.launchd:
name: org.memcached
state: unloaded
- name: restart sshd
community.general.launchd:
name: com.openssh.sshd
plist: ssh.plist
state: restarted
返回值
常见的返回值记录在此处,以下是此模块独有的字段
键 |
描述 |
---|---|
关于服务状态的元数据 返回: 始终 示例: |