HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible_collections/dellemc/os6/roles/os6_snmp/templates/os6_snmp.j2
#jinja2: trim_blocks: True,lstrip_blocks: True
{####################################

Purpose:
Configure snmp commands for os6 Devices

os6_snmp:
    snmp_contact:  test
    snmp_location: Santa Clara
    snmp_community:
      - name: public
        access_mode: ro
        state: absent
      - name: private
        access_mode: rw
        state: absent
    snmp_traps: 
      - name: all
        state: present
    snmp_host:
      - ip: 4.4.4.4
        communitystring: public
        udpport: 1
        state: absent

#####################################}
{% if os6_snmp is defined and os6_snmp %}

{% for key,value in os6_snmp|dictsort %}
  {% if key=="snmp_contact" %}
    {% if value %}
snmp-server contact "{{ value }}"
    {% else %}
no snmp-server contact
    {% endif %}
  {% elif key == "snmp_location" %}
    {% if value  %}
snmp-server location "{{ value }}"
    {% else %}
no snmp-server location
    {% endif %}
  {% elif key == "snmp_community" %}
    {% if value %}
      {% for item in value %}
        {% if item.name is defined and item.name %}
          {% if item.state is defined and item.state == "absent" %}
no snmp-server community {{ item.name }}
          {% else %}
            {% if item.access_mode is defined and item.access_mode %}
snmp-server community "{{ item.name }}" {{ item.access_mode }}
            {% endif %}
          {% endif %}
        {% endif %}
      {% endfor %}
    {% endif %}
  {% elif key == "snmp_host" and value %}
    {% for item in value %}
      {% if item.ip is defined and item.ip %}
        {% if item.state is defined and item.state == "absent" %}
no snmp-server host {{ item.ip }} traps
        {% else %}
          {% if item.communitystring is defined and item.communitystring %}
            {% if item.udpport is defined and item.udpport %}
snmp-server host {{ item.ip }} "{{ item.communitystring }}" udp-port {{ item.udpport }}
            {% else %}
snmp-server host {{ item.ip }} "{{ item.communitystring }}"
            {% endif %}
          {% endif %}
        {% endif %}
      {% endif %}
    {% endfor%}
  {% elif key == "snmp_traps" %}
    {% if value %}
      {% for val in value %}
        {% if val.name is defined and val.name %}
          {% if val.state is defined and val.state == "absent" %}
no snmp-server enable traps {{ val.name }}
          {% else %}
            {% if val.name == "all" %}
              {% set trap_list = ['bgp state-changes limited','dvmrp','captive-portal','pim','captive-portal client-auth-failure','captive-portal client-connect','captive-portal client-db-full','captive-portal client-disconnect'] %}
              {% for name in trap_list %}
snmp-server enable traps {{ name }}
              {% endfor %}
            {% else %}
snmp-server enable traps {{ val.name }}
            {% endif %}
          {% endif %}
        {% endif %}
      {% endfor %}
    {% endif %}

  {% endif %}
{% endfor %}
{% endif %}