mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
validate-modules: Fix all system modules (#52384)
This PR includes validate-modules fixes for all system modules. Except a few that are deliberately implemented like this.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
# Copyright: (c) 2015, Brian Coca <bcoca@ansible.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
@@ -13,19 +13,20 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
|
||||
# This is a modification of @bcoca's `svc` module
|
||||
|
||||
DOCUMENTATION = '''
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: runit
|
||||
author:
|
||||
- James Sumners (@jsumners)
|
||||
version_added: "2.3"
|
||||
short_description: Manage runit services
|
||||
short_description: Manage runit services
|
||||
description:
|
||||
- Controls runit services on remote hosts using the sv utility.
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
- Name of the service to manage.
|
||||
type: str
|
||||
required: yes
|
||||
state:
|
||||
description:
|
||||
@@ -35,6 +36,7 @@ options:
|
||||
C(reloaded) will send a HUP (sv reload).
|
||||
C(once) will run a normally downed sv once (sv once), not really
|
||||
an idempotent operation.
|
||||
type: str
|
||||
choices: [ killed, once, reloaded, restarted, started, stopped ]
|
||||
enabled:
|
||||
description:
|
||||
@@ -43,14 +45,16 @@ options:
|
||||
service_dir:
|
||||
description:
|
||||
- directory runsv watches for services
|
||||
type: str
|
||||
default: /var/service
|
||||
service_src:
|
||||
description:
|
||||
- directory where services are defined, the source of symlinks to service_dir.
|
||||
type: str
|
||||
default: /etc/sv
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
EXAMPLES = r'''
|
||||
- name: Start sv dnscache, if not running
|
||||
runit:
|
||||
name: dnscache
|
||||
@@ -85,7 +89,6 @@ EXAMPLES = '''
|
||||
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
@@ -226,7 +229,7 @@ class Sv(object):
|
||||
try:
|
||||
(rc, out, err) = self.module.run_command(' '.join(cmd))
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg="failed to execute: %s" % to_native(e), exception=traceback.format_exc())
|
||||
self.module.fail_json(msg="failed to execute: %s" % to_native(e))
|
||||
return (rc, out, err)
|
||||
|
||||
def report(self):
|
||||
@@ -268,7 +271,7 @@ def main():
|
||||
else:
|
||||
sv.disable()
|
||||
except (OSError, IOError) as e:
|
||||
module.fail_json(msg="Could not change service link: %s" % to_native(e), exception=traceback.format_exc())
|
||||
module.fail_json(msg="Could not change service link: %s" % to_native(e))
|
||||
|
||||
if state is not None and state != sv.state:
|
||||
changed = True
|
||||
|
||||
Reference in New Issue
Block a user