2023-03-14 18:58:52 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2023-04-09 02:03:29 +00:00
|
|
|
# Salt lab environment with one master and various minions
|
2023-03-14 18:58:52 +00:00
|
|
|
|
2024-02-06 17:15:52 +00:00
|
|
|
# hardware specs
|
|
|
|
CPU_COUNT = 2
|
|
|
|
MEMORY_MB = 1024
|
|
|
|
|
2023-03-14 03:08:57 +00:00
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
config.nfs.verify_installed = false
|
2023-03-24 19:45:04 +00:00
|
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
2023-03-14 03:08:57 +00:00
|
|
|
config.vm.define "salt", primary: true do |salt|
|
2024-02-06 12:53:35 +00:00
|
|
|
salt.vm.box = "bento/ubuntu-22.04"
|
2023-03-14 03:08:57 +00:00
|
|
|
salt.vm.hostname = "salt"
|
2024-02-06 12:53:35 +00:00
|
|
|
salt.vm.network :private_network,
|
|
|
|
:ip => "192.168.100.120",
|
|
|
|
:libvirt__dhcp_enabled => false
|
2023-03-14 03:08:57 +00:00
|
|
|
salt.vm.provider :libvirt do |libvirt|
|
2024-02-06 17:15:52 +00:00
|
|
|
libvirt.cpus = CPU_COUNT
|
|
|
|
libvirt.memory = MEMORY_MB
|
2023-03-14 03:08:57 +00:00
|
|
|
end
|
2023-04-09 02:03:29 +00:00
|
|
|
salt.vm.synced_folder 'salt_content/local', '/srv', type: 'rsync'
|
2023-03-14 03:08:57 +00:00
|
|
|
salt.vm.provision "shell", inline: <<-SHELL
|
2023-03-23 23:37:36 +00:00
|
|
|
apt-get update
|
2024-02-06 12:53:35 +00:00
|
|
|
apt-get install curl vim -y
|
2023-03-14 03:08:57 +00:00
|
|
|
curl -o bootstrap-salt.sh -L https://bootstrap.saltproject.io
|
2024-02-06 12:53:35 +00:00
|
|
|
sh bootstrap-salt.sh -M -X -U stable 3006
|
|
|
|
salt-pip install pygit2
|
2023-03-27 02:10:41 +00:00
|
|
|
cat << EOF > /etc/salt/master.d/lab.conf
|
2023-04-08 03:48:12 +00:00
|
|
|
auto_accept: True
|
2024-02-07 16:22:14 +00:00
|
|
|
file_ignore_regex:
|
|
|
|
- '/*\.gitkeep'
|
2023-03-27 02:10:41 +00:00
|
|
|
file_roots:
|
|
|
|
base:
|
2023-04-09 02:03:29 +00:00
|
|
|
- /srv/salt
|
2024-02-07 15:40:11 +00:00
|
|
|
- /srv/formulas
|
2023-04-08 03:38:21 +00:00
|
|
|
fileserver_backend:
|
|
|
|
- roots
|
|
|
|
- gitfs
|
|
|
|
gitfs_provider: pygit2
|
|
|
|
gitfs_update_interval: 60
|
2023-04-08 03:48:38 +00:00
|
|
|
gitfs_base: main
|
2023-04-08 03:38:21 +00:00
|
|
|
gitfs_remotes:
|
|
|
|
- https://github.com/jbowdre/vagrant-saltlab.git:
|
2023-04-09 02:03:29 +00:00
|
|
|
- root: salt_content/gitfs/salt
|
2023-04-08 03:38:21 +00:00
|
|
|
- mountpoint: salt://
|
2024-02-10 03:50:46 +00:00
|
|
|
# Uncomment the following to use the salt-content repo
|
|
|
|
# - https://github.com/jbowdre/salt-content.git:
|
|
|
|
# - root: salt
|
|
|
|
# -mountpoint: salt://
|
2023-04-09 02:03:29 +00:00
|
|
|
pillar_roots:
|
|
|
|
base:
|
|
|
|
- /srv/pillar
|
2023-04-08 03:38:21 +00:00
|
|
|
ext_pillar:
|
|
|
|
- git:
|
|
|
|
- main https://github.com/jbowdre/vagrant-saltlab.git:
|
2023-04-09 02:03:29 +00:00
|
|
|
- root: salt_content/gitfs/pillar
|
2023-04-08 04:04:44 +00:00
|
|
|
- env: base
|
2023-03-27 02:10:41 +00:00
|
|
|
reactor:
|
|
|
|
- 'salt/minion/*/start':
|
2023-04-08 03:38:21 +00:00
|
|
|
- salt://_reactor/sync_grains.sls
|
2023-03-27 02:10:41 +00:00
|
|
|
EOF
|
2023-03-23 23:37:06 +00:00
|
|
|
systemctl start salt-master
|
|
|
|
systemctl start salt-minion
|
|
|
|
sleep 5
|
|
|
|
systemctl restart salt-master
|
2023-03-14 03:08:57 +00:00
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "minion01" do |minion01|
|
2024-02-06 12:53:35 +00:00
|
|
|
minion01.vm.box = "bento/ubuntu-22.04"
|
2023-03-14 03:08:57 +00:00
|
|
|
minion01.vm.hostname = "minion01"
|
2024-02-06 12:53:35 +00:00
|
|
|
minion01.vm.network :private_network,
|
|
|
|
:ip => "192.168.100.121",
|
|
|
|
:libvirt__dhcp_enabled => false
|
|
|
|
minion01.vm.provider :libvirt do |libvirt|
|
2024-02-06 17:15:52 +00:00
|
|
|
libvirt.cpus = CPU_COUNT
|
|
|
|
libvirt.memory = MEMORY_MB
|
2024-02-06 12:53:35 +00:00
|
|
|
end
|
2023-03-14 03:08:57 +00:00
|
|
|
minion01.vm.provision "shell", inline: <<-SHELL
|
2023-03-23 23:37:36 +00:00
|
|
|
apt-get update
|
2023-03-24 02:40:54 +00:00
|
|
|
apt-get install curl -y
|
2023-03-14 03:08:57 +00:00
|
|
|
curl -o bootstrap-salt.sh -L https://bootstrap.saltproject.io
|
2024-02-06 12:53:35 +00:00
|
|
|
sh bootstrap-salt.sh -A 192.168.100.120 -U stable 3006
|
2023-03-24 02:40:54 +00:00
|
|
|
cat << EOF > /etc/salt/minion.d/grains.conf
|
|
|
|
grains:
|
|
|
|
roles:
|
|
|
|
- saltlab
|
|
|
|
EOF
|
|
|
|
systemctl restart salt-minion
|
2023-03-14 03:08:57 +00:00
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "minion02" do |minion02|
|
2024-02-06 12:53:35 +00:00
|
|
|
minion02.vm.box = "peru/ubuntu-20.04-server-amd64"
|
2023-03-14 03:08:57 +00:00
|
|
|
minion02.vm.hostname = "minion02"
|
2024-02-06 12:53:35 +00:00
|
|
|
minion02.vm.network :private_network,
|
|
|
|
:ip => "192.168.100.122",
|
|
|
|
:libvirt__dhcp_enabled => false
|
|
|
|
minion02.vm.provider :libvirt do |libvirt|
|
2024-02-06 17:15:52 +00:00
|
|
|
libvirt.cpus = CPU_COUNT
|
|
|
|
libvirt.memory = MEMORY_MB
|
2024-02-06 12:53:35 +00:00
|
|
|
end
|
2023-03-14 03:08:57 +00:00
|
|
|
minion02.vm.provision "shell", inline: <<-SHELL
|
2023-03-23 23:37:36 +00:00
|
|
|
apt-get update
|
2023-03-24 02:40:54 +00:00
|
|
|
apt-get install curl -y
|
2023-03-14 03:08:57 +00:00
|
|
|
curl -o bootstrap-salt.sh -L https://bootstrap.saltproject.io
|
2024-02-06 12:53:35 +00:00
|
|
|
sh bootstrap-salt.sh -A 192.168.100.120 -U stable 3006
|
2023-03-24 02:40:54 +00:00
|
|
|
cat << EOF > /etc/salt/minion.d/grains.conf
|
|
|
|
grains:
|
|
|
|
roles:
|
|
|
|
- saltlab
|
2023-03-24 22:12:03 +00:00
|
|
|
- web
|
2023-03-24 02:40:54 +00:00
|
|
|
EOF
|
|
|
|
systemctl restart salt-minion
|
2023-03-14 03:08:57 +00:00
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "minion03" do |minion03|
|
2024-02-06 12:53:35 +00:00
|
|
|
minion03.vm.box = "bento/rockylinux-8"
|
2023-03-14 03:08:57 +00:00
|
|
|
minion03.vm.hostname = "minion03"
|
2024-02-06 12:53:35 +00:00
|
|
|
minion03.vm.network :private_network,
|
|
|
|
:ip => "192.168.100.123",
|
|
|
|
:libvirt__dhcp_enabled => false
|
|
|
|
minion03.vm.provider :libvirt do |libvirt|
|
2024-02-06 17:15:52 +00:00
|
|
|
libvirt.cpus = CPU_COUNT
|
|
|
|
libvirt.memory = MEMORY_MB
|
2024-02-06 12:53:35 +00:00
|
|
|
end
|
2023-03-14 03:08:57 +00:00
|
|
|
minion03.vm.provision "shell", inline: <<-SHELL
|
|
|
|
curl -o bootstrap-salt.sh -L https://bootstrap.saltproject.io
|
2024-02-06 12:53:35 +00:00
|
|
|
sh bootstrap-salt.sh -A 192.168.100.120 -U stable 3006
|
2023-03-25 03:08:20 +00:00
|
|
|
systemctl enable salt-minion
|
2023-03-24 02:40:54 +00:00
|
|
|
cat << EOF > /etc/salt/minion.d/grains.conf
|
|
|
|
grains:
|
|
|
|
roles:
|
|
|
|
- saltlab
|
|
|
|
EOF
|
|
|
|
systemctl restart salt-minion
|
2023-03-14 03:08:57 +00:00
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "minion04" do |minion04|
|
2024-02-06 12:53:35 +00:00
|
|
|
minion04.vm.box = "rockylinux/9"
|
2023-03-14 03:08:57 +00:00
|
|
|
minion04.vm.hostname = "minion04"
|
2024-02-06 12:53:35 +00:00
|
|
|
minion04.vm.network :private_network,
|
|
|
|
:ip => "192.168.100.124",
|
|
|
|
:libvirt__dhcp_enabled => false
|
|
|
|
minion04.vm.provider :libvirt do |libvirt|
|
2024-02-06 17:15:52 +00:00
|
|
|
libvirt.cpus = CPU_COUNT
|
|
|
|
libvirt.memory = MEMORY_MB
|
2024-02-06 12:53:35 +00:00
|
|
|
end
|
2023-03-14 03:08:57 +00:00
|
|
|
minion04.vm.provision "shell", inline: <<-SHELL
|
|
|
|
curl -o bootstrap-salt.sh -L https://bootstrap.saltproject.io
|
2024-02-06 12:53:35 +00:00
|
|
|
sh bootstrap-salt.sh -A 192.168.100.120 -U stable 3006
|
2023-03-24 02:40:54 +00:00
|
|
|
cat << EOF > /etc/salt/minion.d/grains.conf
|
|
|
|
grains:
|
|
|
|
roles:
|
|
|
|
- saltlab
|
2023-03-24 22:12:03 +00:00
|
|
|
- web
|
2023-03-24 02:40:54 +00:00
|
|
|
EOF
|
|
|
|
systemctl restart salt-minion
|
2023-03-14 03:08:57 +00:00
|
|
|
SHELL
|
|
|
|
end
|
|
|
|
end
|