From cf6fcbadd60fc16ccb2415d9f28849c41e439916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=E2=80=A8?= Date: Fri, 27 Nov 2020 11:15:24 +0100 Subject: [PATCH 1/2] #201 Creating Jinja template and documentation --- .../arista/avd/roles/eos_cli_config_gen/README.md | 15 +++++++++++++++ .../templates/eos/snmp-settings.j2 | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md index 28c7867a539..e538361e12b 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md @@ -358,6 +358,21 @@ Redundancy: ```yaml snmp_server: + communities: + - < community_name_1 >: + access: < ro | rw > + access_list_ipv4: + name: < acl_ipv4_name > + access_list_ipv6: + name: < acl_ipv6_name > + view: + - < community_name_2 >: + access: < ro | rw > + access_list_ipv4: + name: < acl_ipv4_name > + access_list_ipv6: + name: < acl_ipv6_name > + view: contact: < contact_name > location: < location > local_interfaces: diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 index 0ea19cbc06e..9f9c44a4a89 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 @@ -18,6 +18,11 @@ snmp-server view {{ view['name'] }} {{ view['MIB_family_name'] }} {% if view['in {% endfor %} {% endif %} +{% if snmp_server.communities is defined and snmp_server.communities is not none %} +{% for community in communities | arista.avd.natural_sort %} +snmp-server community {{ community }} {% if snmp_server.communities[community].view is not none %}view {{ snmp_server.communities[community].view }} {% endif %}{% if snmp_server.communities[community].access is defined %} {{ snmp_server.communities[community].access }} {% else %} ro {% endif %} {% if snmp_server.communities[community].access_list_ipv6.name is not none %} ipv6 {{ snmp_server.communities[community].access_list_ipv6.name }} {% endif %}{% if snmp_server.communities[community].access_list_ipv4.name is not none %}{{ snmp_server.communities[community].access_list_ipv4.name }} {% endif %} +{% endfor %} +{% endif %} {% if snmp_server.groups is defined and snmp_server.groups is not none %} {% for group in snmp_server.groups %} snmp-server group {{ group['name'] }} {{ group['version'] }} {% if group['authentication']is defined and group['version'] == 'v3' %} {{ group['authentication'] }} {% endif %}{% if group['read'] is defined %}read {{ group['read'] }} {% endif %}{% if group['write'] is defined %}write {{ group['write'] }}{% endif %}{% if group['notify'] is defined %}notify {{ group['notify'] }} {% endif %} From e13f18310bd6c8ddcad797d1c642257cb9d9820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=E2=80=A8?= Date: Tue, 8 Dec 2020 10:35:57 +0100 Subject: [PATCH 2/2] Changes in loop and documentation --- .../arista/avd/roles/eos_cli_config_gen/README.md | 4 ++-- .../roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md index e538361e12b..417cc59079c 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/README.md @@ -359,14 +359,14 @@ Redundancy: ```yaml snmp_server: communities: - - < community_name_1 >: + < community_name_1 >: access: < ro | rw > access_list_ipv4: name: < acl_ipv4_name > access_list_ipv6: name: < acl_ipv6_name > view: - - < community_name_2 >: + < community_name_2 >: access: < ro | rw > access_list_ipv4: name: < acl_ipv4_name > diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 index 9f9c44a4a89..5e6832dfaf9 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/templates/eos/snmp-settings.j2 @@ -19,8 +19,8 @@ snmp-server view {{ view['name'] }} {{ view['MIB_family_name'] }} {% if view['in {% endfor %} {% endif %} {% if snmp_server.communities is defined and snmp_server.communities is not none %} -{% for community in communities | arista.avd.natural_sort %} -snmp-server community {{ community }} {% if snmp_server.communities[community].view is not none %}view {{ snmp_server.communities[community].view }} {% endif %}{% if snmp_server.communities[community].access is defined %} {{ snmp_server.communities[community].access }} {% else %} ro {% endif %} {% if snmp_server.communities[community].access_list_ipv6.name is not none %} ipv6 {{ snmp_server.communities[community].access_list_ipv6.name }} {% endif %}{% if snmp_server.communities[community].access_list_ipv4.name is not none %}{{ snmp_server.communities[community].access_list_ipv4.name }} {% endif %} +{% for community in snmp_server.communities | arista.avd.natural_sort %} +snmp-server community {{ community }} {% if snmp_server.communities[community].view is defined %}view {{ snmp_server.communities[community].view }} {% endif %}{% if snmp_server.communities[community].access is defined %} {{ snmp_server.communities[community].access }} {% else %} ro {% endif %} {% if snmp_server.communities[community].access_list_ipv6.name is defined %} ipv6 {{ snmp_server.communities[community].access_list_ipv6.name }} {% endif %}{% if snmp_server.communities[community].access_list_ipv4.name is defined %}{{ snmp_server.communities[community].access_list_ipv4.name }} {% endif %} {% endfor %} {% endif %} {% if snmp_server.groups is defined and snmp_server.groups is not none %}