fortiswitch_json_generic – Configure Fortinet’s FortiSwitch with json generic method.

Synopsis

This module is able to configure a FortiSwitch 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.fortiswitch >= 1.2.5

Parameters

  • enable_log - Enable/Disable logging for task. type: bool required: False default: False
  • json_generic - json generic default: null type: dict
    • dictbody - Body with YAML list of key/value format type: dict
    • jsonbody - Body with JSON string format, will always give priority to jsonbody type: str
    • method - HTTP methods type: str choices: GET, PUT, POST, DELETE
    • path - URL path, e.g./api/v2/cmdb/firewall/address type: str
    • specialparams - Extra URL parameters, e.g.start=1&count=10 type: str

Examples

host

[fortiswitches]
fortiswitch01 ansible_host=192.168.52.177 ansible_user="admin" ansible_password="your_password"

[fortiswitches:vars]
ansible_network_os=fortinet.fortiswitch.fortiswitch

sample1.yml

---
- hosts: fortiswitches
  connection: httpapi
  collections:
    - fortinet.fortiswitch
  vars:
   ansible_httpapi_use_ssl: true
   ansible_httpapi_validate_certs: false
   ansible_httpapi_port: 443

  tasks:
  - name: test add with string
    fortiswitch_json_generic:
      enable_log: True
      json_generic:
        method: "PUT"
        path: "/api/v2/cmdb/system/global"
        jsonbody: |
          {
            "timezone": "04"
          }
    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:

  • build - Build number of the fortiswitch image returned: always type: str sample: '1547'
  • http_method - Last method used to provision the content into FortiSwitch returned: always type: str sample: 'PUT'
  • http_status - Last result given by FortiSwitch on last operation applied returned: always type: str sample: 200
  • mkey - Master key (id) used in the last call to FortiSwitch returned: success type: str sample: id
  • name - Name of the table used to fulfill the request returned: always type: str sample: urlfilter
  • path - Path of the table used to fulfill the request returned: always type: str sample: webfilter
  • revision - Internal revision number returned: always type: str sample: 17.0.2.10658
  • serial - Serial number of the unit returned: always type: str sample: FSVMEVYYQT3AB5352
  • status - Indication of the operation's result returned: always type: str sample: success
  • version - Version of the FortiSwitch returned: always type: str sample: v7.0.0

Authors

  • Link Zheng (@chillancezen)

  • Jie Xue (@JieX19)

  • Frank Shen (@fshen01)

  • Hongbin Lu (@fgtdev-hblu)

Warning

It’s preferred to use FortiSwitch Ansible Collection Included Modules unless some features are not available there.