Allow network Alias addresses
For nova flat networking to work /w neutron we need to allow an alias address for some interfaces. This PR exposes a "alias:" option which is an address that will be added as an alias for the interface. For Debian this means an additional block at the bottom of the configuration file. For RedHat this means an <interface_name>:0 file is created. Change-Id: I39c396ce3b6eab321d5eb70645c1d0af71dcf5c6
This commit is contained in:
parent
e31607bea4
commit
7d8954032a
@ -54,6 +54,7 @@ To allow a more complicated network setup we can specify
|
||||
``netmask``: Netmask of the interface (defaults to 255.255.255.0)
|
||||
``name``: Name of the interface
|
||||
``veth_peer``: Set up a veth peer for the interface
|
||||
``alias``: Add an alias IP address
|
||||
|
||||
For example, a Nova setup may look like this:
|
||||
|
||||
@ -65,6 +66,7 @@ For example, a Nova setup may look like this:
|
||||
- name: "br-vxlan"
|
||||
ip_addr: "10.1.1.1"
|
||||
- name: "br-vlan"
|
||||
ip_addr: "10.1.2.1"
|
||||
ip_addr: "10.1.2.200"
|
||||
veth_peer: "eth12"
|
||||
alias: "10.1.2.1"
|
||||
|
||||
|
@ -19,3 +19,9 @@ iface {{ item.name | default('br-mgmt') }} inet static
|
||||
{% else %}
|
||||
bridge_ports none
|
||||
{% endif %}
|
||||
|
||||
{% if item.alias is defined %}
|
||||
iface {{ item.name | default('br-mgmt') }} inet static
|
||||
address {{ item.alias }}
|
||||
netmask {{ item.netmask | default('255.255.255.0') }}
|
||||
{% endif %}
|
||||
|
5
network_interfaces/redhat_interface_alias.cfg.j2
Normal file
5
network_interfaces/redhat_interface_alias.cfg.j2
Normal file
@ -0,0 +1,5 @@
|
||||
# This interface is an alias
|
||||
DEVICE={{ item.name | default('br-mgmt') }}:0
|
||||
IPADDR={{ item.alias | default('10.1.0.1') }}
|
||||
NETMASK={{ item.netmask | default('255.255.255.0') }}
|
||||
ONBOOT=yes
|
@ -64,6 +64,15 @@
|
||||
when:
|
||||
- ansible_pkg_mgr == 'yum'
|
||||
|
||||
- name: Create alias file when required
|
||||
template:
|
||||
src: "network_interfaces/redhat_interface_alias.cfg.j2"
|
||||
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name | default('br-mgmt')}}:0"
|
||||
with_items: "{{ bridges }}"
|
||||
when:
|
||||
- ansible_pkg_mgr == 'yum'
|
||||
- item.alias is defined
|
||||
|
||||
- name: Put down post-up script for veth-peer interfaces (RedHat)
|
||||
template:
|
||||
src: "network_interfaces/redhat_interface_{{ item[0] | default('default') }}.cfg.j2"
|
||||
@ -90,12 +99,28 @@
|
||||
- (network_interfaces_rhel | changed) or (network_interfaces_deb | changed)
|
||||
with_items: "{{ bridges }}"
|
||||
|
||||
- name: Shut down the alias interface (RedHat)
|
||||
command: "ifdown {{ item.name | default('br-mgmt') }}:0"
|
||||
when:
|
||||
- ansible_pkg_mgr == 'yum'
|
||||
- network_interfaces_rhel | changed
|
||||
- item.alias is defined
|
||||
with_items: "{{ bridges }}"
|
||||
|
||||
- name: Start the network interfaces
|
||||
command: "ifup {{ item.name | default('br-mgmt') }}"
|
||||
when:
|
||||
- (network_interfaces_rhel | changed) or (network_interfaces_deb | changed)
|
||||
with_items: "{{ bridges }}"
|
||||
|
||||
- name: Start the alias interface (RedHat)
|
||||
command: "ifup {{ item.name | default('br-mgmt') }}:0"
|
||||
when:
|
||||
- ansible_pkg_mgr == 'yum'
|
||||
- network_interfaces_rhel | changed
|
||||
- item.alias is defined
|
||||
with_items: "{{ bridges }}"
|
||||
|
||||
- name: Add iptables rule to ensure ssh checksum is correct
|
||||
command: /sbin/iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user