Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_sys_reboot.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_sys_reboot
15 short_description: Restart FortiManager.
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 sys_reboot:
21 description: The top level parameters set.
22 required: false
23 type: dict
24 suboptions:
25 fmgr_message:
26 type: str
27 description: Optional message to be stored in event log.
28 '''
29
30 EXAMPLES = '''
31 - name: Example playbook (generated based on argument schema)
32 hosts: fortimanagers
33 connection: httpapi
34 gather_facts: false
35 tasks:
36 - name: Restart FortiManager.
37 fortinet.fortimanager.fmgr_sys_reboot:
38 # workspace_locking_adom: <global or your adom name>
39 sys_reboot:
40 # fmgr_message: <string>
41 '''
42
43 RETURN = '''
44 meta:
45 description: The result of the request.
46 type: dict
47 returned: always
48 contains:
49 request_url:
50 description: The full url requested.
51 returned: always
52 type: str
53 sample: /sys/login/user
54 response_code:
55 description: The status of api request.
56 returned: always
57 type: int
58 sample: 0
59 response_data:
60 description: The api response.
61 type: list
62 returned: always
63 response_message:
64 description: The descriptive message of the api response.
65 type: str
66 returned: always
67 sample: OK.
68 system_information:
69 description: The information of the target system.
70 type: dict
71 returned: always
72 rc:
73 description: The status the request.
74 type: int
75 returned: always
76 sample: 0
77 version_check_warning:
78 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
79 type: list
80 returned: complex
81 '''
82 from ansible.module_utils.basic import AnsibleModule
83 from ansible.module_utils.connection import Connection
84 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
85 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
86
87
88 def main():
89 urls_list = [
90 '/sys/reboot'
91 ]
92 module_arg_spec = {
93 'sys_reboot': {
94 'type': 'dict', 'v_range': [['6.2.5', '']],
95 'options': {'fmgr_message': {'v_range': [['6.2.5', '']], 'type': 'str'}}
96 }
97 }
98
99 module_option_spec = get_module_arg_spec('exec')
100 module_arg_spec.update(module_option_spec)
101 check_galaxy_version(module_arg_spec)
102 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'sys_reboot'),
103 supports_check_mode=True)
104 if not module._socket_path:
105 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
106 connection = Connection(module._socket_path)
107 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
108 None, 'data', module, connection)
109 fmgr.process_exec()
110 module.exit_json(meta=module.params)
111
112
113 if __name__ == '__main__':
114 main()