fortinet.fortimanager.fmgr_generic module – Build and send generic FortiManager API request.

Note

This module is part of the fortinet.fortimanager collection (version 2.8.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install fortinet.fortimanager.

To use it in a playbook, specify: fortinet.fortimanager.fmgr_generic.

New in fortinet.fortimanager 2.0.0

Synopsis

  • This module is for generic fortimanager requests. it receives raw json-rpc data, and sends it to fortimanager, finally returns the response to users.

  • This module also rely on fortimanager httpapi plugin as the transport.

  • the payload doesn’t include session, the httpapi plugin will automatically fill the session later.

  • the username and password is not managed by the module, but by the plugin.

Parameters

Parameter

Comments

access_token

string

The token to access FortiManager without using username and password.

enable_log

boolean

Enable/Disable logging for task

Choices:

  • false ← (default)

  • true

forticloud_access_token

string

authenticate Ansible client with forticloud API access token

json

string

the raw json-formatted payload to send to fortimanager

method

string

the method of the json-rpc

it must be in [get, add, set, update, delete, move, clone, exec]

params

list / elements=dictionary

the parameter collection.

rc_failed

list / elements=integer

the rc codes list with which the conditions to fail will be overriden

rc_succeeded

list / elements=integer

the rc codes list with which the conditions to succeed will be overriden

workspace_locking_adom

string

no description

workspace_locking_timeout

integer

no description

Default: 300

Notes

Note

  • two parameters schemes are supported, either in raw json format or in ansible recognnizable top-level parameters format.

  • json is defined as string, user is response for make it json-formatted

  • method and params should be specified by users if ‘json’ is not present

  • if all three parameters are provided, the ‘json’ is preferred.

Examples

- name: Generic module
  hosts: fortimanagers
  connection: httpapi
  vars:
    adom: "root"
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_httpapi_port: 443
  tasks:
    - name: Login a user
      fortinet.fortimanager.fmgr_generic:
        method: "exec"
        params:
          - url: "sys/login/user"
            data:
              - user: "APIUser"
                passwd: "Fortinet1!e"
    - name: Login another user
      fortinet.fortimanager.fmgr_generic:
        json: |
          {
           "method":"exec",
           "params":[
            {
                 "url":"sys/login/user",
                 "data":[
                    {
                       "user":"APIUser",
                       "passwd":"Fortinet1!"
                    }
                  ]
             }
            ]
          }

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

api_result

string

full API response, includes status code and message

Returned: always

Authors

  • Xinwei Du (@dux-fortinet)

  • Xing Li (@lix-fortinet)

  • Link Zheng (@zhengl)

  • Jie Xue (@JieX19)

  • Frank Shen (@fshen01)

  • Hongbin Lu (@fgtdev-hblu)