diff --git a/playbooks/iproute2.yml b/playbooks/iproute2.yml new file mode 100755 index 0000000..4e918a5 --- /dev/null +++ b/playbooks/iproute2.yml @@ -0,0 +1,17 @@ +#!/usr/bin/env ansible-playbook +--- +- hosts: + - edge-1.back.infra.auro.re + - edge-2.back.infra.auro.re + - isp-1.back.infra.auro.re + - isp-2.back.infra.auro.re + - infra-1.back.infra.auro.re + - infra-2.back.infra.auro.re + - vpn-1.back.infra.auro.re + - vpn-2.back.infra.auro.re + vars: + iproute2__custom_tables: + bird: 100 + roles: + - iproute2 +... diff --git a/roles/iproute2/defaults/main.yml b/roles/iproute2/defaults/main.yml new file mode 100644 index 0000000..d5965eb --- /dev/null +++ b/roles/iproute2/defaults/main.yml @@ -0,0 +1,8 @@ +--- +iproute2__default_tables: + local: 255 + main: 254 + default: 253 + unspec: 0 +iproute2__custom_tables: {} +... diff --git a/roles/iproute2/tasks/main.yml b/roles/iproute2/tasks/main.yml new file mode 100644 index 0000000..2dd3832 --- /dev/null +++ b/roles/iproute2/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- name: Ensure that default and custom tables names don't overlap + assert: + that: "not (iproute2__default_tables.keys() + | intersect(iproute2__custom_tables.keys()))" + +- name: Configure rt_tables + template: + src: rt_tables.j2 + dest: /etc/iproute2/rt_tables + owner: root + group: root + mode: u=rw,g=r,o=r + vars: + iproute2__tables: "{{ iproute2__default_tables + | combine(iproute2__custom_tables) }}" +... diff --git a/roles/iproute2/templates/rt_tables.j2 b/roles/iproute2/templates/rt_tables.j2 new file mode 100644 index 0000000..441314f --- /dev/null +++ b/roles/iproute2/templates/rt_tables.j2 @@ -0,0 +1,5 @@ +{{ ansible_managed | comment }} + +{% for name, id in iproute2__tables.items() %} +{{ id }} {{ name }} +{% endfor %}