#!/usr/bin/python from __future__ import absolute_import, division, print_function # Copyright 2019-2024 Fortinet, Inc. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) __metaclass__ = type ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'metadata_version': '1.1'} DOCUMENTATION = ''' --- module: fmgr_template short_description: Require device/vdom scope member version_added: "2.0.0" extends_documentation_fragment: - fortinet.fortimanager.general - fortinet.fortimanager.general.full_crud options: revision_note: description: The change note that can be specified when an object is created or updated. type: str adom: description: The parameter (adom) in requested url. type: str required: true template: description: The top level parameters set. required: false type: dict suboptions: description: type: str description: Description. modification_time: aliases: ['modification-time'] type: str description: Modification time. name: type: str description: Name. required: true script: type: str description: Script. provision: type: str description: Provision. choices: ['disable', 'enable'] type: type: str description: Type. choices: ['cli', 'jinja'] variables: type: raw description: (list) Variables. position: type: str description: Position. choices: ['post-vdom-copy', 'prep-vdom-copy'] option: type: list elements: str description: Option. choices: ['sdwan-overlay', 'sdwan-manager'] scope_member: aliases: ['scope member'] type: list elements: dict description: Scope member. suboptions: name: type: str description: Name. vdom: type: str description: Vdom. ''' EXAMPLES = ''' - name: Example playbook (generated based on argument schema) hosts: fortimanagers connection: httpapi gather_facts: false tasks: - name: Require device/vdom scope member fortinet.fortimanager.fmgr_template: # workspace_locking_adom: adom: state: present # template: name: "your value" # Required variable, string # description: # modification_time: # script: # provision: # type: # variables: # position: # option: ["sdwan-overlay", "sdwan-manager"] # scope_member: # - name: # vdom: ''' RETURN = ''' meta: description: The result of the request. type: dict returned: always contains: request_url: description: The full url requested. returned: always type: str sample: /sys/login/user response_code: description: The status of api request. returned: always type: int sample: 0 response_data: description: The api response. type: list returned: always response_message: description: The descriptive message of the api response. type: str returned: always sample: OK. system_information: description: The information of the target system. type: dict returned: always rc: description: The status the request. type: int returned: always sample: 0 version_check_warning: description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. type: list returned: complex ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.connection import Connection from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec def main(): urls_list = [ '/pm/config/adom/{adom}/obj/cli/template', '/pm/config/global/obj/cli/template' ] module_arg_spec = { 'adom': {'required': True, 'type': 'str'}, 'revision_note': {'type': 'str'}, 'template': { 'type': 'dict', 'v_range': [['6.0.0', '']], 'options': { 'description': {'type': 'str'}, 'modification-time': {'v_range': [['6.0.0', '7.0.3']], 'type': 'str'}, 'name': {'required': True, 'type': 'str'}, 'script': {'type': 'str'}, 'provision': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, 'type': {'v_range': [['7.0.1', '']], 'choices': ['cli', 'jinja'], 'type': 'str'}, 'variables': {'v_range': [['7.0.1', '']], 'type': 'raw'}, 'position': {'v_range': [['7.4.2', '']], 'choices': ['post-vdom-copy', 'prep-vdom-copy'], 'type': 'str'}, 'option': {'v_range': [['7.6.0', '']], 'type': 'list', 'choices': ['sdwan-overlay', 'sdwan-manager'], 'elements': 'str'}, 'scope member': { 'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'options': { 'name': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'}, 'vdom': {'v_range': [['7.4.7', '7.4.10'], ['7.6.4', '']], 'type': 'str'} }, 'elements': 'dict' } } } } module_option_spec = get_module_arg_spec('full crud') module_arg_spec.update(module_option_spec) check_galaxy_version(module_arg_spec) module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'template'), supports_check_mode=True) if not module._socket_path: module.fail_json(msg='MUST RUN IN HTTPAPI MODE') connection = Connection(module._socket_path) fmgr = NAPIManager('full crud', module_arg_spec, urls_list, 'name', 'data', module, connection) fmgr.process_crud() module.exit_json(meta=module.params) if __name__ == '__main__': main()