-
Notifications
You must be signed in to change notification settings - Fork 76
/
03_provision_libvirt_resources.yml
78 lines (69 loc) · 2.62 KB
/
03_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
- name: This play provisions libvirt resources with terraform
hosts: vm_host
become: true
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: SELinux fix for running images in different folders
when: (ansible_distribution == 'Ubuntu' and ansible_distribution_major_version | int >= 18)
block:
- name: Ensure security_driver is disabled
ansible.builtin.lineinfile:
line: 'security_driver = "none"'
path: /etc/libvirt/qemu.conf
state: present
- name: Restart libvirtd service
ansible.builtin.service:
name: libvirtd
state: restarted
- name: Take care of systemd-resolved on F33 and Ubuntu hosts
when:
(ansible_distribution == 'Fedora' and ansible_distribution_major_version | int > 33) or
(ansible_distribution == 'Ubuntu' and ansible_distribution_major_version | int > 18)
block:
- name: Ensure systemd-resolved config dir is present
ansible.builtin.file:
path: /etc/systemd/resolved.conf.d/
state: directory
mode: "0755"
- name: Enable localdns if systemd-resolved is present
ansible.builtin.template:
src: systemd-resolved.j2
dest: /etc/systemd/resolved.conf.d/{{ k8s.cluster_name | default('k8s-test', true) }}-local-kube.conf
mode: "0755"
notify:
- Restart systemd-resolved
- name: Ensure NM configuration directory exists
ansible.builtin.file:
path: /etc/NetworkManager/conf.d
state: directory
mode: "0755"
- name: Ensure NM dnsmasq directory exists
ansible.builtin.file:
path: /etc/NetworkManager/dnsmasq.d
state: directory
mode: "0755"
- name: Configure NetworkManager for local DNS
ansible.builtin.copy:
src: files/localdns.conf
dest: /etc/NetworkManager/conf.d/{{ k8s.cluster_name | default('k8s-test', true) }}-localdns.conf
mode: "0755"
notify:
- Restart NetworkManager
- name: Configure NetworkManager for libvirt network
ansible.builtin.template:
src: templates/libvirt_dnsmasq.j2
dest: /etc/NetworkManager/dnsmasq.d/{{ k8s.cluster_name | default('k8s-test', true) }}-libvirt_dnsmasq.conf
mode: "0755"
notify:
- Restart NetworkManager
handlers:
- name: Restart systemd-resolved
ansible.builtin.service:
name: systemd-resolved
state: restarted
enabled: true
- name: Restart NetworkManager
ansible.builtin.service:
name: NetworkManager
state: restarted