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

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

Duplicate entry #203

Closed romaah closed 1 year ago

romaah commented 1 year ago

When using the fortios_router_static to configure static routes on a vdom, it seemingly errors on adding static routes when they are already defined, and will not report as unchanged/green even if the setting match exactly as configured.

failed: [***] (item={'comment': 'test route 1', 'dst': '10.10.10.30/32', 'gateway': '2.2.2.2'}) => {"ansible_loop_var": "item", "changed": false, "item": {"comment": "test route 1", "dst": "10.10.10.30/32", "gateway": "2.2.2.2"}, "meta": {"build": 1914, "cli_error": "current vf=***-DEV:6\nDuplicated entry.\nobject set operator error, -15 discard the setting\nCommand fail. Return code -15\nCommand fail. Return code 1\n", "error": -15, "http_method": "POST", "http_status": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "name": "static", "path": "router", "revision": "e32f4********9b8694********6448c4b6df********977b63b", "revision_changed": false, "serial": "FG2********1E4Q179********3868", "status": "error", "vdom": "***-DEV", "version": "v6.4.8"}, "msg": "Error in repo"}

Is this as intended.. as currently this doesn't support idempotency.

MaxxLiu22 commented 1 year ago

Hi @romaah ,

Thanks for raising this issue, The error msg means that ansible try to add a new static router but there is a duplicated one existing. So if you would like to edit the existing one, I suggest to add an argument "seq_num", since ansible use this argument to locate the specific static router.

- hosts: fortigates
  collections:
    - fortinet.fortios
  connection: httpapi
  vars:
   vdom: "root"
   ansible_httpapi_use_ssl: yes
   ansible_httpapi_validate_certs: no
   ansible_httpapi_port: 443
  tasks:
  - name: Configure IPv4 static routing tables.
    fortios_router_static:
      vdom:  "root"
      state: "present"
      access_token: "token"
      router_static:
        dst: '10.10.10.30/32'
        comment: "test route 1"
        device: "port1"
        gateway: "2.2.2.2"
        seq_num: "2"
        status: "enable"

Thanks, Maxx

JieX19 commented 1 year ago

The issue will be closed as it's been resolved.