From 13bff48fb33d4016568efbb75cf712f20ee0be91 Mon Sep 17 00:00:00 2001 From: Laxmikant Chintakindi Date: Tue, 26 Nov 2024 18:28:14 +0530 Subject: [PATCH] Feat(eos_cli_config_gen): Add support for ip name server groups --- .../documentation/devices/host1.md | 5 ++ .../intended/configs/host1.cfg | 15 ++++++ .../host_vars/host1/ip_name_server_groups.yml | 20 ++++++++ .../host_vars/host1/monitor-connectivity.yml | 1 + .../docs/tables/ip-name-server-groups.md | 38 ++++++++++++++ .../docs/tables/ip-name-servers.md | 13 ----- .../docs/tables/monitor-connectivity.md | 4 ++ .../documentation/monitor-connectivity.j2 | 6 +++ .../j2templates/eos-intended-config.j2 | 2 + .../j2templates/eos/ip-name-server-groups.j2 | 27 ++++++++++ .../j2templates/eos/monitor-connectivity.j2 | 3 ++ .../schema/eos_cli_config_gen.schema.yml | 49 +++++++++++++------ .../ip_name_server_groups.schema.yml | 24 +++++++++ .../ip_name_servers.schema.yml | 2 +- .../monitor_connectivity.schema.yml | 3 ++ 15 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip_name_server_groups.yml create mode 100644 ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-server-groups.md create mode 100644 python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-server-groups.j2 create mode 100644 python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_server_groups.schema.yml diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md index 402324f1856..9ccbf41fe26 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/documentation/devices/host1.md @@ -1951,6 +1951,10 @@ monitor server radius | Name | Interfaces | | ---- | ---------- | +##### Name-server + +Name-server Group: mynameserver1 + ### Monitor Connectivity Device Configuration ```eos @@ -1991,6 +1995,7 @@ monitor connectivity url https://server2.local.com ! vrf yellow + name-server group mynameserver1 interval 5 no shutdown interface set GLOBAL_SET Ethernet1-4 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg index 8005d54543c..dbd3734112e 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/intended/configs/host1.cfg @@ -278,6 +278,20 @@ monitor server radius probe threshold failure 100 probe method access-request username arista password 7 141600021F102B ! +ip name-server group mynameserver0 + name-server vrf default 1.1.1.1 + name-server vrf default 8.8.8.8 + name-server vrf default 2.2.2.2 priority 1 + dns domain arista.avd.com + ip domain-list domain-list1 +! +ip name-server group mynameserver1 + name-server vrf default 1.1.1.1 + name-server vrf vrf1 8.8.8.8 + name-server vrf vrf1 2.2.2.2 priority 1 + dns domain arista.avd.com + ip domain-list domain-list1 +! ip nat translation address selection hash field source-ip ip nat translation address selection any ip nat translation tcp-timeout 7200 @@ -2996,6 +3010,7 @@ monitor connectivity url https://server2.local.com ! vrf yellow + name-server group mynameserver1 interval 5 no shutdown interface set GLOBAL_SET Ethernet1-4 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip_name_server_groups.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip_name_server_groups.yml new file mode 100644 index 00000000000..5094cadfd30 --- /dev/null +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/ip_name_server_groups.yml @@ -0,0 +1,20 @@ +--- +ip_name_server_groups: + - name: mynameserver1 + ip_domain_list: domain-list1 + dns_domain: arista.avd.com + name_servers: + - ip_address: 8.8.8.8 + vrf: vrf1 + - ip_address: 1.1.1.1 + - ip_address: 2.2.2.2 + vrf: vrf1 + priority: 1 + - name: mynameserver0 + ip_domain_list: domain-list1 + dns_domain: arista.avd.com + name_servers: + - ip_address: 8.8.8.8 + - ip_address: 1.1.1.1 + - ip_address: 2.2.2.2 + priority: 1 diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/monitor-connectivity.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/monitor-connectivity.yml index 7c11abd5eb3..adeea6395c1 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/monitor-connectivity.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen/inventory/host_vars/host1/monitor-connectivity.yml @@ -8,6 +8,7 @@ monitor_connectivity: - name: HOST_SET interfaces: Loopback2-4, Loopback10-12 local_interfaces: GLOBAL_SET + name_server_group: mynameserver1 hosts: - name: server1 description: server1_connectivity_monitor diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-server-groups.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-server-groups.md new file mode 100644 index 00000000000..58c65bd3f09 --- /dev/null +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-server-groups.md @@ -0,0 +1,38 @@ + +=== "Table" + + | Variable | Type | Required | Default | Value Restrictions | Description | + | -------- | ---- | -------- | ------- | ------------------ | ----------- | + | [ip_name_server_groups](## "ip_name_server_groups") | List, items: Dictionary | | | | | + | [  - name](## "ip_name_server_groups.[].name") | String | Required, Unique | | | | + | [    name_servers](## "ip_name_server_groups.[].name_servers") | List, items: Dictionary | | | | | + | [      - ip_address](## "ip_name_server_groups.[].name_servers.[].ip_address") | String | Required | | | IPv4 or IPv6 address for DNS server. | + | [        vrf](## "ip_name_server_groups.[].name_servers.[].vrf") | String | | | | VRF Name. | + | [        priority](## "ip_name_server_groups.[].name_servers.[].priority") | Integer | | | Min: 0
Max: 4 | Priority value (lower is first). | + | [    dns_domain](## "ip_name_server_groups.[].dns_domain") | String | | | | | + | [    ip_domain_list](## "ip_name_server_groups.[].ip_domain_list") | String | | | | Set domain names to complete unqualified host names. | + +=== "YAML" + + ```yaml + ip_name_server_groups: + - name: + name_servers: + + # IPv4 or IPv6 address for DNS server. + - ip_address: + + # VRF Name. + vrf: + + # Priority value (lower is first). + priority: + dns_domain: + + # Set domain names to complete unqualified host names. + ip_domain_list: + ``` diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md index 35e93124ad2..1d5d57c122d 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/ip-name-servers.md @@ -7,23 +7,10 @@ | Variable | Type | Required | Default | Value Restrictions | Description | | -------- | ---- | -------- | ------- | ------------------ | ----------- | - | [ip_name_servers](## "ip_name_servers") | List, items: Dictionary | | | | | - | [  - ip_address](## "ip_name_servers.[].ip_address") | String | Required | | | IPv4 or IPv6 address for DNS server. | - | [    vrf](## "ip_name_servers.[].vrf") | String | | | | VRF Name. | - | [    priority](## "ip_name_servers.[].priority") | Integer | | | Min: 0
Max: 4 | Priority value (lower is first). | | [name_server](## "name_server") removed | Dictionary | | | | This key was removed. Support was removed in AVD version v5.0.0. Use ip_name_servers instead. | === "YAML" ```yaml - ip_name_servers: - # IPv4 or IPv6 address for DNS server. - - ip_address: - - # VRF Name. - vrf: - - # Priority value (lower is first). - priority: ``` diff --git a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/monitor-connectivity.md b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/monitor-connectivity.md index c883cb409fc..dd43201edf4 100644 --- a/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/monitor-connectivity.md +++ b/ansible_collections/arista/avd/roles/eos_cli_config_gen/docs/tables/monitor-connectivity.md @@ -22,6 +22,7 @@ | [      local_interfaces](## "monitor_connectivity.hosts.[].local_interfaces") | String | | | | | | [      address_only](## "monitor_connectivity.hosts.[].address_only") | Boolean | | `True` | | When address-only is configured, the source IP of the packet is set to the interface
IP but the packet may exit the device via a different interface.
When set to `false`, the probe uses the interface to exit the device. | | [      url](## "monitor_connectivity.hosts.[].url") | String | | | | | + | [  name_server_group](## "monitor_connectivity.name_server_group") | String | | | | Set name-server group. | | [  vrfs](## "monitor_connectivity.vrfs") | List, items: Dictionary | | | | | | [    - name](## "monitor_connectivity.vrfs.[].name") | String | Required, Unique | | | VRF Name. | | [      description](## "monitor_connectivity.vrfs.[].description") | String | | | | | @@ -69,6 +70,9 @@ # When set to `false`, the probe uses the interface to exit the device. address_only: url: + + # Set name-server group. + name_server_group: vrfs: # VRF Name. diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/monitor-connectivity.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/monitor-connectivity.j2 index 0e1f86db500..9aeb3c4cd47 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/monitor-connectivity.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/documentation/monitor-connectivity.j2 @@ -81,6 +81,12 @@ {% endif %} {% endfor %} {% endif %} +{% if monitor_connectivity.name_server_group is arista.avd.defined %} + +##### Name-server + +Name-server Group: {{ monitor_connectivity.name_server_group }} +{% endif %} ### Monitor Connectivity Device Configuration diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos-intended-config.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos-intended-config.j2 index 081816342e6..1cb9ea5b926 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos-intended-config.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos-intended-config.j2 @@ -88,6 +88,8 @@ {% include 'eos/mcs-client.j2' %} {# monitor server radius #} {% include 'eos/monitor-server-radius.j2' %} +{# ip name-server groups #} +{% include 'eos/ip-name-server-groups.j2' %} {# platform - trident#} {% include 'eos/platform-trident.j2' %} {# IP NAT - Part 1#} diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-server-groups.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-server-groups.j2 new file mode 100644 index 00000000000..82cc8baf430 --- /dev/null +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/ip-name-server-groups.j2 @@ -0,0 +1,27 @@ +{# + Copyright (c) 2023-2024 Arista Networks, Inc. + Use of this source code is governed by the Apache License 2.0 + that can be found in the LICENSE file. +#} +{% for name_server_group in ip_name_server_groups | arista.avd.natural_sort("name") %} +! +ip name-server group {{ name_server_group.name }} +{% for name_server in name_server_group.name_servers | arista.avd.natural_sort("ip_address") %} +{% if name_server.priority is not arista.avd.defined %} +{% set name_server_cli = "name-server vrf " ~ name_server.vrf | arista.avd.default("default") ~ " " ~ name_server.ip_address %} + {{ name_server_cli }} +{% endif %} +{% endfor %} +{% for name_server in name_server_group.name_servers | arista.avd.natural_sort("ip_address") %} +{% if name_server.priority is arista.avd.defined %} +{% set name_server_cli = "name-server vrf " ~ name_server.vrf | arista.avd.default("default") ~ " " ~ name_server.ip_address ~ " priority " ~ name_server.priority %} + {{ name_server_cli }} +{% endif %} +{% endfor %} +{% if name_server_group.dns_domain is arista.avd.defined %} + dns domain {{ name_server_group.dns_domain }} +{% endif %} +{% if name_server_group.ip_domain_list is arista.avd.defined %} + ip domain-list {{ name_server_group.ip_domain_list }} +{% endif %} +{% endfor %} diff --git a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/monitor-connectivity.j2 b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/monitor-connectivity.j2 index 1a4e86055ca..d4585382f71 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/monitor-connectivity.j2 +++ b/python-avd/pyavd/_eos_cli_config_gen/j2templates/eos/monitor-connectivity.j2 @@ -54,6 +54,9 @@ monitor connectivity {% endfor %} {% endif %} {% endfor %} +{% if monitor_connectivity.name_server_group is arista.avd.defined %} + name-server group {{ monitor_connectivity.name_server_group }} +{% endif %} {% if monitor_connectivity.interval is arista.avd.defined %} interval {{ monitor_connectivity.interval }} {% endif %} diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml index 042cf8d9eec..e8092de63e2 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/eos_cli_config_gen.schema.yml @@ -5264,27 +5264,22 @@ keys: per-vlan. ' - ip_name_servers: + ip_name_server_groups: type: list + primary_key: name items: type: dict keys: - ip_address: + name: type: str - required: true - description: IPv4 or IPv6 address for DNS server. - vrf: - description: VRF Name. + name_servers: + type: list + $ref: eos_cli_config_gen#/$defs/ip_name_servers + dns_domain: type: str - convert_types: - - int - priority: - description: Priority value (lower is first). - type: int - convert_types: - - str - min: 0 - max: 4 + ip_domain_list: + type: str + description: Set domain names to complete unqualified host names. ip_nat: type: dict keys: @@ -8106,6 +8101,9 @@ keys: default: true url: type: str + name_server_group: + type: str + description: Set name-server group. vrfs: type: list primary_key: name @@ -22381,3 +22379,24 @@ $defs: min: 1 max: 65535 description: requires 'original_port'. + ip_name_servers: + type: list + items: + type: dict + keys: + ip_address: + type: str + required: true + description: IPv4 or IPv6 address for DNS server. + vrf: + description: VRF Name. + type: str + convert_types: + - int + priority: + description: Priority value (lower is first). + type: int + convert_types: + - str + min: 0 + max: 4 diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_server_groups.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_server_groups.schema.yml new file mode 100644 index 00000000000..b5dfa6bdcb8 --- /dev/null +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_server_groups.schema.yml @@ -0,0 +1,24 @@ +# Copyright (c) 2023-2024 Arista Networks, Inc. +# Use of this source code is governed by the Apache License 2.0 +# that can be found in the LICENSE file. +# yaml-language-server: $schema=../../../_schema/avd_meta_schema.json +# Line above is used by RedHat's YAML Schema vscode extension +# Use Ctrl + Space to get suggestions for every field. Autocomplete will pop up after typing 2 letters. +type: dict +keys: + ip_name_server_groups: + type: list + primary_key: name + items: + type: dict + keys: + name: + type: str + name_servers: + type: list + $ref: "eos_cli_config_gen#/$defs/ip_name_servers" + dns_domain: + type: str + ip_domain_list: + type: str + description: Set domain names to complete unqualified host names. diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml index 5d71dcdfe2b..06aeb455fe8 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/ip_name_servers.schema.yml @@ -5,7 +5,7 @@ # Line above is used by RedHat's YAML Schema vscode extension # Use Ctrl + Space to get suggestions for every field. Autocomplete will pop up after typing 2 letters. type: dict -keys: +$defs: ip_name_servers: type: list items: diff --git a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/monitor_connectivity.schema.yml b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/monitor_connectivity.schema.yml index 545cea7a9e5..0c22ae0c0b6 100644 --- a/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/monitor_connectivity.schema.yml +++ b/python-avd/pyavd/_eos_cli_config_gen/schema/schema_fragments/monitor_connectivity.schema.yml @@ -60,6 +60,9 @@ keys: default: true url: type: str + name_server_group: + type: str + description: Set name-server group. vrfs: type: list primary_key: name