community.openwrt.service module – Manage services on OpenWrt targets

Note

This module is part of the community.openwrt collection (version 0.5.0).

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.openwrt.

To use it in a playbook, specify: community.openwrt.service.

Synopsis

  • The community.openwrt.service module controls services on OpenWrt using init scripts.

  • It can start, stop, restart, reload services and manage their enabled state.

Note

This module has a corresponding action plugin.

Parameters

Parameter

Comments

enabled

boolean

Whether the service should start on boot.

Choices:

  • false

  • true

name

string / required

Name of the service.

Corresponds to the init script name in /etc/init.d/.

pattern

string

Pattern to search for in the process table to determine if the service is running.

If specified, this pattern is used with pgrep instead of the init script’s running command.

state

string

Desired state of the service.

Choices:

  • "reloaded"

  • "restarted"

  • "started"

  • "stopped"

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

platform

Platform: OpenWrt

Target platform for this module.

Examples

- name: Start the network service
  community.openwrt.service:
    name: network
    state: started

- name: Stop the firewall service
  community.openwrt.service:
    name: firewall
    state: stopped

- name: Restart the dnsmasq service
  community.openwrt.service:
    name: dnsmasq
    state: restarted

- name: Enable a service to start on boot
  community.openwrt.service:
    name: uhttpd
    enabled: true

- name: Disable a service from starting on boot
  community.openwrt.service:
    name: telnet
    enabled: false

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

enabled

string

Whether the service is enabled to start on boot.

Returned: when enabled is specified

Sample: "yes"

name

string

The name of the service.

Returned: always

Sample: "network"

state

string

The current state of the service.

Returned: when state is specified

Sample: "started"

Authors

  • Markus Weippert (@gekmihesg)