0c99f74c03
Change-Id: I9567a0319a4763ad3e37e4a8704751d7dfbf8b29
111 lines
3.0 KiB
YAML
111 lines
3.0 KiB
YAML
---
|
|
|
|
# Copyright 2014, 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.
|
|
|
|
# NOTE(mhayden): One of three exit codes should be returned.
|
|
# 0 = service is running
|
|
# 3 = service is installed, but not running
|
|
# 4 = service is not installed, and not running
|
|
- name: Check if NetworkManager is running
|
|
command: systemctl status NetworkManager
|
|
changed_when: false
|
|
failed_when: false
|
|
register: networkmanager_check
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Ensure network services wait on networking (if using NetworkManager)
|
|
service:
|
|
name: NetworkManager-wait-online.service
|
|
enabled: yes
|
|
when: networkmanager_check.rc == 0
|
|
|
|
- name: Drop lxc net bridge
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
owner: "root"
|
|
group: "root"
|
|
mode: "{{ item.mode | default('0644') }}"
|
|
with_items: "{{ lxc_cached_network_interfaces }}"
|
|
notify:
|
|
- Restart bridge
|
|
tags:
|
|
- lxc-files
|
|
- lxc-net
|
|
- lxc-bridge
|
|
- lxc-interfaces
|
|
|
|
# NOTE(mhayden): There are ifup hooks that handle the customized LXC container
|
|
# networking. Starting lxc-net will trample over these hooks and cause
|
|
# networking issues for containers.
|
|
- name: Disable and stop lxc-net
|
|
service:
|
|
name: lxc-net
|
|
enabled: no
|
|
state: stopped
|
|
tags:
|
|
- lxc-net
|
|
|
|
- name: Mask lxc-net systemd service
|
|
file:
|
|
src: /dev/null
|
|
path: /etc/systemd/system/lxc-net.service
|
|
state: link
|
|
tags:
|
|
- lxc-files
|
|
- lxc-net
|
|
|
|
# All Debian based systems use the interfaces.d directory for extra network configs
|
|
# this check ensures the needed source line is in the base config file
|
|
- name: Ensure networking includes interfaces.d
|
|
lineinfile:
|
|
dest: "/etc/network/interfaces"
|
|
line: "source /etc/network/interfaces.d/*.cfg"
|
|
backup: "yes"
|
|
when:
|
|
- ansible_facts['os_family'] == "Debian"
|
|
tags:
|
|
- lxc-net
|
|
- lxc-interfaces
|
|
|
|
- name: Create systemd unit for dnsmasq
|
|
template:
|
|
src: lxc-dnsmasq-systemd-init.j2
|
|
dest: "/etc/systemd/system/lxc-dnsmasq.service"
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
when:
|
|
- lxc_net_nat | bool
|
|
notify:
|
|
- Reload systemd units
|
|
- Restart dnsmasq
|
|
|
|
# Check that the container bridge exists, if not bring it up
|
|
- name: Check Container Bridge exists
|
|
stat:
|
|
path: "/sys/class/net/{{ lxc_net_bridge }}/bridge/bridge_id"
|
|
register: bridge_check
|
|
failed_when: false
|
|
changed_when: not bridge_check.stat.exists
|
|
notify:
|
|
- Bring bridge up
|
|
tags:
|
|
- lxc-bridge
|
|
|
|
# Ensure lxc networks are running as they're supposed to
|
|
- meta: flush_handlers
|