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: |
Zack Williams | b61ca26 | 2018-01-29 17:01:21 -0700 | [diff] [blame] | 41 | - "{{ management_net_bridge }}" |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 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 |
Zack Williams | 2f5f2bd | 2017-12-01 15:04:22 -0700 | [diff] [blame] | 90 | register: fabric_net_config |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 91 | |
Zack Williams | 2f5f2bd | 2017-12-01 15:04:22 -0700 | [diff] [blame] | 92 | - name: Bring up fabricbridge on head node |
| 93 | when: "'head' in group_names and fabric_net_config.changed" |
| 94 | command: "ifup fabricbridge" |
| 95 | tags: |
| 96 | - skip_ansible_lint # needs to be run before next steps |
| 97 | |
| 98 | - name: Bring up fabricbridge:0 on head node if using VSG addresspool |
| 99 | when: "'head' in group_names and fabric_net_config.changed and use_addresspool_vsg" |
| 100 | command: "ifup fabricbridge:0" |
| 101 | tags: |
| 102 | - skip_ansible_lint # no interface manip module in ansible |
| 103 | |
| 104 | - name: Bring up fabricbridge:1 on head node if using PUBLIC addresspool |
| 105 | when: "'head' in group_names and fabric_net_config.changed and use_addresspool_vsg" |
| 106 | command: "ifup fabricbridge:1" |
| 107 | tags: |
| 108 | - skip_ansible_lint # no interface manip module in ansible |
| 109 | |
| 110 | - name: Bring up common fabric interfaces, if reconfigured |
| 111 | when: fabric_net_config.changed |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 112 | command: "ifup {{ item }}" |
| 113 | with_flattened: |
Zack Williams | 6dc2d45 | 2017-12-20 17:50:49 -0700 | [diff] [blame] | 114 | - fabricbond |
| 115 | - "{{ fabric_net_interfaces }}" |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 116 | tags: |
| 117 | - skip_ansible_lint # needs to be run before next steps |
| 118 | |