Page MenuHomeDevCentral

D4093.id10746.diff
No OneTemporary

D4093.id10746.diff

diff --git a/pillar/core/frr.sls b/pillar/core/frr.sls
new file mode 100644
--- /dev/null
+++ b/pillar/core/frr.sls
@@ -0,0 +1,19 @@
+# -------------------------------------------------------------
+# 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
+ hervil: 10.10.10.10
+ web-001: 11.11.11.11
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
copy from roles/router/frrouting/files/frr.rc
copy 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/config.sls b/roles/router/frrouting/config.sls
--- a/roles/router/frrouting/config.sls
+++ b/roles/router/frrouting/config.sls
@@ -1,6 +1,27 @@
# -------------------------------------------------------------
-# Salt — Router — FRRouting
+# Salt — Router — 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/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
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/frr.rc b/roles/router/frrouting/files/newsyslog.conf
copy from roles/router/frrouting/files/frr.rc
copy to roles/router/frrouting/files/newsyslog.conf
--- a/roles/router/frrouting/files/frr.rc
+++ b/roles/router/frrouting/files/newsyslog.conf
@@ -1,9 +1,9 @@
# -------------------------------------------------------------
-# Network — Activate FRRouting with OSPF
+# Network — OSPF newsyslog
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
-# Source file: roles/router/carp/files/frr.rc
+# Source file: roles/router/frrouting/files/newsyslog.conf
# -------------------------------------------------------------
#
# <auto-generated>
@@ -13,5 +13,4 @@
# and will be lost if the state is redeployed.
# </auto-generated>
-frr_enable="YES"
-frr_daemons="zebra ospfd"
+/var/log/set-ospf.log root:wheel 644 7 1000 * JC
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,84 @@
+#!/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)"
+
+
+# -------------------------------------------------------------
+# Helper functions
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+# -----------------------------------------------------------------------------
+# Function: log
+# Description: Send a message to syslog.
+#
+# The logs are sent to syslog /var/log/set-ospf.log using the "set-ospf" tag.
+#
+# Parameters:
+# $* Message to log
+#
+# Returns:
+# 0
+# -----------------------------------------------------------------------------
+log() {
+ logger -t set-ospf -- "$*"
+}
+
+
+# -------------------------------------------------------------
+# 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/files/frr.rc b/roles/router/frrouting/files/syslog.conf
rename from roles/router/frrouting/files/frr.rc
rename to roles/router/frrouting/files/syslog.conf
--- a/roles/router/frrouting/files/frr.rc
+++ b/roles/router/frrouting/files/syslog.conf
@@ -1,9 +1,9 @@
# -------------------------------------------------------------
-# Network — Activate FRRouting with OSPF
+# Network — OSPF syslog
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# License: Trivial work, not eligible to copyright
-# Source file: roles/router/carp/files/frr.rc
+# Source file: roles/router/frrouting/files/syslog.conf
# -------------------------------------------------------------
#
# <auto-generated>
@@ -13,5 +13,6 @@
# and will be lost if the state is redeployed.
# </auto-generated>
-frr_enable="YES"
-frr_daemons="zebra ospfd"
+!set-ospf
+*.* /var/log/set-ospf.log
+!*
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
@@ -7,6 +7,5 @@
# -------------------------------------------------------------
include:
- - .software
- .config
- - .service
+ - .logging_set_ospf
diff --git a/roles/router/frrouting/logging_set_ospf.sls b/roles/router/frrouting/logging_set_ospf.sls
new file mode 100644
--- /dev/null
+++ b/roles/router/frrouting/logging_set_ospf.sls
@@ -0,0 +1,24 @@
+# -------------------------------------------------------------
+# Salt — Router — FRRouting logging
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+/usr/local/etc/syslog.d/set-ospf.conf:
+ file.managed:
+ - source: salt://roles/router/frrouting/files/syslog.conf
+ - makedirs: True
+ - mode: 644
+
+/etc/newsyslog.conf.d/set-ospf.conf:
+ file.managed:
+ - source: salt://roles/router/frrouting/files/newsyslog.conf
+ - mode: 644
+
+/etc/syslog.conf exclude set-ospf:
+ file.replace:
+ - name: /etc/syslog.conf
+ - pattern: '!-carp-ovh,gre-tunnels\n\*\.notice;authpriv\.none;kern\.debug;lpr\.info;mail\.crit;news\.err /var/log/messages\n!\*'
+ - repl: '!-carp-ovh,gre-tunnels,set-ospf\n*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages\n!*'
+ - backup: False

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
3708027
Default Alt Text
D4093.id10746.diff (16 KB)

Event Timeline