Compare commits

...

4 commits

Author SHA1 Message Date
60dd62c00f access: increase command timeout when setting config
Some options take a while to enable. Like port-security.
2025-03-18 14:40:18 +01:00
08a0cdd994 exit: update package cache before installing stuff 2025-03-18 14:17:59 +01:00
c0156b4899 exit: bump keepalive version
And drop unneeded (also nonexistent) dependency.
2025-03-18 14:17:31 +01:00
07fa350ae6 access: enable port-security
Should prevent one way of network coming down. Again.
2025-03-17 15:41:48 +01:00
4 changed files with 20 additions and 4 deletions

View file

@ -15,7 +15,7 @@
ansible.netcommon.cli_config: ansible.netcommon.cli_config:
config: '{{ lookup("template", "config-"~manufacturer~"-"~device_type~".j2") }}' config: '{{ lookup("template", "config-"~manufacturer~"-"~device_type~".j2") }}'
vars: vars:
ansible_command_timeout: 60 ansible_command_timeout: 240
ansible_terminal_stderr_re: [] # some errors are not actually errors ansible_terminal_stderr_re: [] # some errors are not actually errors
register: result register: result
# These lines are not displayed by 'sho ru' and always reported as different, so ignore them. # These lines are not displayed by 'sho ru' and always reported as different, so ignore them.

View file

@ -10,6 +10,7 @@ ip ssh server
vlan {{ vlans | map(attribute='vid') | compact_numlist }} vlan {{ vlans | map(attribute='vid') | compact_numlist }}
{# bond members #}
{% for iface in interfaces | selectattr('lag') %} {% for iface in interfaces | selectattr('lag') %}
interface {{ iface.name }} interface {{ iface.name }}
{% if iface.enabled %} no{% endif %} shutdown {% if iface.enabled %} no{% endif %} shutdown
@ -17,13 +18,21 @@ interface {{ iface.name }}
{% endfor %} {% endfor %}
{# access interfaces #}
{%- set mgmt = namespace(ip=false, gw=false) %} {%- set mgmt = namespace(ip=false, gw=false) %}
{%- for iface in interfaces | rejectattr('lag') %} {%- for iface in interfaces | rejectattr('lag') %}
interface {{ iface.name }} interface {{ iface.name }}
{% if iface.type.value != 'lag' %} {# common setup for user-facing interfaces #}
{% if iface.type.value != 'lag' and not iface.mgmt_only %}
switchport port-security
switchport port-security maximum 250
switchport port-security violation shutdown
switchport port-security aging time 5
switchport port-security aging type inactivity
{% if iface.enabled %} no shutdown{% else %} shutdown{% endif %} {% if iface.enabled %} no shutdown{% else %} shutdown{% endif %}
{% endif %} {% endif %}
{# set VLAN for untagged ports #}
{%+ if iface.mode and iface.mode.value == 'access' %} {%+ if iface.mode and iface.mode.value == 'access' %}
switchport mode access switchport mode access
{% if iface.untagged_vlan and iface.untagged_vlan.vid != 1 %} {% if iface.untagged_vlan and iface.untagged_vlan.vid != 1 %}
@ -37,6 +46,9 @@ interface {{ iface.name }}
no voice vlan enable no voice vlan enable
{% endif %} {% endif %}
{# set tagged and native VLANs for tagged ports #}
{# if native (untagged) VLAN is set, add it to the list of tagged VLANs #}
{# without this, the switch won’t forward traffic #}
{%+ elif iface.mode and iface.mode.value == 'tagged' %} {%+ elif iface.mode and iface.mode.value == 'tagged' %}
switchport mode trunk switchport mode trunk
{% if iface.untagged_vlan %} {% if iface.untagged_vlan %}
@ -48,10 +60,12 @@ interface {{ iface.name }}
{% endif %} {% endif %}
switchport trunk allowed vlan {{ iface_vlans | map(attribute='vid') | compact_numlist }} switchport trunk allowed vlan {{ iface_vlans | map(attribute='vid') | compact_numlist }}
{# we don’t support any other mode #}
{%+ else %} {%+ else %}
{% endif %} {% endif %}
{# store management address and gateway for later #}
{%- if iface.mgmt_only and iface.ip_addresses %} {%- if iface.mgmt_only and iface.ip_addresses %}
{% set mgmt.ip = iface.ip_addresses[0].address %} {% set mgmt.ip = iface.ip_addresses[0].address %}
{% if iface.custom_fields.gateway %} {% if iface.custom_fields.gateway %}
@ -66,6 +80,7 @@ interface {{ iface.name }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{# management VLAN #}
{%- if mgmt.ip %} {%- if mgmt.ip %}
interface Vlan1 interface Vlan1
ip address {{ mgmt.ip | ipaddr('address') }} {{ mgmt.ip | ipaddr('netmask') }} ip address {{ mgmt.ip | ipaddr('address') }} {{ mgmt.ip | ipaddr('netmask') }}

View file

@ -3,13 +3,13 @@
block: block:
- name: Install deps for keepalived - name: Install deps for keepalived
package: package:
name: autoconf,automake,build-essential,pkg-config,libxtables-dev,libip4tc-dev,libip6tc-dev,libipset-dev,libnl-3-dev,libnl-genl-3-dev,libssl-dev name: autoconf,automake,build-essential,pkg-config,libxtables-dev,libip4tc-dev,libip6tc-dev,libnl-3-dev,libnl-genl-3-dev,libssl-dev
- name: Checkout keepalived source - name: Checkout keepalived source
git: git:
repo: https://github.com/acassen/keepalived repo: https://github.com/acassen/keepalived
dest: /usr/local/src/keepalived dest: /usr/local/src/keepalived
version: v2.2.7 version: v2.3.2
- name: Build and install keepalived - name: Build and install keepalived
shell: | shell: |

View file

@ -5,6 +5,7 @@
- name: Install deps for radvd - name: Install deps for radvd
package: package:
name: autoconf,automake,bison,build-essential,flex,gettext,libtool,pkg-config,libbsd-dev,libbsd0 name: autoconf,automake,bison,build-essential,flex,gettext,libtool,pkg-config,libbsd-dev,libbsd0
update_cache: true
- name: Checkout radvd source - name: Checkout radvd source
git: git: