fortinet-ansible-dev / ansible-galaxy-fortiswitch-collection

GNU General Public License v3.0
2 stars 0 forks source link

fortinet.fortiswitch.fortiswitch_switch_interface not working #5

Open borgermeister opened 1 year ago

borgermeister commented 1 year ago

I am unable to configure interfaces with the module 'fortinet.fortiswitch.fortiswitch_switch_interface'

Ansible version:

ansible [core 2.13.5]
  config file = /home/ansible/git/github/ansible-home/ansible.cfg
  configured module search path = ['/home/ansible/venv-ansible/lib/python3.9/site-packages/napalm_ansible/modules']
  ansible python module location = /home/ansible/venv-ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ansible/venv-ansible/.ansible
  executable location = /home/ansible/venv-ansible/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

Collection version:

ansible-galaxy collection list | grep fortiswitch
fortinet.fortiswitch     1.1.2

Task in playbook:

    - name: Configure interface
      fortinet.fortiswitch.fortiswitch_switch_interface:
        state: present
        switch_interface:
          name: '{{ item.name }}'
          description: '{{ item.description }}'
      loop: '{{ devices[0]["interfaces"] }}'

Error message from playbook:

failed: [sw01.borgermeister.lan] (item={'name': 'port1', 'description': 'SHUTDOWN', 'enabled': True, 'mode': None, 'ip_addresses': [], 'tagged_vlans': [], 'untagged_vlan': None}) => changed=false 
  ansible_loop_var: item
  item:
    description: SHUTDOWN
    enabled: true
    ip_addresses: []
    mode: null
    name: port1
    tagged_vlans: []
    untagged_vlan: null
  meta:
    build: 419
    cmdb-checksum: '8630734143195324327'
    cmdb-index: '516'
    http_method: PUT
    http_status: 400
    mkey: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
    name: interface
    path: switch
    serial: S108EF5918005861
    status: error
    timestamp: '2022-10-24T11:57:18Z'
    vdom: root
    version: v7.2.2
  msg: Error in repo

Diagnose debug CLI on FortiSwitch:

Error in cmf_shm_api.c,cmf_shm_update,765, pid=821,vd=root,query=switch.interface,level=1,pos=0.
0: config switch interface
1: edit "interface"
Error in cmf_shm_api.c,cmf_shm_update,765, pid=821,vd=root,query=switch.interface,level=1,pos=0.
0: config switch interface
-61: rename "port1" to "interface"
(skipped) edit "interface"

(skipped) set description "SHUTDOWN"
MaxxLiu22 commented 1 year ago

Hi @borgermeister ,

Thank you for raising this issue and sorry for any inconvenience. This issue is the same as #4, I can reproduce this issue on my side and have reported it to the development team, will let you know if there are any updates.

Thanks, Maxx

JieX19 commented 1 year ago

Hi @borgermeister,

I tested this module and it works now. Could you help confirm if it works well on your side?

Thanks, Jie

borgermeister commented 1 year ago

Hi

Finally had the time to test this out and it is still not working. However the error message has changed now. I´m using Nautobot as source of truth.

Ansible version output:

ansible [core 2.15.0]
  config file = /home/ansible/git/github/ansible-home/ansible.cfg
  configured module search path = ['/home/ansible/venv-ansible/lib/python3.9/site-packages/napalm_ansible/modules']
  ansible python module location = /home/ansible/venv-ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/home/ansible/venv-ansible/.ansible
  executable location = /home/ansible/venv-ansible/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/home/ansible/venv-ansible/bin/python)
  jinja version = 3.1.2
  libyaml = True

fortinet.fortiswitch 1.2.1

Ansible playbook:

    - name: Configure interface
      fortinet.fortiswitch.fortiswitch_switch_interface:
        state: present
        switch_interface:
          name: '{{ item.name }}'
          description: '{{ item.description }}'
          native_vlan: '{{ item.untagged_vlan | community.general.json_query("vid") | int }}'
          allowed_vlans: '{{ item.tagged_vlans | community.general.json_query("[].vid") | int }}'
      when: item.type is not search('VIRTUAL')
      loop: '{{ devices[0]["interfaces"] }}'

Ansible error message:

failed: [sw01] (item={'name': 'port1', 'description': 'Cisco CX switch', 'type': 'A_1000BASE_T', 'enabled': True, 'mode': 'TAGGED', 'member_interfaces': [], 'lag': None, 'ip_addresses': [], 'tagged_vlans': [{'vid': 10}], 'untagged_vlan': {'vid': 1}}) => changed=false 
  ansible_loop_var: item
  item:
    description: Cisco CX switch
    enabled: true
    ip_addresses: []
    lag: null
    member_interfaces: []
    mode: TAGGED
    name: port1
    tagged_vlans:
    - vid: 10
    type: A_1000BASE_T
    untagged_vlan:
      vid: 1
  meta:
    build: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
    cmdb-checksum: 2859********38********97367********73659
    cmdb-index: 5********9
    error_reason: object already exists (mkey='********')
    http_method: POST
    http_status: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
    name: interface
    path: switch
    serial: S****************8EF59********8****************586********
    status: error
    timestamp: 2********23-********7-29T****************:28:45Z
    vdom: root
    version: v7.2.2
  msg: Error in repo

FortiSwitch debug CLI output:

{
  "http_method":"GET",
  "results":{
    "version":"FortiSwitch-108E-FPOE v7.2.2,build0419,220902 (GA)",
    "serial_number":"S108EF5918005861",
    "BIOS_version":"04000006",
    "system_part_number":"P21379-01",
    "burn_in_mac":"e8:1c:ba:12:eb:a8",
    "hostname":"sw01",
    "distribution":"International",
    "branch_point":"419",
    "system_time":"Sat Jul 29 12:28:45 2023\n"
  },
  "vdom":"root",
  "path":"system",
  "name":"status",
  "status":"success",
  "cmdb-index":"509",
  "cmdb-checksum":"2859138197367073659",
  "serial":"S108EF5918005861",
  "version":"v7.2.2",
  "build":419,
  "timestamp":"2023-07-29T10:28:45Z"
}
api_global.c  [   65] : ----------------------------------------------------------------------------------
api_global.c  [   66] : Received '/api/v2/cmdb/switch/interface/port1' request from '10.100.1.129'
api_global.c  [   67] : ----------------------------------------------------------------------------------
aps_util.c    [ 1172] : cky-cid (24) loginname (admin) username (admin) prof-name (super_admin) in cookies
api_version.c [  718] : Found out an entry ('switch.interface' -> 'switch.interface') for version (v2)
api_cmdb.c    [ 2360] : finding a CMDB node (path='switch',name='interface')
api_cmdb.c    [ 2398] : querying CMDB node with mkey 'port1'
api_cmdb.c    [ 2053] : found legacy 'json' parameter - feature is deprecated
api_version.c [   30] : Changing Same Type Item : name ('igmps-flood-reports' -> 'igmp-snooping-flood-reports')
api_version.c [   30] : Changing Same Type Item : name ('igmps-flood-traffic' -> 'mcast-snooping-flood-traffic')
api_cmdb.c    [ 2128] : editing CMDB object : append (0) auto_key (0) mkey (port1) flags (0) ...
api_json.c    [ 1939] : node_parse_object failed for node 'allowed-vlans': '0' (err=1)
api_cmdb.c    [ 1978] : return error code : cmdb (1) to http code (500)
api_common.c  [  858] : API return HTTP code (500:error)
================== Response ==================
{
  "http_method":"PUT",
  "status":"error",
  "http_status":500,
  "vdom":"root",
  "path":"switch",
  "name":"interface",
  "mkey":"port1",
  "cmdb-index":"509",
  "cmdb-checksum":"2859138197367073659",
  "serial":"S108EF5918005861",
  "version":"v7.2.2",
  "build":419,
  "timestamp":"2023-07-29T10:28:45Z",
  "error_reason":"node_parse_object failed for node 'allowed-vlans': '0' (err=1)"