Giter VIP home page Giter VIP logo

Comments (14)

kbreit avatar kbreit commented on July 24, 2024 1

Happens to everyone.

I fixed the HTTP error handling in the collection, maybe at version 1.0 so it wasn’t always in collections and never was in the mainline Ansible code. Additionally this supports rate limiting.

Also, if you have feature requests or new module requests please let me know. Always looking for feedback.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024 1

Closing this issue as it appears to be resolved. Please open issues as new features are needed or bugs are discovered

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

Thanks for reporting this.

Are you still seeing the problem? I created a test case and it worked and my integration tests are working. Are you able to provide me an example site code, timezone, etc. that you'd use? Make up the information but I want to get this as close to yours as I can.

No matter what, this shouldn't have crashed on a 400 error. What version of Ansible are you using? Also, are you using the collection? Update...you already provided the Ansible version. Are you using the collection?

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Hey thanks for looking at this for me, here are the vars I'm using:
site_code: RDU
time_zone: America/New York

I'm using the built in Ansible modules on the latest version, should I move to the collections?

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

I would recommend moving to the collection. All (almost?) future development will be in the collection and not mainline Ansible. In fact the collection already has new modules and bug fixes that mainline doesn’t.

Please try the collection but I see two issues at hand. First is the handling of the 400 code and the second is the reason 400 has been generated. Give me a little time to work through it and let me know if collections help.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

No worries man thanks for working on this, i'll try the collections :-)

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

I'm seeing the same error with the collections, but I'm not sure if I'm referencing them correctly:

# Meraki MR Device deployment
---
- name: deploy wireless devices
  hosts: localhost
  connection: local
  gather_facts: no 
  #debugger: on_failed
  collections:
   - /home/flynn/.ansible/collections/ansible_collections/cisco/meraki
  
  # import the var files which include the ansible vault meraki aip key
  vars_files:
   - ./vault/meraki
   - ./group_vars/mr_CRIV.yml
        
  # set roles to be used in the playbook
  roles:
  # List of tags for use when scoping down the functions of the playbook
  # create_wireless_network - create_wap_network
  # claim_wireless_devices - claim_mr
  # bind_wireless_network_to_template - bind_mr
  # update_wireless_devices - update_mr
  
   - create_wireless_network

task:

---
# tasks file for create_wireless_network
  - name: "Create Meraki Wireless - {{  site_code  }} network"
    meraki_network:
     auth_key: "{{  auth_key  }}"
     state: present
     org_name: "{{  org_name_wireless  }}"
     net_name: "Wireless - {{  site_code  }}"
     type: 
      - "wireless"
     timezone: "{{  time_zone  }}"
     tags: 
      - "{{  site_code  }}"
     internal_error_retry_time: 60
    delegate_to: localhost
    tags:
     - create_wap_network

Output

flynn@NCL-WL-16612:~/ansible-meraki$ ansible-playbook deploy_global_wireless_devices.yml -vvv
ansible-playbook 2.9.7
  config file = /home/flynn/ansible-meraki/ansible.cfg
  configured module search path = [u'/home/flynn/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.17 (default, Nov  7 2019, 10:07:09) [GCC 7.4.0]
Using /home/flynn/ansible-meraki/ansible.cfg as config file
host_list declined parsing /home/flynn/ansible-meraki/inventory as it did not pass its verify_file() method
script declined parsing /home/flynn/ansible-meraki/inventory as it did not pass its verify_file() method
auto declined parsing /home/flynn/ansible-meraki/inventory as it did not pass its verify_file() method
Parsed /home/flynn/ansible-meraki/inventory inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'

PLAYBOOK: deploy_global_wireless_devices.yml ********************************************************************************************************************
1 plays in deploy_global_wireless_devices.yml
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'

PLAY [deploy wireless devices] **********************************************************************************************************************************
META: ran handlers
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'
Read vars_file './vault/meraki'
Read vars_file './group_vars/mr_CRIV.yml'

TASK [create_wireless_network : Create Meraki Wireless - RDU network] *******************************************************************************************
task path: /home/flynn/ansible-meraki/roles/create_wireless_network/tasks/main.yml:3
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: flynn
<localhost> EXEC /bin/sh -c 'echo ~flynn && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/flynn/.ansible/tmp `"&& mkdir /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164 && echo ansible-tmp-1589060835.15-1186-198313268104164="` echo /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/network/meraki/meraki_network.py
<localhost> PUT /home/flynn/.ansible/tmp/ansible-local-1180X8GHbp/tmpPFUgCk TO /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/ /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python2 /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py", line 102, in <module>
    _ansiballz_main()
  File "/home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.network.meraki.meraki_network', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python2.7/runpy.py", line 188, in run_module
    fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_meraki_network_payload_LmxGK6/ansible_meraki_network_payload.zip/ansible/modules/network/meraki/meraki_network.py", line 390, in <module>
  File "/tmp/ansible_meraki_network_payload_LmxGK6/ansible_meraki_network_payload.zip/ansible/modules/network/meraki/meraki_network.py", line 371, in main
  File "/tmp/ansible_meraki_network_payload_LmxGK6/ansible_meraki_network_payload.zip/ansible/module_utils/network/meraki/meraki.py", line 116, in inner
ansible.module_utils.network.meraki.meraki.HTTPError: HTTP error 400 - None
fatal: [localhost -> localhost]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "/home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py", line 102, in <module>
        _ansiballz_main()
      File "/home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/flynn/.ansible/tmp/ansible-tmp-1589060835.15-1186-198313268104164/AnsiballZ_meraki_network.py", line 40, in invoke_module
        runpy.run_module(mod_name='ansible.modules.network.meraki.meraki_network', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib/python2.7/runpy.py", line 188, in run_module
        fname, loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
        mod_name, mod_fname, mod_loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/tmp/ansible_meraki_network_payload_LmxGK6/ansible_meraki_network_payload.zip/ansible/modules/network/meraki/meraki_network.py", line 390, in <module>
      File "/tmp/ansible_meraki_network_payload_LmxGK6/ansible_meraki_network_payload.zip/ansible/modules/network/meraki/meraki_network.py", line 371, in main
      File "/tmp/ansible_meraki_network_payload_LmxGK6/ansible_meraki_network_payload.zip/ansible/module_utils/network/meraki/meraki.py", line 116, in inner
    ansible.module_utils.network.meraki.meraki.HTTPError: HTTP error 400 - None
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

PLAY RECAP ******************************************************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

I've installed them and they're located in the correct place.

flynn@NCL-WL-16612:~/ansible-meraki$ ll /home/flynn/.ansible/collections/ansible_collections/cisco/meraki/
total 1108
drwxrwxrwx 1 flynn flynn     512 May  9 16:08 ./
drwxrwxrwx 1 flynn flynn     512 May  9 16:07 ../
-rw-r--r-- 1 flynn flynn    6148 May  9 16:07 .DS_Store
-rw-r--r-- 1 flynn flynn      91 May  9 16:08 .env
-rw-r--r-- 1 flynn flynn      60 May  9 16:08 .gitignore
drwxrwxrwx 1 flynn flynn     512 May  9 16:08 .vscode/
-rw-r--r-- 1 flynn flynn    2303 May  9 16:07 CHANGELOG.md
-rw-r--r-- 1 flynn flynn 1108190 May  9 16:07 FILES.json
-rw-r--r-- 1 flynn flynn     800 May  9 16:07 MANIFEST.json
-rw-r--r-- 1 flynn flynn    7729 May  9 16:08 README.md
drwxrwxrwx 1 flynn flynn     512 May  9 16:07 plugins/
drwxrwxrwx 1 flynn flynn     512 May  9 16:08 tests/

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

Easy way to test if you’re using the collection. Try to run a task using meraki_switch_stack. A simple query is good enough. I don’t have that in mainline Ansible so if it works you’re using the collection.

- name: Query one stack
  meraki_switch_stack:
    auth_key: abc123
    state: query
    org_name: YourOrg
    net_name: YourNet

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Yeah you're right:

flynn@NCL-WL-16612:~/ansible-meraki$ ansible-playbook collections_test.yml 
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! couldn't resolve module/action 'meraki_switch_stack'. This often indicates a misspelling, missing collection, or incorrect module path.

Do you have an example on referencing the collections?

# Meraki MX Device deployment
---
- name: deploy wireless devices
  hosts: localhost
  connection: local
  gather_facts: no 
  #debugger: on_failed
  collections:
   - cieco.meraki
  
  # import the var files which include the ansible vault meraki aip key
  vars_files:
   - ./vault/meraki

  # set roles to be used in the playbook
  tasks:
    - name: "Collections test"
      meraki_switch_stack:
       auth_key: "{{  auth_key  }}"
       state: query
       org_name: "test_org"
       net_name: "switch_network"

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

You misspelled cisco in the collections as cieco. Correct that and run again, let me know. Thanks.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

Good and bad news. Good news, I reproduced your bug. Bad news, I reproduced it. Give me a little time to look into it.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

I think I found the problem. Is your line for timezone timezone: America/New York verbatim? Timezones aren't allowed to have spaces and instead have underscores so timezone: America/New_York should be valid. Please test this fix and let me know if it resolves this issue. If it does, I have a patch ready to go which will check for spaces and fail with a more descriptive error.

Either way, you shouldn't receive a traceback on a 400 error. I'm going to look into that more. Unfortunately, the request code is by far the ugliest piece of code in the modules so it's going to be a little more tough to fix. We'll see.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

Another update. I've tested this against the collection and I'm handling the exception properly. Please see the output below:

fatal: [localhost -> localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "body": {"errors": ["Time zone is not a valid time zone"]}, "changed": false, "msg": "HTTP error 400 - https://api.meraki.com/api/v0/organizations/12345/networks - ['Time zone is not a valid time zone']", "response": "HTTP Error 400: Bad Request", "status": 400}

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Hey man, I'm sorry I should have caught that, first off the collections are working when you spell Cisco correctly:-) Also setting the timezone format correctly resolves my initial issue. So have the collections always been able to handle the http 400 errors or have you just added this? I don't seem to be able to reproduce the same fatal error using the collections.

Thanks again man I really appreciate you helping me out, sorry they were mostly human error ;-)

from ansible-meraki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.