Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_ha_peer.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_system_ha_peer
15 short_description: Peer.
16 version_added: "1.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 system_ha_peer:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 id:
27 type: int
28 description: Id.
29 required: true
30 ip:
31 type: str
32 description: IP address of peer.
33 ip6:
34 type: str
35 description: IP address
36 serial_number:
37 aliases: ['serial-number']
38 type: str
39 description: Serial number of peer.
40 '''
41
42 EXAMPLES = '''
43 - name: Example playbook
44 hosts: fortimanagers
45 gather_facts: false
46 connection: httpapi
47 vars:
48 ansible_httpapi_use_ssl: true
49 ansible_httpapi_validate_certs: false
50 ansible_httpapi_port: 443
51 tasks:
52 - name: Peer.
53 fortinet.fortimanager.fmgr_system_ha_peer:
54 bypass_validation: false
55 state: present
56 system_ha_peer:
57 id: 3
58 ip: "11.11.11.5" # Required, could not be 0.0.0.0
59 serial_number: FMG-VM0000000003 # need a valid serial number
60
61 - name: Gathering fortimanager facts
62 hosts: fortimanagers
63 gather_facts: false
64 connection: httpapi
65 vars:
66 ansible_httpapi_use_ssl: true
67 ansible_httpapi_validate_certs: false
68 ansible_httpapi_port: 443
69 tasks:
70 - name: Retrieve all the HA peers
71 fortinet.fortimanager.fmgr_fact:
72 facts:
73 selector: "system_ha_peer"
74 params:
75 peer: "your_value"
76 '''
77
78 RETURN = '''
79 meta:
80 description: The result of the request.
81 type: dict
82 returned: always
83 contains:
84 request_url:
85 description: The full url requested.
86 returned: always
87 type: str
88 sample: /sys/login/user
89 response_code:
90 description: The status of api request.
91 returned: always
92 type: int
93 sample: 0
94 response_data:
95 description: The api response.
96 type: list
97 returned: always
98 response_message:
99 description: The descriptive message of the api response.
100 type: str
101 returned: always
102 sample: OK.
103 system_information:
104 description: The information of the target system.
105 type: dict
106 returned: always
107 rc:
108 description: The status the request.
109 type: int
110 returned: always
111 sample: 0
112 version_check_warning:
113 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
114 type: list
115 returned: complex
116 '''
117 from ansible.module_utils.basic import AnsibleModule
118 from ansible.module_utils.connection import Connection
119 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
120 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
121
122
123 def main():
124 urls_list = [
125 '/cli/global/system/ha/peer'
126 ]
127 module_arg_spec = {
128 'system_ha_peer': {
129 'type': 'dict', 'v_range': [['6.0.0', '']],
130 'options': {'id': {'required': True, 'type': 'int'}, 'ip': {'type': 'str'}, 'ip6': {'type': 'str'}, 'serial-number': {'type': 'str'}}
131 }
132 }
133
134 module_option_spec = get_module_arg_spec('full crud')
135 module_arg_spec.update(module_option_spec)
136 check_galaxy_version(module_arg_spec)
137 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_ha_peer'),
138 supports_check_mode=True)
139 if not module._socket_path:
140 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
141 connection = Connection(module._socket_path)
142 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
143 'id', 'data', module, connection)
144 fmgr.process_crud()
145 module.exit_json(meta=module.params)
146
147
148 if __name__ == '__main__':
149 main()