fortinet-ansible-dev / ansible-galaxy-fortios-collection

GNU General Public License v3.0
84 stars 48 forks source link

VLAN Creation error #246

Closed alebeta90 closed 1 year ago

alebeta90 commented 1 year ago

Hi all,

I'm trying to create a vlan using the fortios collection

FortiOS Version: 6.2.12 FortiOS Collection: 2.2.3

This is my playbook

- name: Configure VLANs
  fortios_system_interface:
    state: "present"
    vdom: "{{ vdom }}"
    system_interface:
      name: "SVC"
      interface: "SVC-Switch"
      ip: "10.108.112.1/24"
      allowaccess: "ping"
      vlanid: 11
      role: "lan"

This are the errors I can get from debugging

[httpsd 2794 - 1682352762 info] fweb_debug_init[302] -- New PUT request for "/api/v2/cmdb/system/interface/SVC" from "10.200.3.1:13023"

[httpsd 2794 - 1682352762 info] fweb_debug_init[303] -- User-Agent: "Python-urllib/3.10"

[httpsd 2794 - 1682352762 info] fweb_debug_init[305] -- Handler "api_cmdb_v2-handler" assigned to request

[httpsd 2794 - 1682352762 info] aps_init_process_vdom[1290] -- initialized process vdom to 'root' (cookie='(null)')

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'vdom' (type=string)

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'allowaccess' (type=string)

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'interface' (type=string)

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'ip' (type=string)

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'name' (type=string)

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'role' (type=string)

[httpsd 2794 - 1682352762 info] api_store_parameter[239] -- add API parameter 'vlanid' (type=int)

[httpsd 2794 - 1682352762 info] handle_cli_req_v2_vdom[2148] -- new CMDB API request (vdom='root',user='admin')

[httpsd 2794 - 1682352762 info] api_cmdb_request_init_by_path[1517] -- new CMDB query (path='system',name='interface')

[httpsd 2794 - 1682352762 info] api_cmdb_request_init_by_path[1546] -- querying CMDB entry (mkey='SVC')

[httpsd 2794 - 1682352762 info] api_cmdb_request_init_by_path[1550] -- unable to find 'SVC' in table 'system.interface'

[httpsd 2794 - 1682352762 error] _api_cmdb_v2_config[1141] -- Object with mkey SVC not found and allow_append flag not set

[httpsd 2794 - 1682352762 warning] api_return_http_result[696] -- API error 404 raised

[httpsd 2794 - 1682352762 info] fweb_debug_final[203] -- Completed PUT request for "/api/v2/cmdb/system/interface/SVC" (HTTP 404)

[httpsd 2774 - 1682352762 info] fweb_debug_init[302] -- New POST request for "/api/v2/cmdb/system/interface" from "10.200.3.1:16095"

[httpsd 2774 - 1682352762 info] fweb_debug_init[303] -- User-Agent: "Python-urllib/3.10"

[httpsd 2774 - 1682352762 info] fweb_debug_init[305] -- Handler "api_cmdb_v2-handler" assigned to request

[httpsd 2774 - 1682352762 info] aps_init_process_vdom[1290] -- initialized process vdom to 'root' (cookie='(null)')

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'vdom' (type=string)

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'allowaccess' (type=string)

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'interface' (type=string)

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'ip' (type=string)

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'name' (type=string)

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'role' (type=string)

[httpsd 2774 - 1682352762 info] api_store_parameter[239] -- add API parameter 'vlanid' (type=int)

[httpsd 2774 - 1682352762 info] handle_cli_req_v2_vdom[2148] -- new CMDB API request (vdom='root',user='admin')

[httpsd 2774 - 1682352762 info] api_cmdb_request_init_by_path[1517] -- new CMDB query (path='system',name='interface')

[httpsd 2774 - 1682352762 info] _api_cmdb_v2_config[1178] -- editing CLI object (append=1, auto_key=0, path=system, name=interface, mkey=(null), flags=0)

[httpsd 2774 - 1682352762 info] api_set_cmdb_attr[1787] -- 'name'

[httpsd 2774 - 1682352762 info] api_set_cmdb_attr[1787] -- 'ip'

[httpsd 2774 - 1682352762 info] api_set_cmdb_attr[1787] -- 'allowaccess'

[httpsd 2774 - 1682352762 info] api_set_cmdb_attr[1787] -- 'interface'

[httpsd 2774 - 1682352762 info] api_set_cmdb_attr[1787] -- 'vlanid'

[httpsd 2774 - 1682352762 info] api_set_cmdb_attr[1787] -- 'role'

[httpsd 2774 - 1682352762 info] cmdb_save_with_children[277] -- appended main node (nret=-56, is_new=1)

[httpsd 2774 - 1682352762 error] cmdb_save_with_children[283] -- saving failed for main node: 'interface' (err=-56)

[httpsd 2774 - 1682352762 error] cmdb_commit_from_json[1588] -- error saving request object to CLI (-56)

[httpsd 2774 - 1682352762 error] _api_cmdb_v2_config[1213] -- error editing object (nret=-56)

[httpsd 2774 - 1682352762 warning] api_return_http_result[696] -- API error -56 raised

[httpsd 2774 - 1682352762 info] fweb_debug_final[203] -- Completed POST request for "/api/v2/cmdb/system/interface" (HTTP 500)

[httpsd 2816 - 1682352762 info] fweb_debug_init[302] -- New POST request for "/logout" from "10.200.3.1:16607"

[httpsd 2816 - 1682352762 info] fweb_debug_init[303] -- User-Agent: "Python-urllib/3.10"

[httpsd 2816 - 1682352762 info] fweb_debug_init[305] -- Handler "logout-handler" assigned to request

[httpsd 2816 - 1682352762 info] fweb_debug_final[203] -- Completed POST request for "/logout" (HTTP 200)

Somehow I can not understand from the debug information what the error is, maybe I'm missing something? I did try entering the commands directly in the Forti CLI and it does work as expected, so I'm a little bit clueless here :) any help is appreciated

Best regards

alebeta90 commented 1 year ago

ok, just now few minutes later after opening the issue I found the solution

- name: Configure VLANs
  fortios_system_interface:
    state: "present"
    vdom: "{{ vdom }}"
    system_interface:
      name: "SVC"
      interface: "SVC-Switch"
      ip: "10.108.112.1/24"
      allowaccess: "ping"
      vlanid: 11
      role: "lan"
      vdom: "{{ vdom }}"

I needed to specify the vdom within system_interface the vdom defined in fortios_system_interface was not enough.