From 3caea818961eea4cfd1a6adaa78f88764197963a Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 1 Sep 2024 10:37:11 +0200 Subject: [PATCH] access: add voice VLAN support --- roles/access/tasks/main.yml | 5 ++++- roles/access/templates/config-d-link.j2 | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/roles/access/tasks/main.yml b/roles/access/tasks/main.yml index 8cd7fd2..4813ea5 100644 --- a/roles/access/tasks/main.yml +++ b/roles/access/tasks/main.yml @@ -5,7 +5,10 @@ - name: Set configuration ansible.netcommon.cli_config: config: '{{ lookup("template", "config-"~manufacturer~"-"~device_type~".j2") }}' + vars: + ansible_command_timeout: 60 + ansible_terminal_stderr_re: [] # some errors are not actually errors register: result # These lines are not displayed by 'sho ru' and always reported as different, so ignore them. - changed_when: result.commands | reject('match', '^(no shutdown|no switchport access vlan|switchport mode access|switchport mode hybrid|interface .*|no enable service web-server https?)$') + changed_when: result.commands | reject('match', '^(no shutdown|no switchport access vlan|no voice vlan.*|switchport mode access|switchport mode hybrid|interface .*|no enable service web-server https?)$') notify: write config diff --git a/roles/access/templates/config-d-link.j2 b/roles/access/templates/config-d-link.j2 index 4e09bc0..ca7c60f 100644 --- a/roles/access/templates/config-d-link.j2 +++ b/roles/access/templates/config-d-link.j2 @@ -30,6 +30,11 @@ interface {{ iface.name }} {% else %} no switchport access vlan {% endif %} +{% if voice_vlan is defined and not iface.mgmt_only %} + voice vlan enable +{% else %} + no voice vlan enable +{% endif %} {%+ elif iface.mode and iface.mode.value == 'tagged' %} switchport mode trunk @@ -52,6 +57,17 @@ interface Vlan1 ip address {{ mgmt.ip | ipaddr('address') }} {{ mgmt.ip | ipaddr('netmask') }} {% endif %} +voice vlan mac-address 2C-3E-CF-00-00-00 FF-FF-FF-00-00-00 description Cisco +voice vlan mac-address 3C-0E-23-00-00-00 FF-FF-FF-00-00-00 description Cisco +voice vlan mac-address B8-38-61-00-00-00 FF-FF-FF-00-00-00 description Cisco +voice vlan mac-address C4-14-3C-00-00-00 FF-FF-FF-00-00-00 description Cisco + +{% if voice_vlan is defined %} +voice vlan {{ voice_vlan }} +{% else %} +no voice vlan +{% endif %} + snmp-server name {{ inventory_hostname }} sntp enable