community.general.fmgr_query (0.1.1) — module

Query FortiManager data objects for use in Ansible workflows.

Authors: Luke Weighall (@lweighall)

preview | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Provides information on data objects within FortiManager so that playbooks can perform conditionals.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: QUERY FORTIGATE DEVICE BY IP
  fmgr_query:
    object: "device"
    adom: "ansible"
    device_ip: "10.7.220.41"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: QUERY FORTIGATE DEVICE BY SERIAL
  fmgr_query:
    adom: "ansible"
    object: "device"
    device_serial: "FGVM000000117992"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: QUERY FORTIGATE DEVICE BY FRIENDLY NAME
  fmgr_query:
    adom: "ansible"
    object: "device"
    device_unique_name: "ansible-fgt01"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: VERIFY CLUSTER MEMBERS AND STATUS
  fmgr_query:
    adom: "ansible"
    object: "cluster_nodes"
    device_unique_name: "fgt-cluster01"
    nodes: ["ansible-fgt01", "ansible-fgt02", "ansible-fgt03"]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: GET STATUS OF TASK ID
  fmgr_query:
    adom: "ansible"
    object: "task"
    task_id: "3"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: USE CUSTOM TYPE TO QUERY AVAILABLE SCRIPTS
  fmgr_query:
    adom: "ansible"
    object: "custom"
    custom_endpoint: "/dvmdb/adom/ansible/script"
    custom_dict: { "type": "cli" }

Inputs

    
adom:
    default: root
    description:
    - The ADOM the configuration should belong to.
    required: false

nodes:
    description:
    - A LIST of firewalls in the cluster you want to verify i.e. ["firewall_A","firewall_B"].
    required: false

object:
    choices:
    - device
    - cluster_nodes
    - task
    - custom
    description:
    - The data object we wish to query (device, package, rule, etc). Will expand choices
      as improves.
    required: true

task_id:
    description:
    - The ID of the task you wish to query status on. If left blank and object = 'task'
      a list of tasks are returned.
    required: false

device_ip:
    description:
    - The IP of the device you want to query.
    required: false

custom_dict:
    description:
    - ADVANCED USERS ONLY! REQUIRES KNOWLEDGE OF FMGR JSON API!
    - DICTIONARY JSON FORMAT ONLY -- Custom dictionary/datagram to send to the endpoint.
    required: false

device_serial:
    description:
    - The serial number of the device you want to query.
    required: false

custom_endpoint:
    description:
    - ADVANCED USERS ONLY! REQUIRES KNOWLEDGE OF FMGR JSON API!
    - The HTTP Endpoint on FortiManager you wish to GET from.
    required: false

device_unique_name:
    description:
    - The desired "friendly" name of the device you want to query.
    required: false

Outputs

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