Delete calls fail with vdom error
Closed this issue · 6 comments
When trying to delete an existing object I get an error saying:
File "/Users/damani/.pyenv/versions/3.6.5/lib/python3.6/site-packages/fortiosapi/fortiosapi.py", line 329, in schema\n url = self.cmdb_url(path, name) + "?action=schema"\nTypeError: cmdb_url() missing 1 required positional argument: 'vdom'\n"
I'm running FortiOS v6.0.3
Code:
- hosts: localhost
# strategy: debug
vars:
host: "{{ lookup ('env', 'FORTIGATE_IP') }}"
username: "{{ lookup ('env', 'FORTIGATE_USER') }}"
password: "{{ lookup ('env', 'FORTIGATE_PASS') }}"
vdom: "root"
gaia_vpn_name: "{{ lookup ('env', 'GAIA_VPN_NAME') }}"
gaia_wan_interface: "{{ lookup ('env', 'GAIA_WAN_INTERFACE') }}"
gaia_local_gw: "{{ lookup ('env', 'GAIA_LOCAL_GW') }}"
gaia_remote_gw: "{{ lookup ('env', 'GAIA_REMOTE_GW') }}"
gaia_vpn_shared_secret: "{{ lookup ('env', 'GAIA_VPN_SHARED_SECRET') }}"
gaia_src_subnet: "{{ lookup ('env', 'GAIA_SRC_SUBNET') }}"
gaia_dst_subnet: "{{ lookup ('env', 'GAIA_DST_SUBNET') }}"
gaia_vpn_route_num_0: "{{ lookup ('env', 'GAIA_VPN_ROUTE_NUM_0') }}"
gaia_vpn_inbound_fw_id_0: "{{ lookup ('env', 'GAIA_INBOUND_FW_ID_0') }}"
gaia_vpn_outbound_fw_id_0: "{{ lookup ('env', 'GAIA_OUTBOUND_FW_ID_0') }}"
gaia_lan_interface: "{{ lookup ('env', 'GAIA_LAN_INTERFACE') }}"
tasks:
- name: Show Var(s)
debug:
msg:
- "host is: {{ host }}"
- "vdom is: {{ vdom }}"
- name: Remove Gaia outbound firewall policy
fortiosconfig:
config: "firewall policy"
action: "delete"
host: "{{ host }}"
username: "{{ username }}"
password: "{{ password }}"
vdom: "{{ vdom }}"
config_parameters:
policyid: "{{ gaia_vpn_outbound_fw_id_0 }}"
name: "{{ gaia_vpn_name }}_0_out"
action: "accept"
srcintf: [ {"name": "{{ gaia_lan_interface }}"} ]
dstintf: [ {"name": "{{ gaia_vpn_name }}"} ]
srcaddr: [ {"name": "all"} ]
dstaddr: [ {"name": "all"} ]
schedule: "always"
service: [ {"name":"ALL"} ]
tcp-mss-sender: "1350"
tcp-mss-receiver: "1350"
Error:
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/Users/user1/.pyenv/versions/3.6.5/lib/python3.6/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is stronglyadvised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n InsecureRequestWarning)\n/Users/user1/.pyenv/versions/3.6.5/lib/python3.6/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n InsecureRequestWarning)\nTraceback (most recent call last):\n File \"/Users/user1/.ansible/tmp/ansible-tmp-1546309813.406816-137183293061395/AnsiballZ_fortiosconfig.py\", line 113, in <module>\n _ansiballz_main()\n File \"/Users/user1/.ansible/tmp/ansible-tmp-1546309813.406816-137183293061395/AnsiballZ_fortiosconfig.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/user1/.ansible/tmp/ansible-tmp-1546309813.406816-137183293061395/AnsiballZ_fortiosconfig.py\", line 48, in invoke_module\n imp.load_module('__main__', mod, module, MOD_DESC)\n File \"/Users/user1/.pyenv/versions/3.6.5/lib/python3.6/imp.py\", line 235, in load_module\n return load_source(name, filename, file)\n File \"/Users/user1/.pyenv/versions/3.6.5/lib/python3.6/imp.py\", line 170, in load_source\n module = _exec(spec, sys.modules[name])\n File \"<frozen importlib._bootstrap>\", line 618, in _exec\n File \"<frozen importlib._bootstrap_external>\", line 678, in exec_module\n File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n File \"/var/folders/6k/19krd1hx19x54m6s_6d3v51r0000gq/T/ansible_fortiosconfig_payload_sglg06m3/__main__.py\", line 845, in <module>\n File \"/var/folders/6k/19krd1hx19x54m6s_6d3v51r0000gq/T/ansible_fortiosconfig_payload_sglg06m3/__main__.py\", line 833, in main\n File \"/var/folders/6k/19krd1hx19x54m6s_6d3v51r0000gq/T/ansible_fortiosconfig_payload_sglg06m3/__main__.py\", line 587, in fortigate_config_del\n File \"/Users/user1/.pyenv/versions/3.6.5/lib/python3.6/site-packages/fortiosapi/fortiosapi.py\", line 329, in schema\n url = self.cmdb_url(path, name) + \"?action=schema\"\nTypeError: cmdb_url() missing 1 required positional argument: 'vdom'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
to retry, use: --limit @/Users/user1/Google Drive/Scripts/Gaia/gaia-util-Azure-Sandbox/gaia-util/tf-azure/40ansible/fortigate_remove_gaia_vpn_azure.retry
Put actions also fail in a similar manner. Set actions do seem to work.
Hi @DamaniN,
thanks for your post. Indeed there is a fault in our internal library that causes this problem. I'll provide a fix shortly for this. I'll let you know once it is done.
The change has been included in fortiosapi library and a new PyPI package has been generated. You can upgrade your current fortiosapi library and re-test:
pip install --upgrade fortiosapi
You should get fortiosapi >= 0.10.3 (check by running pip freeze)
I'm closing this for now. Feel free to open it again if there are issues.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.122.118', port=80): Max retries exceeded with url: /logincheck (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fb9810e5710>, 'Connection to 192.168.122.118 timed out. (connect timeout=12)'))
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1577010383.89-200239878080684/AnsiballZ_fortiosconfig.py", line 113, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1577010383.89-200239878080684/AnsiballZ_fortiosconfig.py", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1577010383.89-200239878080684/AnsiballZ_fortiosconfig.py", line 48, in invoke_module\n imp.load_module('main', mod, module, MOD_DESC)\n File "/tmp/ansible_fortiosconfig_payload_Sth9XH/main.py", line 948, in \n File "/tmp/ansible_fortiosconfig_payload_Sth9XH/main.py", line 936, in main\n File "/tmp/ansible_fortiosconfig_payload_Sth9XH/main.py", line 646, in fortigate_del\n File "/tmp/ansible_fortiosconfig_payload_Sth9XH/main.py", line 493, in login\n File "/usr/local/lib/python2.7/dist-packages/fortiosapi/fortiosapi.py", line 170, in login\n data='username=' + urllib.parse.quote(username) + '&secretkey=' + urllib.parse.quote(password) + "&ajax=1", timeout=self.timeout)\n File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 581, in post\n return self.request('POST', url, data=data, json=json, **kwargs)\n File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 533, in request\n resp = self.send(prep, **send_kwargs)\n File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 646, in send\n r = adapter.send(request, **kwargs)\n File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 504, in send\n raise ConnectTimeout(e, request=request)\nrequests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.122.118', port=80): Max retries exceeded with url: /logincheck (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fb9810e5710>, 'Connection to 192.168.122.118 timed out. (connect timeout=12)'))\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
what is the issue