meraki_mx_vlan - Diff causes crash
kbreit opened this issue · 3 comments
As reported in @288...
i receive the same error but on meraki_mx_vlan.
The diff check should recognise no change needs to be done and then errors with:
# task
- name: set vlan 101 Clients
cisco.meraki.meraki_mx_vlan:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
net_name: "{{ item.site_name }}"
state: present
vlan_id: 101
name: Clients
subnet: "10.{{ item.site_octet }}.101.0/27"
appliance_ip: 10.{{ item.site_octet }}.101.1
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
The full traceback is:
Traceback (most recent call last):
File "/Users/oliver/.ansible/tmp/ansible-tmp-1651492136.3267891-62421-102830058445798/AnsiballZ_meraki_mx_vlan.py", line 107, in <module>
_ansiballz_main()
File "/Users/oliver/.ansible/tmp/ansible-tmp-1651492136.3267891-62421-102830058445798/AnsiballZ_meraki_mx_vlan.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/oliver/.ansible/tmp/ansible-tmp-1651492136.3267891-62421-102830058445798/AnsiballZ_meraki_mx_vlan.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.cisco.meraki.plugins.modules.meraki_mx_vlan', init_globals=dict(_module_fqn='ansible_collections.cisco.meraki.plugins.modules.meraki_mx_vlan', _modlib_path=modlib_path),
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/var/folders/6g/cclk58y94dz5xwsmy4l28xq00000gn/T/ansible_cisco.meraki.meraki_mx_vlan_payload_0eelm70n/ansible_cisco.meraki.meraki_mx_vlan_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_mx_vlan.py", line 585, in <module>
File "/var/folders/6g/cclk58y94dz5xwsmy4l28xq00000gn/T/ansible_cisco.meraki.meraki_mx_vlan_payload_0eelm70n/ansible_cisco.meraki.meraki_mx_vlan_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_mx_vlan.py", line 562, in main
File "/var/folders/6g/cclk58y94dz5xwsmy4l28xq00000gn/T/ansible_cisco.meraki.meraki_mx_vlan_payload_0eelm70n/ansible_cisco.meraki.meraki_mx_vlan_payload.zip/ansible_collections/cisco/meraki/plugins/module_utils/network/meraki/meraki.py", line 205, in generate_diff
TypeError: 'NoneType' object is not subscriptable
failed: [localhost] (item=site 1) => {
"ansible_loop_var": "item",
"changed": false,
"item": {
"site_address": "Banana, Kiribati",
"site_name": "site 1",
"site_octet": 12
},
"module_stderr": "Traceback (most recent call last):\n File \"/Users/oliver/.ansible/tmp/ansible-tmp-1651492136.3267891-62421-102830058445798/AnsiballZ_meraki_mx_vlan.py\", line 107, in <module>\n _ansiballz_main()\n File \"/Users/oliver/.ansible/tmp/ansible-tmp-1651492136.3267891-62421-102830058445798/AnsiballZ_meraki_mx_vlan.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/oliver/.ansible/tmp/ansible-tmp-1651492136.3267891-62421-102830058445798/AnsiballZ_meraki_mx_vlan.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.cisco.meraki.plugins.modules.meraki_mx_vlan', init_globals=dict(_module_fqn='ansible_collections.cisco.meraki.plugins.modules.meraki_mx_vlan', _modlib_path=modlib_path),\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/var/folders/6g/cclk58y94dz5xwsmy4l28xq00000gn/T/ansible_cisco.meraki.meraki_mx_vlan_payload_0eelm70n/ansible_cisco.meraki.meraki_mx_vlan_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_mx_vlan.py\", line 585, in <module>\n File \"/var/folders/6g/cclk58y94dz5xwsmy4l28xq00000gn/T/ansible_cisco.meraki.meraki_mx_vlan_payload_0eelm70n/ansible_cisco.meraki.meraki_mx_vlan_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_mx_vlan.py\", line 562, in main\n File \"/var/folders/6g/cclk58y94dz5xwsmy4l28xq00000gn/T/ansible_cisco.meraki.meraki_mx_vlan_payload_0eelm70n/ansible_cisco.meraki.meraki_mx_vlan_payload.zip/ansible_collections/cisco/meraki/plugins/module_utils/network/meraki/meraki.py\", line 205, in generate_diff\nTypeError: 'NoneType' object is not subscriptable\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
Originally posted by @oliverl-21 in #288 (comment)
@oliverl-21 Do you have a full test case I can use to reproduce this? I added a test in my integration test that seems to match yours but isn't reproducing the crash.
- name: Change VLAN for diff test
meraki_vlan:
auth_key: '{{auth_key}}'
state: present
org_name: '{{test_org_name}}'
net_name: '{{test_net_name}}'
vlan_id: 2
name: TestVLAN
subnet: 192.168.250.0/24
appliance_ip: 192.168.250.2
delegate_to: localhost
- name: Test idempotency with diff
meraki_vlan:
auth_key: '{{auth_key}}'
state: present
org_name: '{{test_org_name}}'
net_name: '{{test_net_name}}'
vlan_id: 2
name: TestVLAN
subnet: 192.168.250.0/24
appliance_ip: 192.168.250.2
diff: yes
delegate_to: localhost
register: diff_test
You can see this at https://github.com/CiscoDevNet/ansible-meraki/pull/309/files#
That's my scenario. I excluded the device binding in this sample.
it creates the site, binds it to a template and sets the IPs for the VLANs
Currently i'm not able to reproduce the error.
# playbook.yml
---
- name: meraki test
hosts: localhost
gather_facts: no
vars_files:
- ../roles/meraki/defaults/main.yml
- ../roles/meraki/vars/main.yml
- ../roles/meraki/vars/template.yml
tasks:
- name: create network
cisco.meraki.meraki_network:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
net_name: "{{ item.site_name }}"
state: present
type:
- wireless
- appliance
- switch
- sensor
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
- name: bind network to template
cisco.meraki.meraki_config_template:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
state: present
net_name: "{{ item.site_name }}"
config_template: "{{ template }}"
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
# - name: add device to network
# cisco.meraki.meraki_device:
# auth_key: "{{ auth_key }}"
# org_name: "{{ org_name }}"
# net_name: "{{ item.0.site_name }}"
# serial: "{{ item.1 | default(None) }}"
# state: present
# ignore_errors: true
# when: item.1 is defined and item.1 != none
# loop: "{{ site|subelements('devices') }}"
# loop_control:
# label: "{{ item }}"
# - name: set Device location
# cisco.meraki.meraki_device:
# auth_key: "{{ auth_key }}"
# org_name: "{{ org_name }}"
# net_name: "{{ item.0.site_name }}"
# address: "{{ item.0.site_address }}"
# move_map_marker: true
# serial: "{{ item.1 | default(None) }}"
# state: present
# ignore_errors: true
# when: item.1 is defined and item.1 != none
# loop: "{{ site|subelements('devices') }}"
# loop_control:
# label: "{{ item }}"
# set site Specific IPs based on site_octet
- name: set vlan 1
cisco.meraki.meraki_mx_vlan:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
org_id: "{{ org_id }}"
net_name: "{{ item.site_name }}"
state: present
vlan_id: 10
vlan_name: mgmt
subnet: 10.{{ item.site_octet }}.1.0/28
appliance_ip: 10.{{ item.site_octet }}.1.1
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
ignore_errors: true
- name: set vlan 100
cisco.meraki.meraki_mx_vlan:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
net_name: "{{ item.site_name }}"
state: present
vlan_id: 100
vlan_name: test
subnet: "10.{{ item.site_octet }}.100.0/27"
appliance_ip: 10.{{ item.site_octet }}.100.1
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
- name: set vlan 101 Clients
cisco.meraki.meraki_mx_vlan:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
net_name: "{{ item.site_name }}"
state: present
vlan_id: 101
vlan_name: Clients
subnet: "10.{{ item.site_octet }}.101.0/27"
appliance_ip: 10.{{ item.site_octet }}.101.1
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
- name: set vlan 102 Voice
cisco.meraki.meraki_mx_vlan:
auth_key: "{{ auth_key }}"
org_name: "{{ org_name }}"
net_name: "{{ item.site_name }}"
state: present
vlan_id: 102
name: Voice
subnet: "10.{{ item.site_octet }}.102.0/27"
appliance_ip: 10.{{ item.site_octet }}.102.1
loop: "{{ site }}"
loop_control:
label: "{{ item.site_name }}"
# vars template.yml
template: template-1
site:
- site_name: site 1
site_address: Banana, Kiribati
site_octet: 12
device:
- serial1
- serial2
- site_name: site 2
site_address: Germany, Frankfurt
site_octet: 13
device:
- serial3
- serial4
@oliverl-21 I am going to close this issue for the moment. However, if you experience it again, please open the issue again. With the test case I'll be able to delve into it better, if it's indeed a problem again.