forked from Checkmk/ansible-collection-checkmk.general
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
220 lines (208 loc) · 9.93 KB
/
Copy pathVagrantfile
File metadata and controls
220 lines (208 loc) · 9.93 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
ENV['VAGRANT_NO_PARALLEL'] = 'yes'
Vagrant.configure("2") do |config|
# We are using boxes from here: https://app.vagrantup.com/generic
# Main Box
config.vm.define "collection", primary: true do |srv|
srv.vm.box = "generic/debian12" # boxen/debian-13 # generic/debian12 # alvistack/debian-13
srv.vm.network :private_network,
:ip => "192.168.124.42",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used for development of the Checkmk Ansible Collection.'
libvirt.memory = 8096
libvirt.cpus = 4
libvirt.title = 'collection'
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
$script = <<-SCRIPT
apt-get -y update --quiet
apt-get -y purge postfix --quiet # Necessary, as it breaks the upgrade process
apt-get -y dist-upgrade --quiet
apt-get -y install ca-certificates curl direnv gnupg lsb-release qemu-guest-agent podman htop make glances
sudo -u vagrant bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh"
sudo -u vagrant bash -c "cd /home/vagrant/ansible_collections/checkmk/general/ && /home/vagrant/.local/bin/uv sync"
sudo -u vagrant bash -c "cd /home/vagrant/ansible_collections/checkmk/general/ && /home/vagrant/.local/bin/uv run ansible-galaxy collection install -f -r /home/vagrant/ansible_collections/checkmk/general/requirements.yml"
grep "alias ic=" /home/vagrant/.bashrc || echo "alias ic='LC_ALL=C.UTF-8 uv run ansible-galaxy collection build --force ~/ansible_collections/checkmk/general && LC_ALL=C.UTF-8 uv run ansible-galaxy collection install -f ./checkmk-general-*.tar.gz && rm ./checkmk-general-*.tar.gz'" >> /home/vagrant/.bashrc
grep "alias ap=" /home/vagrant/.bashrc || echo "alias ap='LC_ALL=C.UTF-8 uv run ansible-playbook -i vagrant, '" >> /home/vagrant/.bashrc
grep "export LC_ALL=C.UTF-8" /home/vagrant/.bashrc || echo "export LC_ALL=C.UTF-8" >> /home/vagrant/.bashrc
grep "export UV_PROJECT_ENVIRONMENT=.venv-vm" /home/vagrant/.bashrc || echo "export UV_PROJECT_ENVIRONMENT=.venv-vm" >> /home/vagrant/.bashrc
hostnamectl set-hostname collection
SCRIPT
srv.vm.provision "shell", inline: $script
srv.vm.provision :reload
srv.vm.synced_folder "./", "/home/vagrant/ansible_collections/checkmk/general/", type: "virtiofs"
end
# Ubuntu
# If we want to move to Ubuntu 24, this could be an option: cloud-image/ubuntu-24.04
config.vm.define "ansibuntu", autostart: false , primary: false do |srv|
srv.vm.box = "generic/ubuntu2204"
# srv.vm.box = "boxen/ubuntu-24.04" # ToDo: Fix issue with local Vagrant
srv.vm.network :private_network,
:ip => "192.168.124.61",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.title = "ansibuntu"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
srv.vm.provision "shell",
inline: "apt-get -y update --quiet && apt-get -y install vim htop curl wget git acl"
end
# Debian
config.vm.define "debsible", autostart: false , primary: false do |srv|
srv.vm.box = "generic/debian12"
# srv.vm.box = "boxen/debian-13" # ToDo: Fix issue with local Vagrant
srv.vm.network :private_network,
:ip => "192.168.124.62",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.title = "debsible"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
srv.vm.provision "shell",
inline: "apt-get -y update --quiet && apt-get -y install vim htop curl wget git acl"
end
# CentOS Stream
config.vm.define "anstream", autostart: false , primary: false do |srv|
srv.vm.box = "generic/centos9s"
srv.vm.network :private_network,
:ip => "192.168.124.63",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.title = "anstream"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
srv.vm.provision "shell",
inline: "dnf --quiet check-update ; dnf -y install vim curl wget git"
end
# openSUSE
config.vm.define "ansuse", autostart: false , primary: false do |srv|
srv.vm.box = "generic/opensuse15"
srv.vm.network :private_network,
:ip => "192.168.124.64",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.title = "ansuse"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
srv.vm.provision "shell",
inline: "zypper --quiet up -y && zypper --quiet in -y python311-rpm"
end
# Rocky
config.vm.define "rocksible", autostart: false , primary: false do |srv|
# Manual download is needed, as the link on HashiCorp is wrong.
# vagrant box add https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-Vagrant-Libvirt.latest.x86_64.box --name rockylinux/10
# vagrant box add https://dl.rockylinux.org/pub/rocky/10/images/x86_64/Rocky-10-Vagrant-Libvirt-10.1-20251116.0.x86_64.box --name rockylinux/10
srv.vm.box = "generic/rocky9"
# srv.vm.box = "rockylinux/10" #rockylinux/9 #rockylinux/8
srv.vm.network :private_network,
:ip => "192.168.124.65",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.title = "rocksible"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
srv.vm.provision "shell",
inline: "dnf --quiet check-update ; dnf -y install vim curl wget git"
end
# Oracle Linux
config.vm.define "ansoracle", autostart: false , primary: false do |srv|
srv.vm.box = "generic/oracle8"
srv.vm.network :private_network,
:ip => "192.168.124.66",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.ssh.insert_key = false
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 2048
libvirt.cpus = 2
libvirt.title = "ansoracle"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
srv.vm.provision "shell",
inline: "dnf --quiet check-update ; dnf -y install vim curl wget git"
end
# Windows
config.vm.define "ansidows", autostart: false , primary: false do |srv|
srv.vm.box = "peru/windows-server-2022-standard-x64-eval"
srv.vm.network :private_network,
:ip => "192.168.124.67",
:libvirt__netmask => "255.255.255.0",
:libvirt__network_name => "ansible_collection",
:libvirt__network_address => "192.168.124.0"
srv.winrm.max_tries = 100
srv.winrm.retry_delay = 2
srv.vm.boot_timeout = 180
srv.vm.hostname = "ansidows"
srv.vm.provider "libvirt" do |libvirt|
libvirt.default_prefix = "ansible_"
libvirt.description = 'This box is used to test roles against.'
libvirt.memory = 4096
libvirt.cpus = 2
libvirt.title = "ansidows"
libvirt.keymap = "de"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
$script = <<-SCRIPT
Set-NetFirewallRule -name 'FPS-ICMP4-ERQ-In*' -Enabled true
Get-NetFirewallrule -DisplayName *snmp* | Enable-NetFirewallRule
Install-WindowsFeature SNMP-Service,SNMP-WMI-Provider -IncludeManagementTools
Invoke-WebRequest -Uri 'https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-latest.exe' -OutFile "C:\\tmp\\spice-guest-tools.exe"
Write-Output "You need to run the spice agent setup manually!"
Write-Output "Find it at 'C:\\tmp\\spice-guest-tools.exe'"
SCRIPT
srv.vm.provision "shell", inline: $script
end
end