Page MenuHomeDevCentral

D4093.id10741.diff
No OneTemporary

D4093.id10741.diff

diff --git a/roles/router/frrouting/config.sls b/pillar/core/frr.sls
rename from roles/router/frrouting/config.sls
rename to pillar/core/frr.sls
--- a/roles/router/frrouting/config.sls
+++ b/pillar/core/frr.sls
@@ -1,6 +1,17 @@
# -------------------------------------------------------------
-# Salt — Router — FRRouting
+# Pillar — FRRouting — Router/DevServer
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
+
+frrouting:
+ router_ids:
+ router-002: 2.2.2.2
+ router-003: 3.3.3.3
+ ysul: 4.4.4.4
+ windriver: 5.5.5.5
+ docker-002: 6.6.6.6
+ complector: 7.7.7.7
+ db-a-001: 8.8.8.8
+ db-b-001: 9.9.9.9
diff --git a/pillar/top.sls b/pillar/top.sls
--- a/pillar/top.sls
+++ b/pillar/top.sls
@@ -11,6 +11,7 @@
- core.groups
- core.network
- core.ntp
+ - core.frr
- nodes.nodes
- nodes.forests
- hotfixes.roles
diff --git a/roles/core/frrouting/config.sls b/roles/core/frrouting/config.sls
new file mode 100644
--- /dev/null
+++ b/roles/core/frrouting/config.sls
@@ -0,0 +1,26 @@
+# -------------------------------------------------------------
+# Salt — Configuration FRRouting
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs with context %}
+
+{% set router_ids = salt['pillar.get']('frrouting:router_ids', {}) %}
+{% set roles = salt['grains.get']('roles', []) %}
+
+{% if 'router' not in roles and 'devserver' not in roles %}
+
+{{ dirs.etc }}/frr/frr.conf:
+ file.managed:
+ - source: salt://roles/core/frrouting/files/frr.conf
+ - template: jinja
+ - user: frr
+ - group: frr
+ - mode: 644
+ - context:
+ hostname: {{ grains['id'] }}
+ router_id: {{ router_ids.get(grains['id']) }}
+
+{% endif %}
diff --git a/roles/core/frrouting/files/frr.conf b/roles/core/frrouting/files/frr.conf
new file mode 100644
--- /dev/null
+++ b/roles/core/frrouting/files/frr.conf
@@ -0,0 +1,35 @@
+# -------------------------------------------------------------
+# Network — FRRouting OSPF configuration
+# excluding routers and devservers.
+#
+# Note: this state does not currently match all nodes correctly,
+# as the Intranought interface is not always vmx0 and some nodes
+# do not have an Intranought default route.
+#
+# A more reliable way to detect or define the OSPF interface is needed.
+# Affected nodes include: docker-002, dwellers, dns-001.
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+!
+frr version 10.6.1
+frr defaults traditional
+hostname {{ hostname }}
+service integrated-vtysh-config
+!
+interface vmx0
+ ip ospf area 0.0.0.0
+ no ip ospf passive
+exit
+!
+router ospf
+ ospf router-id {{ router_id }}
+ passive-interface default
+exit
+!
diff --git a/roles/router/frrouting/files/frr.rc b/roles/core/frrouting/files/frr.rc
rename from roles/router/frrouting/files/frr.rc
rename to roles/core/frrouting/files/frr.rc
--- a/roles/router/frrouting/files/frr.rc
+++ b/roles/core/frrouting/files/frr.rc
@@ -3,7 +3,7 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
-# Source file: roles/router/carp/files/frr.rc
+# Source file: roles/core/frrouting/files/frr.rc
# -------------------------------------------------------------
#
# <auto-generated>
diff --git a/roles/router/frrouting/init.sls b/roles/core/frrouting/init.sls
copy from roles/router/frrouting/init.sls
copy to roles/core/frrouting/init.sls
diff --git a/roles/router/frrouting/service.sls b/roles/core/frrouting/service.sls
rename from roles/router/frrouting/service.sls
rename to roles/core/frrouting/service.sls
--- a/roles/router/frrouting/service.sls
+++ b/roles/core/frrouting/service.sls
@@ -1,5 +1,5 @@
# -------------------------------------------------------------
-# Salt — Router — FRRouting
+# Salt — FRRouting
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
@@ -11,7 +11,9 @@
/etc/rc.conf.d/frr:
file.managed:
- - source: salt://roles/router/frrouting/files/frr.rc
+ - source: salt://roles/core/frrouting/files/frr.rc
- mode: 644
{% endif %}
+
+## need to add for linux machine : dwellers and docker-002
diff --git a/roles/router/frrouting/software.sls b/roles/core/frrouting/software.sls
rename from roles/router/frrouting/software.sls
rename to roles/core/frrouting/software.sls
--- a/roles/router/frrouting/software.sls
+++ b/roles/core/frrouting/software.sls
@@ -1,5 +1,5 @@
# -------------------------------------------------------------
-# Salt — Router — FRRouting
+# Salt — FRRouting
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
diff --git a/roles/core/init.sls b/roles/core/init.sls
--- a/roles/core/init.sls
+++ b/roles/core/init.sls
@@ -7,6 +7,7 @@
include:
- .rc
+ - .frrouting
- .hostname
- .login
- .network
diff --git a/roles/router/frrouting/files/frr.rc b/roles/devserver/frrouting/files/frr.conf
rename from roles/router/frrouting/files/frr.rc
rename to roles/devserver/frrouting/files/frr.conf
--- a/roles/router/frrouting/files/frr.rc
+++ b/roles/devserver/frrouting/files/frr.conf
@@ -1,9 +1,9 @@
# -------------------------------------------------------------
-# Network — Activate FRRouting with OSPF
+# Network — Configuration FRRouting with OSPF for DevServer
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
-# Source file: roles/router/carp/files/frr.rc
+# Source file: roles/devserver/frrouting/files/frr.conf
# -------------------------------------------------------------
#
# <auto-generated>
@@ -13,5 +13,20 @@
# and will be lost if the state is redeployed.
# </auto-generated>
-frr_enable="YES"
-frr_daemons="zebra ospfd"
+!
+frr version 10.6.0
+frr defaults traditional
+hostname {{ hostname }}
+service integrated-vtysh-config
+!
+interface gre1
+ ip ospf area 0.0.0.0
+ ip ospf network point-to-point
+ no ip ospf passive
+exit
+!
+router ospf
+ ospf router-id {{ router_id }}
+ passive-interface default
+exit
+!
diff --git a/roles/devserver/frrouting/init.sls b/roles/devserver/frrouting/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/devserver/frrouting/init.sls
@@ -0,0 +1,21 @@
+# -------------------------------------------------------------
+# Salt — DevServer — FRRouting configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% from "map.jinja" import dirs with context %}
+
+{% set router_ids = salt['pillar.get']('frrouting:router_ids', {}) %}
+
+{{ dirs.etc }}/frr/frr.conf:
+ file.managed:
+ - source: salt://roles/devserver/frrouting/files/frr.conf
+ - template: jinja
+ - user: frr
+ - group: frr
+ - mode: 644
+ - context:
+ hostname: {{ grains['id'] }}
+ router_id: {{ router_ids.get(grains['id']) }}
diff --git a/roles/devserver/init.sls b/roles/devserver/init.sls
--- a/roles/devserver/init.sls
+++ b/roles/devserver/init.sls
@@ -9,6 +9,7 @@
- .datacube
- .dns
- .mail
+ - .frrouting
- .pkg
- .userland-software
- .userland-home
diff --git a/roles/router/frrouting/files/frr.conf b/roles/router/frrouting/files/frr.conf
new file mode 100644
--- /dev/null
+++ b/roles/router/frrouting/files/frr.conf
@@ -0,0 +1,43 @@
+# -------------------------------------------------------------
+# Network — Configuration FRRouting with OSPF for Router
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/router/frrouting/files/frr.conf
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+!
+frr version 10.6.0
+frr defaults traditional
+hostname {{ hostname }}
+service integrated-vtysh-config
+!
+interface gre1
+ ip ospf area 0.0.0.0
+ ip ospf network point-to-point
+ no ip ospf passive
+exit
+!
+interface gre2
+ ip ospf area 0.0.0.0
+ ip ospf network point-to-point
+ no ip ospf passive
+exit
+!
+interface vmx0
+ ip ospf area 0.0.0.0
+ no ip ospf passive
+exit
+!
+router ospf
+ ospf router-id {{ router_id }}
+ passive-interface default
+exit
+!
diff --git a/roles/router/frrouting/files/set-ospf-default-route.sh b/roles/router/frrouting/files/set-ospf-default-route.sh
new file mode 100644
--- /dev/null
+++ b/roles/router/frrouting/files/set-ospf-default-route.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Network — Configure OSPF default route advertisement according to CARP state
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/router/frrouting/files/set-ospf-default-route.sh
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+
+# -------------------------------------------------------------
+# Configuration
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+set -eu
+
+PRIMARY_ROUTER="$1"
+
+HOST="$(hostname -s)"
+
+# this file log is for test : later will be a log file /var/log/set-ospf.log with tag set-ospf
+LOG="/tmp/set-ospf.log"
+
+
+# -------------------------------------------------------------
+# Helper functions
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+log() {
+ echo "$(date '+%Y-%m-%d %H:%M:%S') [set-ospf] $1" | tee -a "$LOG"
+}
+
+
+# -------------------------------------------------------------
+# Entry point
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+if [ "$HOST" = "$PRIMARY_ROUTER" ]; then
+ log "$HOST is PRIMARY ROUTER -> announce default route"
+
+ vtysh <<EOF
+configure terminal
+router ospf
+ no distance ospf external 255
+ default-information originate always
+end
+write
+EOF
+
+else
+ log "$HOST is BACKUP -> do not advertise or install default route"
+
+ vtysh <<EOF
+configure terminal
+router ospf
+ no default-information originate always
+ distance ospf external 255
+end
+write
+EOF
+
+fi
+
+log "Set Ospf Default Route Done"
diff --git a/roles/router/frrouting/init.sls b/roles/router/frrouting/init.sls
--- a/roles/router/frrouting/init.sls
+++ b/roles/router/frrouting/init.sls
@@ -1,12 +1,27 @@
# -------------------------------------------------------------
-# Salt — Deploy FRRouting
+# Salt — Router — FRRouting configuration
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
-# Created: 2017-01-25
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
-include:
- - .software
- - .config
- - .service
+{% from "map.jinja" import dirs with context %}
+
+{% set router_ids = salt['pillar.get']('frrouting:router_ids', {}) %}
+
+{{ dirs.etc }}/frr/frr.conf:
+ file.managed:
+ - source: salt://roles/router/frrouting/files/frr.conf
+ - template: jinja
+ - user: frr
+ - group: frr
+ - mode: 644
+ - context:
+ hostname: {{ grains['id'] }}
+ router_id: {{ router_ids.get(grains['id']) }}
+
+{{ dirs.libexec }}/frr/set-ospf-default-route:
+ file.managed:
+ - source: salt://roles/router/frrouting/files/set-ospf-default-route.sh
+ - makedirs: True
+ - mode: 755

File Metadata

Mime Type
text/plain
Expires
Mon, May 11, 13:30 (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3708028
Default Alt Text
D4093.id10741.diff (12 KB)

Event Timeline