From 02982f4b664231798ece829b8cb120932e9f99b9 Mon Sep 17 00:00:00 2001 From: Sergey Bubnov Date: Tue, 4 Jun 2019 20:39:17 +0400 Subject: [PATCH] configure pbr after alterator`s commit --- roles/common/tasks/configure_nics.yml | 25 ------------------------- roles/common/tasks/configure_pbr.yml | 25 +++++++++++++++++++++++++ roles/common/tasks/main.yml | 6 ++++++ 3 files changed, 31 insertions(+), 25 deletions(-) create mode 100644 roles/common/tasks/configure_pbr.yml diff --git a/roles/common/tasks/configure_nics.yml b/roles/common/tasks/configure_nics.yml index f148dd5..b03f08f 100644 --- a/roles/common/tasks/configure_nics.yml +++ b/roles/common/tasks/configure_nics.yml @@ -28,28 +28,3 @@ notify: restart network with_items: "{{nic.value.ipv4}}" when: nic.value.ipv4 is defined - -- name: "enable PBR for {{nic.key}}" - block: - - name: Generate sequance - 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' diff --git a/roles/common/tasks/configure_pbr.yml b/roles/common/tasks/configure_pbr.yml new file mode 100644 index 0000000..9ebfc9f --- /dev/null +++ b/roles/common/tasks/configure_pbr.yml @@ -0,0 +1,25 @@ +--- +- name: "enable PBR for {{nic.key}}" + block: + - name: Generate sequance + 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' diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 63867ed..e4becb3 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -104,6 +104,12 @@ async: 100 poll: 0 +- name: configure PBR + include_tasks: configure_pbr.yml + with_dict: "{{node.net}}" + loop_control: + loop_var: nic + - name: update .tmp/ssh_config after NICs reconfiguration include_role: name="inventory"