Zack Williams | 0e58312 | 2016-04-30 16:57:03 -0700 | [diff] [blame] | 1 | --- |
| 2 | - hosts: nova-compute-1 |
| 3 | remote_user: ubuntu |
| 4 | become: yes |
| 5 | |
| 6 | tasks: |
| 7 | - name: Include configuration vars |
| 8 | include_vars: simulate-fabric-vars.yml |
| 9 | |
| 10 | - name: Install prerequisites |
| 11 | apt: |
| 12 | name={{ item }} |
| 13 | update_cache=yes |
| 14 | cache_valid_time=3600 |
| 15 | become: yes |
| 16 | with_items: |
| 17 | - bridge-utils |
| 18 | |
| 19 | - name: Create bridges |
Zack Williams | 5af9191 | 2016-05-01 06:34:16 -0700 | [diff] [blame] | 20 | when: "ansible_{{ item.name }} is not defined" |
Zack Williams | 0e58312 | 2016-04-30 16:57:03 -0700 | [diff] [blame] | 21 | command: brctl addbr "{{ item.name }}" |
| 22 | with_items: "{{ simfabric_bridges }}" |
| 23 | |
Zack Williams | c11aea5 | 2016-05-01 21:34:37 -0700 | [diff] [blame] | 24 | - name: Set IP addresses to bridges |
| 25 | when: "ansible_{{ item.0.name }} is not defined" |
| 26 | command: "ip addr add {{ item.1 }} dev {{ item.0.name }}" |
| 27 | with_subelements: |
| 28 | - "{{ simfabric_bridges }}" |
| 29 | - addresses |
| 30 | |
| 31 | - name: Start bridges |
Zack Williams | 6cc132e | 2016-05-02 13:44:23 -0700 | [diff] [blame^] | 32 | when: "ansible_{{ item.name }} is not defined and not ansible_{{ item.name }}.active" |
Zack Williams | b994a9e | 2016-05-01 22:21:06 -0700 | [diff] [blame] | 33 | command: "ip link set dev {{ item.name }} up" |
Zack Williams | c11aea5 | 2016-05-01 21:34:37 -0700 | [diff] [blame] | 34 | with_items: "{{ simfabric_bridges }}" |
| 35 | |
| 36 | - name: Create ip links |
| 37 | when: "ansible_{{ item.name }}0 is not defined" |
| 38 | command: "ip link add address {{ item.mac }} type {{ item.name }}" |
| 39 | with_items: "{{ simfabric_links }}" |
| 40 | |
| 41 | - name: Start interfaces |
Zack Williams | 6cc132e | 2016-05-02 13:44:23 -0700 | [diff] [blame^] | 42 | when: "ansible_{{ item }}.defined is not defined and not ansible_{{ item }}.active" |
Zack Williams | c11aea5 | 2016-05-01 21:34:37 -0700 | [diff] [blame] | 43 | command: "ip link set dev {{ item }} up" |
| 44 | with_items: "{{ simfabric_interfaces }}" |
| 45 | |
| 46 | - name: Add interfaces to bridges |
Zack Williams | b994a9e | 2016-05-01 22:21:06 -0700 | [diff] [blame] | 47 | when: "ansible_{{ item.0.name }}.interfaces is not defined" |
Zack Williams | c11aea5 | 2016-05-01 21:34:37 -0700 | [diff] [blame] | 48 | command: "brctl addif {{ item.0.name }} {{ item.1 }}" |
| 49 | with_subelements: |
| 50 | - "{{ simfabric_bridges }}" |
| 51 | - interfaces |
| 52 | |
| 53 | - name: Configure iptables |
Zack Williams | b994a9e | 2016-05-01 22:21:06 -0700 | [diff] [blame] | 54 | iptables: "table={{ item.table }} chain={{ item.chain }} source={{ item.source }} destination={{ item.dest }} jump={{ item.jump }}" |
Zack Williams | c11aea5 | 2016-05-01 21:34:37 -0700 | [diff] [blame] | 55 | with_items: "{{ simfabric_iptables }}" |
| 56 | |
| 57 | - name: Set kernel sysctl values |
| 58 | sysctl: |
| 59 | name="{{ item.name }}" |
| 60 | value="{{ item.value }}" |
| 61 | sysctl_set=yes |
| 62 | state=present |
| 63 | reload=yes |
| 64 | with_items: "{{ simfabric_sysctl }}" |
| 65 | |