Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 1 | --- |
Matteo Scandolo | 3896c47 | 2017-08-01 13:31:42 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 16 | # interface-config/tasks/main.yml |
| 17 | |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 18 | - name: Install bridging/bonding utilities |
| 19 | apt: |
| 20 | name: "{{ item }}" |
| 21 | update_cache: yes |
| 22 | cache_valid_time: 3600 |
| 23 | with_items: |
| 24 | - bridge-utils |
| 25 | - ifenslave |
| 26 | - iptables-persistent |
| 27 | |
| 28 | - name: Create management network interfaces |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 29 | template: |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 30 | src: management.cfg.j2 |
| 31 | dest: "/etc/network/interfaces.d/management.cfg" |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 32 | owner: root |
| 33 | group: root |
| 34 | mode: 0644 |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 35 | register: management_net_config |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 36 | |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 37 | - name: Bring up management network interfaces, if reconfigured |
| 38 | when: management_net_config.changed |
| 39 | command: "ifup {{ item }}" |
| 40 | with_flattened: |
| 41 | - mgmtbridge |
| 42 | - mgmtbond |
| 43 | - "{{ management_net_interfaces }}" |
| 44 | - vethmgmt0 |
| 45 | tags: |
| 46 | - skip_ansible_lint # needs to be run before next steps |
| 47 | |
| 48 | # NAT/forward management network traffic out the head node |
| 49 | - name: Default to accept forwarded traffic |
| 50 | when: "'head' in group_names and management_net_config.changed" |
| 51 | iptables: |
| 52 | chain: FORWARD |
| 53 | policy: ACCEPT |
| 54 | notify: |
| 55 | - iptables-save |
| 56 | tags: |
| 57 | - skip_ansible_lint # need to save config in following steps |
| 58 | |
| 59 | - name: Configure forwarding for management bridge |
| 60 | when: "'head' in group_names and management_net_config.changed" |
| 61 | iptables: |
| 62 | chain: FORWARD |
| 63 | in_interface: mgmtbridge |
| 64 | jump: ACCEPT |
| 65 | notify: |
| 66 | - iptables-save |
| 67 | tags: |
| 68 | - skip_ansible_lint # need to save config in following steps |
| 69 | |
| 70 | - name: Configure NAT for management network |
| 71 | when: "'head' in group_names and management_net_config.changed" |
| 72 | iptables: |
| 73 | table: nat |
| 74 | chain: POSTROUTING |
| 75 | out_interface: "{{ headnode_nat_interface }}" |
| 76 | jump: MASQUERADE |
| 77 | notify: |
| 78 | - iptables-save |
| 79 | tags: |
| 80 | - skip_ansible_lint # need to save config in following steps |
| 81 | |
| 82 | # Create fabric bridge and veth pair |
| 83 | - name: Create fabric network interfaces on compute nodes |
| 84 | template: |
| 85 | src: fabric.cfg.j2 |
| 86 | dest: "/etc/network/interfaces.d/fabric.cfg" |
| 87 | owner: root |
| 88 | group: root |
| 89 | mode: 0644 |
| 90 | register: compute_fabric_config |
| 91 | |
| 92 | - name: Bring up fabric interfaces, if reconfigured |
| 93 | when: compute_fabric_config.changed |
| 94 | command: "ifup {{ item }}" |
| 95 | with_flattened: |
| 96 | - fabricbridge |
| 97 | - fabricbond |
| 98 | - "{{ fabric_net_interfaces }}" |
| 99 | - vethfabric0 |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 100 | tags: |
| 101 | - skip_ansible_lint # needs to be run before next steps |
| 102 | |