infra/roles/common/tasks/configure_pbr.yml
2019-06-05 11:10:05 +04:00

26 lines
758 B
YAML

---
- name: "enable PBR for {{nic.key}}"
block:
- name: Generate sequence
set_fact:
tbl_id: nic.key | regex_replace('^eth(d+)', '\\1'
- name: add table
lineinfile:
path: /etc/iproute2/rt_tables
line: "{{ (tbl_id | int) + 200 }} tbl_{{nic.key}}"
notify: restart network
- name: "create config for {{nic.key}}"
file:
path: "/etc/net/ifaces/{{nic.key}}"
state: directory
- name: define routing rules
template:
src: pbr_config.j2
dest: "/etc/net/ifaces/{{nic.key}}/ifup-post"
mode: '0755'
with_items: "{{nic.value.ipv4}}"
notify: restart network
when: nic.value.ipv4 is defined and nic.value.default is defined
when: node.net | length > 1 and nic.value.descr == 'priv'