forked from kubealex/libvirt-k8s-provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_provision_libvirt_resources.yml
90 lines (76 loc) · 2.83 KB
/
02_provision_libvirt_resources.yml
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
- name: This play provisions libvirt resources with terraform
hosts: vm_host
become: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: Use TF project to ensure pool and network are defined
terraform:
project_path: "files/terraform/libvirt-resources"
variables:
domain: "{{ k8s.network.domain }}"
network_cidr: ' ["{{ k8s.network.network_cidr }}"]'
cluster_name: "{{ k8s.cluster_name }}"
force_init: true
state: present
register: output_masters
- name: qemu SELinux fix for running images in different folders
block:
- name: Ensure security_driver is disabled
lineinfile:
line: 'security_driver = "none"'
path: /etc/libvirt/qemu.conf
state: present
- name: Restart libvirtd service
service:
name: libvirtd
state: restarted
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '18'
- name: Take care of systemd-resolved on F33 and Ubuntu hosts
block:
- name: Ensure systemd-resolved config dir is present
file:
path: /etc/systemd/resolved.conf.d/
state: directory
- name: Enable localdns if systemd-resolved is present
template:
src: systemd-resolved.j2
dest: /etc/systemd/resolved.conf.d/local-kube.conf
notify:
- Restart systemd-resolved
when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version == '33') or (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '18')
- name: Ensure NM configuration directory exists
file:
path: /etc/NetworkManager/conf.d
state: directory
- name: Ensure NM dnsmasq directory exists
file:
path: /etc/NetworkManager/dnsmasq.d
state: directory
- name: Configure NetworkManager for local DNS
copy:
src: files/localdns.conf
dest: /etc/NetworkManager/conf.d/localdns.conf
notify:
- Restart NetworkManager
- name: Configure NetworkManager for libvirt network
template:
src: templates/libvirt_dnsmasq.j2
dest: /etc/NetworkManager/dnsmasq.d/libvirt_dnsmasq.conf
notify:
- Wait for local DNS resolver to be up
handlers:
- name: Restart systemd-resolved
service:
name: systemd-resolved
state: restarted
enabled: true
- name: Restart NetworkManager
service:
name: NetworkManager
state: restarted
- name: Wait for local DNS resolver to be up
wait_for:
port: 53
delay: 10
when: not (ansible_distribution == 'Fedora' and ansible_distribution_major_version == '33') or (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '18')