:source: fortios_json_generic.py :orphan: .. : .. _fortios_json_generic: fortios_json_generic -- Configure Fortinet's FortiOS and FortiGate with json generic method. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. contents:: :local: :depth: 1 Synopsis -------- This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the user to set any category supported by FortiAPI with raw json. All parameters and values included in examples need to be adjusted to datasources before usage. Requirements ------------- The below requirements are needed on the host that executes this module. - install galaxy collection ``fortinet.fortios`` >= 2.0.0 Parameters ---------- .. raw:: html Examples -------- **host** .. code-block:: yaml+jinja [fortigates] fortigate01 ansible_host=192.168.52.177 ansible_user="admin" ansible_password="admin" [fortigates:vars] ansible_network_os=fortios **sample1.yml** .. code-block:: yaml+jinja --- - hosts: fortigates connection: httpapi collections: - fortinet.fortios vars: vdom: "root" ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false ansible_httpapi_port: 443 tasks: - name: test add with string fortios_json_generic: vdom: "{{ vdom }}" json_generic: method: "POST" path: "/api/v2/cmdb/firewall/address" jsonbody: | { "name": "111", "type": "geography", "fqdn": "", "country": "AL", "comment": "ccc", "visibility": "enable", "associated-interface": "port1", "allow-routing": "disable" } register: info - name: display vars debug: msg="{{info}}" **sample2.yml** .. code-block:: yaml+jinja --- - hosts: fortigates connection: httpapi collections: - fortinet.fortios vars: vdom: "root" ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false ansible_httpapi_port: 443 tasks: - name: test delete fortios_json_generic: vdom: "{{ vdom }}" json_generic: method: "DELETE" path: "/api/v2/cmdb/firewall/address/111" specialparams: "testpara1=1&testpara2=2" register: info - name: display vars debug: msg="{{info}}" - name: test add with dict fortios_json_generic: vdom: "{{ vdom }}" json_generic: method: "POST" path: "/api/v2/cmdb/firewall/address" dictbody: name: "111" type: "geography" fqdn: "" country: "AL" comment: "ccc" visibility: "enable" associated-interface: "port1" allow-routing: "disable" register: info - name: display vars debug: msg="{{info}}" - name: test delete fortios_json_generic: vdom: "{{ vdom }}" json_generic: method: "DELETE" path: "/api/v2/cmdb/firewall/address/111" register: info - name: display vars debug: msg="{{info}}" - name: test add with string fortios_json_generic: vdom: "{{ vdom }}" json_generic: method: "POST" path: "/api/v2/cmdb/firewall/address" jsonbody: | { "name": "111", "type": "geography", "fqdn": "", "country": "AL", "comment": "ccc", "visibility": "enable", "associated-interface": "port1", "allow-routing": "disable" } register: info - name: display vars debug: msg="{{info}}" **sample3.yml** .. code-block:: yaml+jinja --- - hosts: fortigates collections: - fortinet.fortios connection: httpapi vars: vdom: "root" ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false ansible_httpapi_port: 443 tasks: - name: test firewall policy order modification fortios_json_generic: vdom: "{{ vdom }}" json_generic: method: "PUT" path: "/api/v2/cmdb/firewall/policy/1" specialparams: "action=move&after=2" register: info - name: display vars debug: msg="{{info}}" Return Values ------------- Common return values are documented: https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values, the following are the fields unique to this module: .. raw:: html Status ------ - This module is ported from https://github.com/fortinet/ansible-fortios-generic Authors ------- - Link Zheng (@chillancezen) - Jie Xue (@JieX19) - Frank Shen (@fshen01) - Hongbin Lu (@fgtdev-hblu) Warning ------- It's preferred to use ``FortiOS Ansible Collection Included Modules`` unless some features are not available there.