| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 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_dns |
| 15 |
short_description: DNS configuration. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
system_dns: |
| 22 |
description: The top level parameters set. |
| 23 |
required: false |
| 24 |
type: dict |
| 25 |
suboptions: |
| 26 |
ip6_primary: |
| 27 |
aliases: ['ip6-primary'] |
| 28 |
type: str |
| 29 |
description: IPv6 primary DNS IP. |
| 30 |
ip6_secondary: |
| 31 |
aliases: ['ip6-secondary'] |
| 32 |
type: str |
| 33 |
description: IPv6 secondary DNS IP. |
| 34 |
primary: |
| 35 |
type: str |
| 36 |
description: Primary DNS IP. |
| 37 |
secondary: |
| 38 |
type: str |
| 39 |
description: Secondary DNS IP. |
| 40 |
''' |
| 41 |
|
| 42 |
EXAMPLES = ''' |
| 43 |
- name: Example playbook (generated based on argument schema) |
| 44 |
hosts: fortimanagers |
| 45 |
connection: httpapi |
| 46 |
gather_facts: false |
| 47 |
tasks: |
| 48 |
- name: DNS configuration. |
| 49 |
fortinet.fortimanager.fmgr_system_dns: |
| 50 |
# workspace_locking_adom: <global or your adom name> |
| 51 |
system_dns: |
| 52 |
# ip6_primary: <string> |
| 53 |
# ip6_secondary: <string> |
| 54 |
# primary: <string> |
| 55 |
# secondary: <string> |
| 56 |
''' |
| 57 |
|
| 58 |
RETURN = ''' |
| 59 |
meta: |
| 60 |
description: The result of the request. |
| 61 |
type: dict |
| 62 |
returned: always |
| 63 |
contains: |
| 64 |
request_url: |
| 65 |
description: The full url requested. |
| 66 |
returned: always |
| 67 |
type: str |
| 68 |
sample: /sys/login/user |
| 69 |
response_code: |
| 70 |
description: The status of api request. |
| 71 |
returned: always |
| 72 |
type: int |
| 73 |
sample: 0 |
| 74 |
response_data: |
| 75 |
description: The api response. |
| 76 |
type: list |
| 77 |
returned: always |
| 78 |
response_message: |
| 79 |
description: The descriptive message of the api response. |
| 80 |
type: str |
| 81 |
returned: always |
| 82 |
sample: OK. |
| 83 |
system_information: |
| 84 |
description: The information of the target system. |
| 85 |
type: dict |
| 86 |
returned: always |
| 87 |
rc: |
| 88 |
description: The status the request. |
| 89 |
type: int |
| 90 |
returned: always |
| 91 |
sample: 0 |
| 92 |
version_check_warning: |
| 93 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 94 |
type: list |
| 95 |
returned: complex |
| 96 |
''' |
| 97 |
from ansible.module_utils.basic import AnsibleModule |
| 98 |
from ansible.module_utils.connection import Connection |
| 99 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 100 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 101 |
|
| 102 |
|
| 103 |
def main(): |
| 104 |
urls_list = [ |
| 105 |
'/cli/global/system/dns' |
| 106 |
] |
| 107 |
module_arg_spec = { |
| 108 |
'system_dns': { |
| 109 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 110 |
'options': {'ip6-primary': {'type': 'str'}, 'ip6-secondary': {'type': 'str'}, 'primary': {'type': 'str'}, 'secondary': {'type': 'str'}} |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
module_option_spec = get_module_arg_spec('partial crud') |
| 115 |
module_arg_spec.update(module_option_spec) |
| 116 |
check_galaxy_version(module_arg_spec) |
| 117 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_dns'), |
| 118 |
supports_check_mode=True) |
| 119 |
if not module._socket_path: |
| 120 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 121 |
connection = Connection(module._socket_path) |
| 122 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 123 |
None, 'data', module, connection) |
| 124 |
fmgr.process_partial_crud() |
| 125 |
module.exit_json(meta=module.params) |
| 126 |
|
| 127 |
|
| 128 |
if __name__ == '__main__': |
| 129 |
main() |