community.general.launchd module – Manage macOS services
Note
This module is part of the community.general collection (version 8.6.4).
You might already have this collection installed if you are using the ansible
package.
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.launchd
.
New in community.general 1.0.0
Synopsis
Manage launchd services on target macOS hosts.
Aliases: system.launchd
Requirements
The below requirements are needed on the host that executes this module.
A system managed by launchd
The plistlib python library
Parameters
Parameter |
Comments |
---|---|
Whether the service should start on boot. At least one of state and enabled are required. Choices:
|
|
Whether the service should not be restarted automatically by launchd. Services might have the ‘KeepAlive’ attribute set to true in a launchd configuration. In case this is set to true, stopping a service will cause that launchd starts the service again. Set this option to Choices:
|
|
Name of the service. |
|
Launchd does not support
Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
A user must privileged to manage services using this module.
Examples
- 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
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Metadata about service status Returned: always Sample: |