Giter VIP home page Giter VIP logo

Comments (26)

kbreit avatar kbreit commented on July 24, 2024

Follow up on this one. I've spent some time on this last night and lunch today. Unfortunately, getting idempotency is more challenging than I thought. I'm working through it but taking longer than I hoped.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

@richardjohnallsopp I just submitted a pull request (#204) for this. Can you give it a try and let me know what you think? Thanks.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

What is the process for getting these and running them? If you could point me to some docs I'd appreciate it.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

@richardjohnallsopp There are a couple of ways to go about this. The most straight forward and simple way is to download https://raw.githubusercontent.com/kbreit/ansible-meraki/module/meraki_alert/plugins/modules/meraki_alert.py and save it locally. You should have a directory called ~/.ansible/collections/ansible_collections/cisco/meraki. Copy that file into ~/.ansible/collections/ansible_collections/cisco/meraki/plugins/modules and you should be able to call it like any other module.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Awesome, thanks man I'm off this weekend so will try all this out and report back.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

I get the following from this module:

(tanglewoodgames_meraki) flynn@NCL-WL-16612:~/tanglewoodgames_meraki$ ./configure_mx_home.sh --tags "configure_alerts"

PLAY [localhost] *****************************************************************************

TASK [Gathering Facts] ***********************************************************************
ok: [127.0.0.1]

TASK [configure alert settings] **************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'MerakiModule' object has no attribute 'convert_snake_to_camel'
fatal: [127.0.0.1 -> localhost]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "/home/flynn/.ansible/tmp/ansible-tmp-1602436989.3608868-3174-24665290994372/AnsiballZ_meraki_alert.py", line 102, in <module>
        _ansiballz_main()
      File "/home/flynn/.ansible/tmp/ansible-tmp-1602436989.3608868-3174-24665290994372/AnsiballZ_meraki_alert.py", line 94, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/flynn/.ansible/tmp/ansible-tmp-1602436989.3608868-3174-24665290994372/AnsiballZ_meraki_alert.py", line 40, in invoke_module
        runpy.run_module(mod_name='ansible_collections.cisco.meraki.plugins.modules.meraki_alert', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_meraki_alert_payload_x5wvf7o0/ansible_meraki_alert_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_alert.py", line 330, in <module>
      File "/tmp/ansible_meraki_alert_payload_x5wvf7o0/ansible_meraki_alert_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_alert.py", line 305, in main
      File "/tmp/ansible_meraki_alert_payload_x5wvf7o0/ansible_meraki_alert_payload.zip/ansible_collections/cisco/meraki/plugins/modules/meraki_alert.py", line 234, in construct_payload
    AttributeError: 'MerakiModule' object has no attribute 'convert_snake_to_camel'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Let me know if I'm doing something wrong?

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

I forgot about a change to the module utility I had to do. Please download https://raw.githubusercontent.com/CiscoDevNet/ansible-meraki/2c0bc3ba5d16de222d5c8d7a032a3b9fb4ef4ec9/plugins/module_utils/network/meraki/meraki.py and put it in the plugins/module_utils/network/meraki directory. That should fix it.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Got it, will try and test today.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

@richardjohnallsopp Were you able to test this module?

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

This one completes now, but do you have a list of names for the alert types? Also I have all_admins set to false and it keeps adding it back in. It does add the emails I've listed, but using the gatewayDown example doesn't set an alert.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024
# configure alerts for network
    - name: configure alert settings
      meraki_alert:
        auth_key: "{{   auth_key  }}"
        org_name: "{{  org_name  }}"
        net_name: "{{  network_name  }}"
        state: present
        default_destinations:
          emails:
            "{{  email_list  }}"
          all_admins: false
          snmp: false
        alerts:
          - type: "gatewayDown"
            enabled: yes
            filters:
              timeout: 60
            alert_destinations:
              emails:
                "{{  email_list  }}"
              all_admins: false
              snmp: false
      delegate_to: localhost
      tags:
        - "configure_alerts"

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

I'm not sure how to translate these network alerts into alert type as I see no mention of gateway
image

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

Hopefully I catch you while you're still working and able to test. Here is a list of alerts, which I'll add to the documentation and enforce. What type of network are you using? MX? If so, it's possible it changes the available alerts based on network type.

  • gatewayDown
  • gatewayToRepeater
  • repeaterDown
  • rogueAp
  • settingsChanged
  • vpnConnectivityChange
  • usageAlert
  • weeklyPresence

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Yeah it's an MX network, but it's not setting the alert type (maybe due to the type name) and it's adding all admins regardless of the bool setting.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Yeah so that list you gave kinda makes sense on the MR network:
image
Do you know where to get the MX ones I listed above? It's annoying that API docs don't have a list of all alerts :-(

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

I'm going to provide feedback to the API team to see if they can update documentation.

Regarding where to get it, I did a query (state: query) and it will list the full data structure for the entire network. There you'll manually pull the types.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

That worked to get the alert types and it works great, but it's still adding the all admins despite being set to false:
image

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

I'm looking into the all admins problem right now.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

I'll post the alerts here for anyone else that might need them:

        type: ampMalwareDetected
        type: ampMalwareBlocked
        type: applianceDown
        type: failoverEvent
        type: dhcpNoLeases
        type: rogueDhcp
        type: ipConflict
        type: cellularUpDown
        type: clientConnectivity
        type: vrrp
        type: vpnConnectivityChange
        type: settingsChanged
        type: usageAlert

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

Very helpful, thank you. I'm going to document these and probably enforce the values.

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

@richardjohnallsopp I think I fixed the bug. It's pushed to the branch so please download the file and use the latest version. I've renamed type to alert_type as well.

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

It's working great:
data

# list of alert type
alert_list:
  - type: "ampMalwareDetected"
    state: "yes"
  - type: "ampMalwareBlocked"
    state: "yes"
  - type: "applianceDown"
    state: "yes"
  - type: "failoverEvent"
    state: "yes"
  - type: "dhcpNoLeases"
    state: "no"
  - type: "rogueDhcp"
    state: "no"
  - type: "ipConflict"
    state: "no"
  - type: "cellularUpDown"
    state: "no"
  - type: "clientConnectivity"
    state: "no"
  - type: "vrrp"
    state: "no"
  - type: "vpnConnectivityChange"
    state: "no"
  - type: "settingsChanged"
    state: "no"
  - type: "usageAlert"
    state: "no"

task

   # configure alerts for network
    - name: configure alert settings
      meraki_alert:
        auth_key: "{{   auth_key  }}"
        org_name: "{{  org_name  }}"
        net_name: "{{  network_name  }}"
        state: present
        default_destinations:
          emails:
            "{{  email_list  }}"
          all_admins: false
          snmp: false
        alerts:
          - type: "{{  item.type  }}"
            enabled: "{{  item.state  }}"
            filters:
              timeout: 60
            alert_destinations:
              emails:
                "{{  email_list  }}"
              all_admins: false
              snmp: false
      delegate_to: localhost
      with_items: "{{  alert_list  }}"
      tags:
        - "configure_alert"

output
image

from ansible-meraki.

richardjohnallsopp avatar richardjohnallsopp commented on July 24, 2024

Yup you fixed it, it all works perfectly, thanks so much for the hard work on this man!!

from ansible-meraki.

kbreit avatar kbreit commented on July 24, 2024

@richardjohnallsopp 2.1.0 is released. Please redownload using ansible-galaxy.

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.