blob: cd415d1ef6adafe10f509ffdca0d051c3492a24c (
plain) (
blame)
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
|
---
- name: configure bonds and vlans
when: "'bonds' in network or 'vlans' in network"
block:
- name: install ifenslave package
when: "'bonds' in network"
apt:
name: ifenslave
state: present
- name: install vlan package
when: "'vlans' in network"
apt:
name: vlan
state: present
- name: create network interfaces
template:
src: interfaces.j2
dest: /etc/network/interfaces
- name: create network bridges
when: "'bridges' in vm_host.network"
block:
- name: generate bridge interface config
loop: "{{ vm_host.network.bridges | default({}) | dict2items }}"
loop_control:
label: "{{ item.key }}"
template:
src: bridge-interfaces.j2
dest: "/etc/network/interfaces.d/br-{{ item.key }}"
register: vmhost_bridge_config
## We don't try to be to clever here: aka don't call ifdown before ifup because
## if there are VMs running they would end up with a broken network
- name: bring up bridge interfaces
loop: "{{ vmhost_bridge_config.results }}"
loop_control:
label: "br-{{ item.item.key }}"
when: item is changed
command: "/sbin/ifup br-{{ item.item.key }}"
failed_when: false
|