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

GNU General Public License v3.0
85 stars 49 forks source link

fortios_router_ospf fails: msg: 'argument ''network'' is of type <class ''dict''> found in ''router_ospf'' #150

Closed petercrocker closed 2 years ago

petercrocker commented 2 years ago

Issue: can't get fortios_router_ospf to configure a network statement.

Version of Galaxy collection: 2.1.3

Example ansible task:

Error:

msg: 'argument ''network'' is of type <class ''dict''> found in ''router_ospf''. and we were unable to convert to list: <class ''dict''> cannot be converted to a list'

Detailed output:

TASK [Configure OSPF network statement] ** task path: /home/pete/.local/lib/python3.8/site-packages/netsim/ansible/tasks/fortinet.fortios.fortios/ospf.yml:74 redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi <192.168.121.101> ESTABLISH LOCAL CONNECTION FOR USER: pete <192.168.121.101> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/pete/.ansible/tmp/ansible-local-97096swp2od3l"&& mkdir "echo /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970" && echo ansible-tmp-1638980339.7207737-97410-163676680173970="echo /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970" ) && sleep 0' Using module file /home/pete/.ansible/collections/ansible_collections/fortinet/fortios/plugins/modules/fortios_router_ospf.py <192.168.121.101> PUT /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/tmpgot6cawe TO /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970/AnsiballZ_fortios_router_ospf.py <192.168.121.101> EXEC /bin/sh -c 'chmod u+x /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970/ /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970/AnsiballZ_fortios_router_ospf.py && sleep 0' <192.168.121.101> EXEC /bin/sh -c '/usr/bin/python3 /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970/AnsiballZ_fortios_router_ospf.py && sleep 0' <192.168.121.101> EXEC /bin/sh -c 'rm -f -r /home/pete/.ansible/tmp/ansible-local-97096swp2od3l/ansible-tmp-1638980339.7207737-97410-163676680173970/ > /dev/null 2>&1 && sleep 0' fatal: [fw]: FAILED! => changed=false invocation: module_args: access_token: null enable_log: null member_path: null member_state: null router_ospf: abr_type: null area: null auto_cost_ref_bandwidth: null bfd: null database_overflow: null database_overflow_max_lsas: null database_overflow_time_to_recover: null default_information_metric: null default_information_metric_type: null default_information_originate: null default_information_route_map: null default_metric: null distance: null distance_external: null distance_inter_area: null distance_intra_area: null distribute_list: null distribute_list_in: null distribute_route_map_in: null log_neighbour_changes: null neighbor: null network: id: 1 prefix: 0.0.0.0/0 ospf_interface: null passive_interface: null redistribute: null restart_mode: null restart_period: null rfc1583_compatible: null router_id: null spf_timers: null summary_address: null vdom: root msg: 'argument ''network'' is of type <class ''dict''> found in ''router_ospf''. and we were unable to convert to list: <class ''dict''> cannot be converted to a list'

petercrocker commented 2 years ago

@JieX19 can you help route this to the correct person to look in to it please?

JieX19 commented 2 years ago

Hi @petercrocker,

The error is caused by the type of the paramter NETWORK. you used the type of dict in the playbook instead of a list. The correct playbook should be like this:

name: Configure OSPF network statement
fortinet.fortios.fortios_router_ospf:
     vdom: "{{ vdom }}"
     router_ospf:
           network:
                - area: "{{ ospf.area | ansible.netcommon.ipaddr('address') | default('0.0.0.0') }}"
                   id: 1
                   prefix: "{{ ospf.network | default('0.0.0.0/0') }}"

Let me know if you have other questions.