Need assistance w/Fortinet playbook to list all AP's managed by device

Hello all, I’m trying to write a playbook to query all Fortinet’s and give me a list of all Access points managed by that device.

I’ve been going off: fortinet.fortios.fortios_monitor_fact module – Retrieve Facts of FortiOS Monitor Objects. — Ansible Documentation

But I’m not having to much look. I’ve tried several iterations of the following playbook. The result it does give is listing (1) AP, but I know for a fact that the current host I’m testing off has several APs. My preferred output would show AP model as well as firmware version. Below is my test playbook and below that will be some debug output

https://docs.ansible.com/ansible/latest/collections/fortinet/fortios/fortios_monitor_fact_module.html

  • my code!

  • hosts: all
    connection: httpapi
    gather_facts: no
    vars:
    vdom: “root”
    ansible_httpapi_use_ssl: yes
    ansible_httpapi_validate_certs: no
    ansible_httpapi_port: 443
    ansible_network_os: fortinet.fortios.fortios
    tasks:
    • name: Gather FortiAPs firmware list
      fortinet.fortios.fortios_monitor_fact:
      vdom: “root”
      selector: wifi_managed_ap
    • debug:
      var: fortinet.fortios.fortios_monitor_fact

Debug output:
ok: [10.1.1.27] => {
“changed”: false,
“invocation”: {
“module_args”: {
“access_token”: null,
“enable_log”: false,
“filters”: null,
“formatters”: null,
“params”: null,
“selector”: “wifi_managed_ap”,
“selectors”: null,
“sorters”: null,
“vdom”: “root”
}
},
“meta”: {
“action”: “”,
“build”: 1575,
“http_method”: “GET”,
“name”: “managed_ap”,
“path”: “wifi”,
“results”: [
{
“ap_profile”: “FAP222C New”,
“ble_profile”: “”,
“board_mac”: “90:6c:ac:39:04:4c”,

Any help would be greatly appreciated

I got it working with assistance from @MaxxLiu22 from Fortinet:

---
- hosts: all
  connection: httpapi
  gather_facts: no
  vars:
     vdom: "root"
     ansible_httpapi_use_ssl: yes
     ansible_httpapi_validate_certs: no
     ansible_httpapi_port: 444
     ansible_network_os: fortinet.fortios.fortios
  tasks:
  - name: Gather FortiAPs firmware list
    fortinet.fortios.fortios_monitor_fact:
      enable_log: true
      selector: 'wifi_managed_ap'
      vdom: "{{ vdom }}"
    register: result
  
  - debug:
      msg: "{{ result.meta.results | json_query('[].{wtp_id: wtp_id, status: status}') }}"

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.