Add staticd configuration
This change makes possible to configure staticd routes with both integrated and standalone configuration types. Change-Id: I7d0e652748e3e88c08fc5249fd3fe6535cb4c65e
This commit is contained in:
parent
c706aedb95
commit
59270dd41a
@ -26,3 +26,6 @@
|
|||||||
# up: route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1
|
# up: route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1
|
||||||
# down: route del -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1
|
# down: route del -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1
|
||||||
frr_vlans: []
|
frr_vlans: []
|
||||||
|
|
||||||
|
frr_integrated_config_path: /etc/frr/frr.conf
|
||||||
|
frr_staticd_routes: []
|
||||||
|
35
tasks/frr_post_install.yml
Normal file
35
tasks/frr_post_install.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2020, VEXXHOST, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- name: Configure frr
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
block:
|
||||||
|
- name: Enable integrated config
|
||||||
|
lineinfile:
|
||||||
|
create: yes
|
||||||
|
path: /etc/frr/vtysh.conf
|
||||||
|
regexp: '^(no)?\s?service integrated-vtysh-config$'
|
||||||
|
line: "service integrated-vtysh-config"
|
||||||
|
notify: Restart frr
|
||||||
|
|
||||||
|
- name: Write down integrated config
|
||||||
|
template:
|
||||||
|
src: frr.conf.j2
|
||||||
|
dest: "{{ frr_integrated_config_path }}"
|
||||||
|
owner: frr
|
||||||
|
group: frr
|
||||||
|
mode: "0640"
|
||||||
|
notify: Restart frr
|
@ -22,3 +22,6 @@
|
|||||||
|
|
||||||
- name: Install frr
|
- name: Install frr
|
||||||
include_tasks: frr_install.yml
|
include_tasks: frr_install.yml
|
||||||
|
|
||||||
|
- name: Service configuration
|
||||||
|
include_tasks: frr_post_install.yml
|
||||||
|
13
templates/frr.conf.j2
Normal file
13
templates/frr.conf.j2
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
!
|
||||||
|
! Zebra configuration
|
||||||
|
!
|
||||||
|
frr defaults traditional
|
||||||
|
!
|
||||||
|
hostname {{ ansible_hostname }}
|
||||||
|
log syslog informational
|
||||||
|
!
|
||||||
|
! staticd config
|
||||||
|
{{ frr_staticd_routes | join('\n') }}
|
||||||
|
!
|
||||||
|
line vty
|
||||||
|
!
|
@ -17,13 +17,14 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
vars_files:
|
vars_files:
|
||||||
- test_vars.yml
|
- test_vars.yml
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- frrouting
|
- frrouting
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: wait after service restart
|
- name: wait after service restart
|
||||||
pause:
|
pause:
|
||||||
seconds: 30
|
seconds: 10
|
||||||
|
|
||||||
- name: Ping vlans ip address
|
- name: Ping vlans ip address
|
||||||
shell: |
|
shell: |
|
||||||
@ -43,3 +44,16 @@
|
|||||||
fail:
|
fail:
|
||||||
msg: frr is not up
|
msg: frr is not up
|
||||||
when: ansible_facts.services['frr'].state != 'running'
|
when: ansible_facts.services['frr'].state != 'running'
|
||||||
|
|
||||||
|
- name: Get static routes
|
||||||
|
become: true
|
||||||
|
become_user: root
|
||||||
|
command: "vtysh -c 'show ip route'"
|
||||||
|
register: _frr_get_routes
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Fail if we're missing routes
|
||||||
|
fail:
|
||||||
|
msg: "We can't find route {{ item }}"
|
||||||
|
with_items: "{{ frr_staticd_routes }}"
|
||||||
|
when: item.split(' ')[-1] not in _frr_get_routes.stdout
|
||||||
|
@ -20,3 +20,6 @@ frr_vlans:
|
|||||||
netmask: 255.255.255.0
|
netmask: 255.255.255.0
|
||||||
network: 192.168.1.0
|
network: 192.168.1.0
|
||||||
broadcast: 192.168.1.255
|
broadcast: 192.168.1.255
|
||||||
|
|
||||||
|
frr_staticd_routes:
|
||||||
|
- ip route 10.0.0.0/24 192.168.1.10
|
||||||
|
Loading…
x
Reference in New Issue
Block a user