From 0d705bc92283fe353f577cbf31b0c2d118b7a2fe Mon Sep 17 00:00:00 2001 From: Jeltz Date: Sat, 1 Jan 2022 21:45:08 +0100 Subject: [PATCH] Add bird role --- playbooks/{router.yml => router_old.yml} | 0 roles/bird/defaults/main.yml | 3 ++ roles/bird/handlers/main.yml | 11 +++++++ roles/bird/tasks/main.yml | 37 ++++++++++++++++++++++++ roles/bird/templates/bird.conf | 37 ++++++++++++++++++++++++ roles/bird/templates/bird6.conf | 37 ++++++++++++++++++++++++ 6 files changed, 125 insertions(+) rename playbooks/{router.yml => router_old.yml} (100%) create mode 100644 roles/bird/defaults/main.yml create mode 100644 roles/bird/handlers/main.yml create mode 100644 roles/bird/tasks/main.yml create mode 100644 roles/bird/templates/bird.conf create mode 100644 roles/bird/templates/bird6.conf diff --git a/playbooks/router.yml b/playbooks/router_old.yml similarity index 100% rename from playbooks/router.yml rename to playbooks/router_old.yml diff --git a/roles/bird/defaults/main.yml b/roles/bird/defaults/main.yml new file mode 100644 index 0000000..eca72f6 --- /dev/null +++ b/roles/bird/defaults/main.yml @@ -0,0 +1,3 @@ +--- +bird_ospf_interfaces: {} +... diff --git a/roles/bird/handlers/main.yml b/roles/bird/handlers/main.yml new file mode 100644 index 0000000..66a62cd --- /dev/null +++ b/roles/bird/handlers/main.yml @@ -0,0 +1,11 @@ +--- +- name: Reload bird + systemd: + name: bird.service + state: reloaded + +- name: Reload bird6 + systemd: + name: bird6.service + state: reloaded +... diff --git a/roles/bird/tasks/main.yml b/roles/bird/tasks/main.yml new file mode 100644 index 0000000..591fcc8 --- /dev/null +++ b/roles/bird/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: Install bird + apt: + name: bird + +- name: Configure bird + template: + src: bird.conf + dest: /etc/bird/bird.conf + owner: root + group: root + mode: u=rw,g=,o= + notify: + - Reload bird + +- name: Configure bird6 + template: + src: bird6.conf + dest: /etc/bird/bird6.conf + owner: root + group: root + mode: u=rw,g=,o= + notify: + - Reload bird6 + +- name: Enable and start bird + systemd: + name: bird.service + enabled: true + state: started + +- name: Enable and start bird6 + systemd: + name: bird6.service + enabled: true + state: started +... diff --git a/roles/bird/templates/bird.conf b/roles/bird/templates/bird.conf new file mode 100644 index 0000000..886dafb --- /dev/null +++ b/roles/bird/templates/bird.conf @@ -0,0 +1,37 @@ +{{ ansible_managed | comment }} + +log syslog all; + +router id {{ bird_router_id }}; + +protocol kernel { + scan time 60; + import none; + export all; + persist; +} + +protocol device { + scan time 60; +} + +protocol ospf backbone { + import filter { +{% if bird_ospf_src_v6 is defined %} + krt_prefsrc = {{ bird_ospf_src }}; +{% endif %} + accept; + }; + export all; + area 0 { +{% for name, iface in bird_ospf_interfaces.items() %} + interface "{{ name }}" { +{% if iface.stub | default(false) %} + stub; +{% elif iface.broadcast | default(false) %} + type broadcast; +{% endif %} + }; +{% endfor %} + }; +} diff --git a/roles/bird/templates/bird6.conf b/roles/bird/templates/bird6.conf new file mode 100644 index 0000000..ae121b7 --- /dev/null +++ b/roles/bird/templates/bird6.conf @@ -0,0 +1,37 @@ +{{ ansible_managed | comment }} + +log syslog all; + +router id {{ bird_router_id }}; + +protocol kernel { + scan time 60; + import none; + export all; + persist; +} + +protocol device { + scan time 60; +} + +protocol ospf backbone { + import filter { +{% if bird_ospf_src_v6 is defined %} + krt_prefsrc = {{ bird_ospf_src_v6 }}; +{% endif %} + accept; + }; + export all; + area 0 { +{% for name, iface in bird_ospf_interfaces.items() %} + interface "{{ name }}" { +{% if iface.stub | default(false) %} + stub; +{% elif iface.broadcast | default(false) %} + type broadcast; +{% endif %} + }; +{% endfor %} + }; +}