Note
This plugin is part of the community.general collection.
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.launchd
.
New in version 1.0.0: of community.general
The below requirements are needed on the host that executes this module.
Parameter | Choices/Defaults | Comments |
---|---|---|
enabled boolean |
| Whether the service should start on boot. At least one of state and enabled are required. |
force_stop boolean |
| 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 yes to let this module change the 'KeepAlive' attribute to false. |
name string / required | Name of the service. | |
state string |
| started /stopped are idempotent actions that will not run commands unless necessary.Launchd does not support restarted nor reloaded natively. These will trigger a stop/start (restarted) or an unload/load (reloaded).restarted unloads and loads the service before start to ensure that the latest job definition (plist) is used.reloaded unloads and loads the service to ensure that the latest job definition (plist) is used. Whether a service is started or stopped depends on the content of the definition file. |
Note
- 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: yes - name: Restart memcached community.general.launchd: name: org.memcached state: restarted - name: Unload memcached community.general.launchd: name: org.memcached state: unloaded
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
status dictionary | always | Metadata about service status Sample: {'current_pid': '-', 'current_state': 'stopped', 'previous_pid': '82636', 'previous_state': 'running'} |
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/general/launchd_module.html