community.general.runit 模块 – 管理 runit 服务

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定:community.general.runit

概要

  • 使用 sv 实用程序控制远程主机上的 runit 服务。

参数

参数

注释

enabled

布尔值

服务是否已启用,如果禁用,则也意味着已停止。

选项

  • false

  • true

name

字符串 / 必需

要管理的服务名称。

service_dir

字符串

runsv 监视服务的目录

默认值: "/var/service"

service_src

字符串

定义服务的目录,指向 service_dir 的符号链接的源。

默认值: "/etc/sv"

state

字符串

started/stopped 是幂等操作,除非必要,否则不会运行命令。restarted 将始终反弹服务(sv restart),killed 将始终反弹服务(sv force-stop)。reloaded 将发送 HUP(sv reload)。once 将运行通常关闭的 sv 一次(sv once),这不是一个真正的幂等操作。

选项

  • "killed"

  • "once"

  • "reloaded"

  • "restarted"

  • "started"

  • "stopped"

属性

属性

支持

描述

check_mode

支持:完全

可以在 check_mode 中运行,并返回更改状态预测,而无需修改目标。

diff_mode

支持:

在 diff 模式下,将返回有关已更改(或可能需要在 check_mode 中更改)的详细信息。

示例

- name: Start sv dnscache, if not running
  community.general.runit:
    name: dnscache
    state: started

- name: Stop sv dnscache, if running
  community.general.runit:
    name: dnscache
    state: stopped

- name: Kill sv dnscache, in all cases
  community.general.runit:
    name: dnscache
    state: killed

- name: Restart sv dnscache, in all cases
  community.general.runit:
    name: dnscache
    state: restarted

- name: Reload sv dnscache, in all cases
  community.general.runit:
    name: dnscache
    state: reloaded

- name: Use alternative sv directory location
  community.general.runit:
    name: dnscache
    state: reloaded
    service_dir: /run/service

作者

  • James Sumners (@jsumners)