From f8ced2516ae5ddda12bb867d60de2e08910c10a2 Mon Sep 17 00:00:00 2001 From: Laxmikant Chintakindi Date: Tue, 20 Aug 2024 16:49:38 +0530 Subject: [PATCH] Refactor(eos_cli_config_gen): Rearrange the eos-cli output to match eos order --- .../documentation/devices/aaa.md | 8 ++++++ .../intended/configs/aaa.cfg | 6 ++++ .../inventory/host_vars/aaa.yml | 9 ++++++ .../j2templates/eos/aaa-server-groups.j2 | 28 +++++++++---------- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/aaa.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/aaa.md index f8b46532894..b532701e989 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/aaa.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/aaa.md @@ -116,11 +116,19 @@ radius-server host 10.10.10.158 key 7 | TACACS1 | tacacs+ | default | 10.10.10.249 | | TACACS2 | tacacs+ | mgt | 192.168.10.157 | | TACACS2 | tacacs+ | default | 10.10.10.248 | +| RADIUS2 | radius | mgt | 192.168.10.157 | +| RADIUS1 | radius | default | 192.168.10.157 | #### AAA Server Groups Device Configuration ```eos ! +aaa group server radius RADIUS1 + server 192.168.10.157 +! +aaa group server radius RADIUS2 + server 192.168.10.157 vrf mgt +! aaa group server tacacs+ TACACS1 server 10.10.10.157 vrf mgt server 10.10.10.249 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/aaa.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/aaa.cfg index a7ba939f1c7..e6ef37f54ba 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/aaa.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/aaa.cfg @@ -9,6 +9,12 @@ tacacs-server host 10.10.10.158 key 7 071B245F5A tacacs-server host 10.10.10.159 key 8a $kUVyoj7FVQ//yw9D2lbqjA==$kxxohBiofI46IX3pw18KYQ==$DOOM0l9uU4TrQt2kyA7XCKtjUA== tacacs-server timeout 10 ! +aaa group server radius RADIUS1 + server 192.168.10.157 +! +aaa group server radius RADIUS2 + server 192.168.10.157 vrf mgt +! aaa group server tacacs+ TACACS1 server 10.10.10.157 vrf mgt server 10.10.10.249 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/aaa.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/aaa.yml index e239dbfbcae..a3678ca8b91 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/aaa.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/aaa.yml @@ -46,6 +46,15 @@ aaa_server_groups: - server: 192.168.10.157 vrf: mgt - server: 10.10.10.248 + - name: RADIUS2 + type: radius + servers: + - server: 192.168.10.157 + vrf: mgt + - name: RADIUS1 + type: radius + servers: + - server: 192.168.10.157 ## AAA Authentication aaa_authentication: diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/aaa-server-groups.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/aaa-server-groups.j2 index 84a3a5fe307..3075ad25606 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/aaa-server-groups.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/aaa-server-groups.j2 @@ -4,22 +4,20 @@ that can be found in the LICENSE file. #} {# eos - aaa server groups #} -{% if aaa_server_groups is arista.avd.defined %} -{% for aaa_server_group in aaa_server_groups %} -{% if aaa_server_group.type is arista.avd.defined and aaa_server_group.name is arista.avd.defined %} +{% for aaa_server_group in aaa_server_groups | arista.avd.natural_sort('type') | arista.avd.natural_sort('name') %} +{% if aaa_server_group.type is arista.avd.defined and aaa_server_group.name is arista.avd.defined %} ! aaa group server {{ aaa_server_group.type }} {{ aaa_server_group.name }} -{% if aaa_server_group.servers is arista.avd.defined %} -{% for server in aaa_server_group.servers %} -{% if server.server is arista.avd.defined %} -{% set server_cli = "server " ~ server.server %} -{% if server.vrf is arista.avd.defined %} -{% set server_cli = server_cli ~ " vrf " ~ server.vrf %} -{% endif %} - {{ server_cli }} +{% if aaa_server_group.servers is arista.avd.defined %} +{% for server in aaa_server_group.servers %} +{% if server.server is arista.avd.defined %} +{% set server_cli = "server " ~ server.server %} +{% if server.vrf is arista.avd.defined %} +{% set server_cli = server_cli ~ " vrf " ~ server.vrf %} {% endif %} -{% endfor %} -{% endif %} + {{ server_cli }} +{% endif %} +{% endfor %} {% endif %} -{% endfor %} -{% endif %} +{% endif %} +{% endfor %}