summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inventory/group_vars/dellos6/main.yml17
-rw-r--r--roles/dellos6/layer2/tasks/main.yml16
-rw-r--r--roles/dellos6/layer2/templates/interfaces.j234
-rw-r--r--roles/dellos6/layer2/templates/vlans.j2 (renamed from roles/dellos6/layer2/templates/vlan.j2)0
4 files changed, 64 insertions, 3 deletions
diff --git a/inventory/group_vars/dellos6/main.yml b/inventory/group_vars/dellos6/main.yml
index 7bf53699..0cb2bcda 100644
--- a/inventory/group_vars/dellos6/main.yml
+++ b/inventory/group_vars/dellos6/main.yml
@@ -18,3 +18,20 @@ dellos6_vlans_yaml: |
- name: "{{ zone_name }}"
id: "{{ switch_network_zones[zone_name].vlan }}"
{% endfor %}
+
+dellos6_interfaces: "{{ dellos6_interfaces_yaml | from_yaml }}"
+dellos6_interfaces_yaml: |
+ - spec: range Gi1/0/5-27
+ vlan: 28
+ - spec: Te1/0/1
+ description: "to sw1"
+ switchport_mode: trunk
+ # - spec: range Te1/0/3-4
+ # channel_group: 1
+ - spec: Po1
+ description: "fileserver"
+ switchport_mode: general
+ allowed_vlans:
+ - 28
+ - 32
+ - 30
diff --git a/roles/dellos6/layer2/tasks/main.yml b/roles/dellos6/layer2/tasks/main.yml
index 75617b1c..a9383e5f 100644
--- a/roles/dellos6/layer2/tasks/main.yml
+++ b/roles/dellos6/layer2/tasks/main.yml
@@ -1,6 +1,16 @@
---
-- name: create vlans
+# - name: configure vlans
+# dellos6_config:
+# src: vlans.j2
+# replace: block
+# notify: save configuration
+
+- pause:
+ prompt: "\n\n{{ lookup('template', 'interfaces.j2') }}\n\n"
+ delegate_to: localhost
+
+- name: configure interfaces
dellos6_config:
- src: vlan.j2
+ src: interfaces.j2
+ replace: block
notify: save configuration
- register: vlan_result
diff --git a/roles/dellos6/layer2/templates/interfaces.j2 b/roles/dellos6/layer2/templates/interfaces.j2
new file mode 100644
index 00000000..28ec1341
--- /dev/null
+++ b/roles/dellos6/layer2/templates/interfaces.j2
@@ -0,0 +1,34 @@
+{% for interface in dellos6_interfaces %}
+interface {{ interface.spec }}
+{% if 'description' in interface %}
+description "{{ interface.description }}"
+{% endif %}
+{% if 'channel_group' in interface %}
+channel-group {{ interface.channel_group }} mode active
+{% endif %}
+switchport mode {{ interface.switchport_mode | default('access') }}
+{% if 'switchport_mode' not in interface or interface.switchport_mode == 'access' %}
+{% if 'vlan' in interface %}
+switchport access vlan {{ interface.vlan }}
+{% endif %}
+{% elif interface.switchport_mode == 'trunk' %}
+{% if 'pvid' in interface %}
+switchport trunk native vlan {{ interface.pvid }}
+{% endif %}
+{% elif interface.switchport_mode == 'general' %}
+{% if 'tagged_only' in interface and interface.tagged_only %}
+switchport general acceptable-frame-type tagged-only
+{% endif %}
+{% if 'ingress_filtering' in interface and not interface.ingress_filtering %}
+switchport general ingress-filtering disable
+{% endif %}
+{% if 'forbidden_vlans' in interface %}
+switchport general forbidden vlan add {{ interface.forbidden_vlans | join(',') }}
+{% endif %}
+switchport general allowed vlan add {{ interface.allowed_vlans | join(',') }}
+{% if 'pvid' in interface %}
+switchport general pvid {{ interface.pvid }}
+{% endif %}
+{% endif %}
+exit
+{% endfor %}
diff --git a/roles/dellos6/layer2/templates/vlan.j2 b/roles/dellos6/layer2/templates/vlans.j2
index 6403c735..6403c735 100644
--- a/roles/dellos6/layer2/templates/vlan.j2
+++ b/roles/dellos6/layer2/templates/vlans.j2