summaryrefslogtreecommitdiff
path: root/openstack/usr/share/openstack/network.yml
blob: 955a617bfea2d3514f56ac7aeb51b2fe45cb4f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
- hosts: localhost
  vars_files:
  - /etc/openstack/network.conf
  tasks:
# Create the bridges to use the External network mapped
# This configuration is for 1 node and it was taken from:
# https://fosskb.wordpress.com/2014/10/18/openstack-juno-on-ubuntu-14-10/
# and https://fosskb.wordpress.com/2014/06/10/managing-openstack-internaldataexternal-network-in-one-interface/

# Count number of network interfaces (interfaces starting with 'e')
  - shell: ls /sys/class/net | grep ^e.* | wc -l
    register: number_interfaces

# Abort if there number of interfaces != 1
  - fail:
        msg: More than one, or none network interfaces found.
    when: EXTERNAL_INTERFACE is not defined and number_interfaces.stdout != "1"

  - shell: ls /sys/class/net | grep ^e.*
    register: interface_name
    when: EXTERNAL_INTERFACE is not defined

  - set_fact:
        ETH_INTERFACE: "{{ interface_name.stdout }}"
    when: EXTERNAL_INTERFACE is not defined

  - set_fact:
        ETH_INTERFACE: "{{ EXTERNAL_INTERFACE }}"
    when: EXTERNAL_INTERFACE is defined

  - set_fact:
        ETH_MAC_ADDRESS: "{{ hostvars['localhost']['ansible_' + ETH_INTERFACE]['macaddress'] }}"

  - name: Create the /run/systemd/network
    file:
        path: /run/systemd/network
        state: directory

  - name: Disable dhcp on the bound physical interface
    template:
        src: /usr/share/openstack/extras/00-disable-device.network
        dest: /run/systemd/network/00-disable-{{ item }}-config.network
    with_items:
    - "{{ ETH_INTERFACE }}"


  - name: Disable dhcp on all the internal interfaces
    template:
        src: /usr/share/openstack/extras/00-disable-device.network
        dest: /run/systemd/network/00-disable-{{ item }}-config.network
    with_items:
    - br-eth1
    - br-ex
    - eth1-br-proxy
    - proxy-br-eth1
    - proxy-br-ex
    - ovs-system

#ovs-vsctl \
#    -- add-br br-eth0 \
#    -- add-port br-eth0 $eth_dev \
#    -- set bridge br-eth0 other-config:hwaddr=$eth_mac
#


  - openvswitch_bridge:
        bridge: br-eth0
        state: present

  - openvswitch_port:
        bridge: br-eth0
        port: "{{ ETH_INTERFACE }}"
        state: present

  - shell: ovs-vsctl set bridge br-eth0 other-config:hwaddr={{ ETH_MAC_ADDRESS }}

  - name: Enable dhcp on the Open vSwitch device that replaces our external interface
    template:
        src: /usr/share/openstack/extras/10-device-dhcp.network
        dest: /run/systemd/network/10-{{ item }}-dhcp.network
    with_items:
    - br-eth0

#ovs-vsctl \
#    -- add-br br-eth1 \
#    -- add-port br-eth1 eth1-br-proxy \
#    -- set interface eth1-br-proxy type=patch options:peer=proxy-br-eth1 \
#    -- add-port br-eth0 proxy-br-eth1 \
#    -- set interface proxy-br-eth1 type=patch options:peer=eth1-br-proxy \
#    -- add-br br-ex \
#    -- add-port br-ex ex-br-proxy \
#    -- set interface ex-br-proxy type=patch options:peer=proxy-br-ex \
#    -- add-port br-eth0 proxy-br-ex \
#    -- set interface proxy-br-ex type=patch options:peer=ex-br-proxy


  - openvswitch_bridge:
        bridge: br-eth1
        state: present
  - openvswitch_port:
        bridge: br-eth1
        port: eth1-br-proxy
        state: present
  - shell: ovs-vsctl set interface eth1-br-proxy type=patch options:peer=proxy-br-eth1
  - openvswitch_port:
        bridge: br-eth0
        port: proxy-br-eth1
        state: present
  - shell: ovs-vsctl set interface proxy-br-eth1 type=patch options:peer=eth1-br-proxy
  - openvswitch_bridge:
        bridge: br-ex
        state: present
  - openvswitch_port:
        bridge: br-ex
        port: ex-br-proxy
        state: present
  - shell: ovs-vsctl set interface ex-br-proxy type=patch options:peer=proxy-br-ex
  - openvswitch_port:
        bridge: br-eth0
        port: proxy-br-ex
        state: present
  - shell: ovs-vsctl set interface proxy-br-ex type=patch options:peer=ex-br-proxy