dbc9598201
The correct options are POST_{UP,DOWN}_SCRIPT Change-Id: Ie3a53a29b99aa1a3cbe4fc4950405adc5f655141
194 lines
6.5 KiB
YAML
194 lines
6.5 KiB
YAML
---
|
|
# Copyright 2015, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Ensure that /etc/network/interfaces.d/ exists (Debian)
|
|
file:
|
|
path: /etc/network/interfaces.d/
|
|
state: directory
|
|
tags:
|
|
- networking-dir-create
|
|
when:
|
|
- ansible_pkg_mgr == 'apt'
|
|
|
|
- name: Copy AIO network configuration (Debian)
|
|
template:
|
|
src: osa_interfaces.cfg.j2
|
|
dest: /etc/network/interfaces.d/osa_interfaces.cfg
|
|
register: osa_interfaces
|
|
when:
|
|
- bootstrap_host_aio_config | bool
|
|
- ansible_pkg_mgr == 'apt'
|
|
tags:
|
|
- networking-interfaces-file
|
|
|
|
- name: Copy network configuration (RedHat)
|
|
template:
|
|
src: "redhat_interface_{{ item.type | default('default') }}.cfg.j2"
|
|
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name | default('br-mgmt') }}"
|
|
with_items: "{{ bridges }}"
|
|
register: network_interfaces_rhel
|
|
when:
|
|
- ansible_pkg_mgr in ['yum', 'dnf']
|
|
|
|
- name: Create alias file when required (RedHat)
|
|
template:
|
|
src: "redhat_interface_alias.cfg.j2"
|
|
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name | default('br-mgmt')}}:0"
|
|
with_items: "{{ bridges }}"
|
|
when:
|
|
- ansible_pkg_mgr in ['yum', 'dnf']
|
|
- item.alias is defined
|
|
|
|
- name: Put down post-up script for veth-peer interfaces (RedHat)
|
|
template:
|
|
src: "rpm_interface_{{ item[0] }}.cfg.j2"
|
|
dest: "/etc/sysconfig/network-scripts/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
|
|
mode: "0755"
|
|
with_nested:
|
|
- [ "ifup-post", "ifdown-post" ]
|
|
- "{{ bridges }}"
|
|
when:
|
|
- item[1].veth_peer is defined
|
|
- ansible_pkg_mgr in ['yum', 'dnf']
|
|
|
|
- name: Ensure the postup/postdown scripts are loaded (RedHat)
|
|
lineinfile:
|
|
dest: "/etc/sysconfig/network-scripts/{{ item[0] }}"
|
|
line: ". /etc/sysconfig/network-scripts/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
|
|
insertbefore: "^exit 0"
|
|
with_nested:
|
|
- [ "ifup-post", "ifdown-post" ]
|
|
- "{{ bridges }}"
|
|
when:
|
|
- item[1].veth_peer is defined
|
|
- ansible_pkg_mgr in ['yum', 'dnf']
|
|
|
|
- name: Copy network configuration (SUSE)
|
|
template:
|
|
src: "suse_interface_default.cfg.j2"
|
|
dest: "/etc/sysconfig/network/ifcfg-{{ item.name | default('br-mgmt') }}"
|
|
with_items: "{{ bridges }}"
|
|
register: network_interfaces_suse
|
|
when:
|
|
- ansible_pkg_mgr == 'zypper'
|
|
|
|
- name: Put down post-up script for veth-peer interfaces (SUSE)
|
|
template:
|
|
src: "rpm_interface_{{ item[0] }}.cfg.j2"
|
|
dest: "/etc/sysconfig/network/scripts/{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}"
|
|
mode: "0755"
|
|
with_nested:
|
|
- [ "ifup-post", "ifdown-post" ]
|
|
- "{{ bridges }}"
|
|
when:
|
|
- item[1].veth_peer is defined
|
|
- ansible_pkg_mgr == 'zypper'
|
|
|
|
- name: Ensure the postup scripts are loaded (SUSE)
|
|
lineinfile:
|
|
dest: "/etc/sysconfig/network/ifcfg-{{ item[1].name | default('br-mgmt') }}"
|
|
line: "POST_UP_SCRIPT=\"compat:suse:{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}\""
|
|
with_nested:
|
|
- [ "ifup-post" ]
|
|
- "{{ bridges }}"
|
|
when:
|
|
- item[1].veth_peer is defined
|
|
- ansible_pkg_mgr == 'zypper'
|
|
|
|
- name: Ensure the postdown scripts are loaded (SUSE)
|
|
lineinfile:
|
|
dest: "/etc/sysconfig/network/ifcfg-{{ item[1].name | default('br-mgmt') }}"
|
|
line: "POST_DOWN_SCRIPT=\"compat:suse:{{ item[0] }}-veth-{{ item[1].name | default('br-mgmt') }}-2-{{ item[1].veth_peer | default('eth1') }}\""
|
|
with_nested:
|
|
- [ "ifdown-post" ]
|
|
- "{{ bridges }}"
|
|
when:
|
|
- item[1].veth_peer is defined
|
|
- ansible_pkg_mgr == 'zypper'
|
|
|
|
- name: Copy multinode network configuration (Debian)
|
|
template:
|
|
src: osa_interfaces_multinode.cfg.j2
|
|
dest: /etc/network/interfaces.d/osa_interfaces.cfg
|
|
register: osa_multinode_interfaces
|
|
when:
|
|
- not bootstrap_host_aio_config | bool
|
|
- ansible_pkg_mgr == 'apt'
|
|
tags:
|
|
- networking-interfaces-file
|
|
|
|
- name: Ensure our interfaces.d configuration files are loaded automatically (Debian)
|
|
lineinfile:
|
|
dest: /etc/network/interfaces
|
|
line: "source /etc/network/interfaces.d/*.cfg"
|
|
when:
|
|
- ansible_pkg_mgr == 'apt'
|
|
tags:
|
|
- networking-interfaces-load
|
|
|
|
- name: Shut down the network interfaces
|
|
command: "ifdown {{ item.name }}"
|
|
when:
|
|
- osa_interfaces | changed or osa_multinode_interfaces | changed or network_interfaces_rhel | changed
|
|
- item.enabled | default(True)
|
|
with_items:
|
|
- { name: br-mgmt }
|
|
- { name: br-storage }
|
|
- { name: br-vlan }
|
|
- { name: br-vxlan }
|
|
- { name: br-dbaas, enabled: "{{ (bootstrap_host_scenario == 'translations') | bool }}" }
|
|
- { name: br-lbaas, enabled: "{{ (bootstrap_host_scenario in ['translations', 'octavia']) | bool }}" }
|
|
tags:
|
|
- networking-interfaces-stop
|
|
|
|
- name: Shut down the encapsulation network interfaces
|
|
command: "ifdown {{ item.key }}"
|
|
when:
|
|
- osa_multinode_interfaces | changed
|
|
- bootstrap_host_encapsulation_enabled | bool
|
|
with_dict: "{{ bootstrap_host_encapsulation_interfaces }}"
|
|
tags:
|
|
- networking-interfaces-stop
|
|
|
|
- name: Start the encapsulation network interfaces
|
|
command: "ifup {{ item.key }}"
|
|
when:
|
|
- osa_multinode_interfaces | changed
|
|
- bootstrap_host_encapsulation_enabled | bool
|
|
with_dict: "{{ bootstrap_host_encapsulation_interfaces }}"
|
|
tags:
|
|
- networking-interfaces-start
|
|
|
|
- name: Start the network interfaces
|
|
command: "ifup {{ item.name }}"
|
|
when:
|
|
- osa_interfaces | changed or network_interfaces_rhel | changed or network_interfaces_suse | changed
|
|
- item.enabled | default(True)
|
|
with_items:
|
|
- { name: br-mgmt }
|
|
- { name: br-storage }
|
|
- { name: br-vlan }
|
|
- { name: br-vxlan }
|
|
- { name: br-dbaas, enabled: "{{ (bootstrap_host_scenario == 'translations') | bool }}" }
|
|
- { name: br-lbaas, enabled: "{{ (bootstrap_host_scenario in ['translations', 'octavia']) | bool }}" }
|
|
tags:
|
|
- networking-interfaces-start
|
|
|
|
- name: Updating the facts due to net changes
|
|
setup:
|
|
filter: "ansible_br*"
|
|
tags:
|
|
- networking
|