fortinet.fortimanager.fmgr_generic (2.4.0) — module

Build and send generic FortiManager API request.

| "added in version" 2.0.0 of fortinet.fortimanager"

Authors: Xinwei Du (@dux-fortinet), Xing Li (@lix-fortinet), Link Zheng (@zhengl), Jie Xue (@JieX19), Frank Shen (@fshen01), Hongbin Lu (@fgtdev-hblu)

preview | supported by community

Install collection

Install with ansible-galaxy collection install fortinet.fortimanager:==2.4.0


Add to requirements.yml

  collections:
    - name: fortinet.fortimanager
      version: 2.4.0

Description

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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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!"
                    }
                  ]
             }
            ]
          }

Inputs

    
json:
    description:
    - the raw json-formatted payload to send to fortimanager
    required: false
    type: str

method:
    description:
    - the method of the json-rpc
    - it must be in [get, add, set, update, delete, move, clone, exec]
    required: false
    type: str

params:
    description:
    - the parameter collection.
    elements: dict
    required: false
    type: list

rc_failed:
    description: the rc codes list with which the conditions to fail will be overriden
    elements: int
    required: false
    type: list

enable_log:
    default: false
    description: Enable/Disable logging for task
    required: false
    type: bool

access_token:
    description: The token to access FortiManager without using username and password.
    required: false
    type: str

rc_succeeded:
    description: the rc codes list with which the conditions to succeed will be overriden
    elements: int
    required: false
    type: list

workspace_locking_adom:
    description: no description
    required: false
    type: str

forticloud_access_token:
    description: authenticate Ansible client with forticloud API access token
    required: false
    type: str

workspace_locking_timeout:
    default: 300
    description: no description
    required: false
    type: int

Outputs

api_result:
  description: full API response, includes status code and message
  returned: always
  type: str