-
Notifications
You must be signed in to change notification settings - Fork 39
/
01_sno_install_virtualization_tools.yml
91 lines (82 loc) · 2.78 KB
/
01_sno_install_virtualization_tools.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
91
---
- name: This play installs needed tools to provision infrastructure VMs
hosts: vm_host
vars_files:
- vars/sno_vars.yml
become: true
tasks:
- name: Install needed packages
ansible.builtin.yum:
name: "{{ virtualization_packages.rhel }}"
state: latest # noqa package-latest
when:
- ansible_distribution == 'RedHat'
- name: Install needed packages
ansible.builtin.yum:
name: "{{ virtualization_packages.centos }}"
state: latest # noqa package-latest
when:
- ansible_distribution == 'CentOS'
- name: Install needed packages
ansible.builtin.yum:
name: "{{ virtualization_packages.fedora }}"
state: latest # noqa package-latest
when:
- ansible_distribution == 'Fedora'
- name: Download and provision Terraform
ansible.builtin.unarchive:
src: "{{ terraform_release_url }}"
dest: /usr/bin/
mode: "0755"
remote_src: true
- name: Virtualization services are enabled
ansible.builtin.service:
name: libvirtd
state: started
enabled: true
when: ansible_distribution != 'CentOS' or
(ansible_distribution == 'CentOS' and ansible_distribution_major_version | int == 8)
- name: Virtualization services are enabled
ansible.builtin.service:
name: virtqemud
state: started
enabled: true
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version | int == 9
- name: Ensure libvirt can use root as user
ansible.builtin.replace:
path: /etc/libvirt/qemu.conf
regexp: "{{ item.regexp }}"
replace: "{{ item.line }}"
loop:
- regexp: '#user = "root"'
line: 'user = "root"'
- regexp: '#group = "root"'
line: 'group = "root"'
- name: Virtualization services are enabled
ansible.builtin.service:
name: libvirtd
state: restarted
enabled: true
when:
- ansible_distribution == 'CentOS'
- name: Virtualization services are enabled
ansible.builtin.service:
name: virtqemud
state: restarted
enabled: true
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version | int == 9
- name: Use TF project to ensure pool and network are defined
community.general.terraform:
project_path: "{{ workspace_directory.base_path }}/{{ cluster.name }}/terraform/libvirt-resources-sno"
variables:
domain: "{{ cluster.name }}.{{ domain }}"
network_cidr: ' ["{{ network_cidr }}"]'
cluster_name: "{{ cluster.name }}"
dns: "{{ cluster_nodes.host_list.sno.ip }}"
force_init: true
state: present
become: true