community.general.nosh – Manage services with nosh
Note
This plugin is part of the community.general collection (version 3.8.3).
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
.
To use it in a playbook, specify: community.general.nosh
.
Synopsis
Control running and enabled state for system-wide or user services.
BSD and Linux systems are supported.
Requirements
The below requirements are needed on the host that executes this module.
A system with an active nosh service manager, see Notes for further information.
Parameters
Parameter |
Comments |
---|---|
Enable or disable the service, independently of Choices:
|
|
Name of the service to manage. |
|
Enable or disable the service according to local preferences in Choices:
|
|
Choices:
|
|
Run system-control talking to the calling user’s service manager, rather than the system-wide service manager. Choices:
|
Notes
Note
Information on the nosh utilities suite may be found at https://jdebp.eu/Softwares/nosh/.
Examples
- name: Start dnscache if not running
community.general.nosh: name=dnscache state=started
- name: Stop mpd, if running
community.general.nosh: name=mpd state=stopped
- name: Restart unbound or start it if not already running
community.general.nosh:
name: unbound
state: restarted
- name: Reload fail2ban or start it if not already running
community.general.nosh:
name: fail2ban
state: reloaded
- name: Disable nsd
community.general.nosh: name=nsd enabled=no
- name: For package installers, set nginx running state according to local enable settings, preset and reset
community.general.nosh: name=nginx preset=True state=reset
- name: Reboot the host if nosh is the system manager, would need a "wait_for*" task at least, not recommended as-is
community.general.nosh: name=reboot state=started
- name: Using conditionals with the module facts
tasks:
- name: Obtain information on tinydns service
community.general.nosh: name=tinydns
register: result
- name: Fail if service not loaded
ansible.builtin.fail: msg="The {{ result.name }} service is not loaded"
when: not result.status
- name: Fail if service is running
ansible.builtin.fail: msg="The {{ result.name }} service is running"
when: result.status and result.status['DaemontoolsEncoreState'] == "running"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
whether the service is enabled at system bootstrap Returned: success Sample: true |
|
name used to find the service Returned: success Sample: “sshd” |
|
whether the enabled status reflects the one set in the relevant Returned: success Sample: “False” |
|
resolved path for the service Returned: success Sample: “/var/sv/sshd” |
|
service process run state, Returned: if state option is used Sample: “reloaded” |
|
a dictionary with the key=value pairs returned by system-control show-json or Returned: success |
|
Returned: success Sample: [“/etc/service-bundles/targets/basic”, “../sshdgenkeys”, “log”] |
|
Returned: success Sample: [“/etc/service-bundles/targets/shutdown”] |
|
Returned: success Sample: “[]” |
|
Returned: success Sample: “running” |
|
Returned: success Sample: “up” |
|
Returned: success Sample: true |
|
Returned: success Sample: “../cyclog@sshd” |
|
Returned: success Sample: 661 |
|
Returned: success Sample: “False” |
|
Returned: success Sample: “False” |
|
Returned: success Sample: “False” |
|
Returned: success Sample: “[]” |
|
Returned: success Sample: “0” |
|
Returned: success Sample: “0” |
|
Returned: success Sample: 4611686019935648081 |
|
Returned: success Sample: 1508260140 |
|
Returned: success Sample: “0” |
|
Returned: success Sample: “0” |
|
Returned: success Sample: 4611686019935648081 |
|
Returned: success Sample: 1508260140 |
|
Returned: success Sample: 1 |
|
Returned: success Sample: “0” |
|
Returned: success Sample: 4611686019935648081 |
|
Returned: success Sample: 1508260140 |
|
Returned: success Sample: “0” |
|
Returned: success Sample: “0” |
|
Returned: success Sample: [“/etc/service-bundles/targets/shutdown”] |
|
Returned: success Sample: 4611686019935648081 |
|
Returned: success Sample: 1508260140 |
|
Returned: success Sample: 4611686019935648081 |
|
Returned: success Sample: 1508260140 |
|
Returned: success Sample: “nothing” |
|
Returned: success Sample: [“/etc/service-bundles/targets/server”, “/etc/service-bundles/targets/sockets”] |
|
Returned: success Sample: [“/etc/service-bundles/targets/basic”, “../sshdgenkeys”] |
|
whether the user-level service manager is called Returned: success Sample: false |
Authors
Thomas Caravia (@tacatac)