-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
98 lines (77 loc) · 3.34 KB
/
Vagrantfile
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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 2.0.0"
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vagrant.plugins = "vagrant-hosts"
vagrant_branch = ENV['PUPPET_ENV'] || 'production'
config.vm.box = "almalinux/9"
config.vm.synced_folder ".", "/vagrant"
config.vm.provider :virtualbox do |vb|
vb.auto_nat_dns_proxy = false
vb.default_nic_type = "virtio"
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
vb.customize ["modifyvm", :id, "--audio", "none"]
end
config.vm.provision :shell, inline: <<-SHELL
systemctl restart rsyslog
systemctl mask firewalld
systemctl stop firewalld
dnf -y install http://yum.puppet.com/puppet8-release-el-9.noarch.rpm
dnf -y install puppet-agent
SHELL
config.vm.provision :hosts do |h|
h.add_localhost_hostnames = false
h.add_host '192.168.56.20', ['puppet.localdomain', 'puppet']
h.add_host '192.168.56.21', ['node.localdomain', 'node']
end
# Puppet
config.vm.define "puppet", primary: true do |puppet|
puppet.vm.hostname = "puppet.localdomain"
puppet.vm.network "private_network", ip: "192.168.56.20", virtualbox__intnet: "puppet"
puppet.vm.network "forwarded_port", guest: 80, host: 8000
puppet.vm.provider "virtualbox" do |vb|
vb.name = "puppet"
vb.memory = "4096"
vb.cpus = "2"
end
puppet.vm.provision "shell", run: "once", env: {"PUPPET_ENV" => vagrant_branch}, inline: <<-SHELL
rm -rf /tmp/modules
/opt/puppetlabs/bin/puppet module install \
--environment production --modulepath=/tmp/modules \
puppet/r10k
/opt/puppetlabs/bin/puppet apply \
--environment production --modulepath=/tmp/modules \
-e "class { 'r10k': remote => 'https://github.com/vchepkov/puppet-bootstrap.git' }"
/opt/puppetlabs/bin/puppet apply \
--environment production --modulepath=/tmp/modules \
-e "file_line { 'mco': path=>'/root/.bashrc', line=>'alias mco=\\'sudo -u vagrant USER=vagrant /opt/puppetlabs/puppet/bin/mco\\''}"
dnf -y install git-core
# required by PuppetDB module 8.1.0
dnf install -y glibc-langpack-en
/vagrant/bin/bootstrap.sh
/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
SHELL
end
# Node
config.vm.define "node", autostart: false do |node|
node.vm.hostname = "node.localdomain"
node.vm.network "private_network", ip: "192.168.56.21", virtualbox__intnet: "puppet"
node.vm.provider "virtualbox" do |vb|
vb.name = "node"
vb.memory = "1024"
end
node.vm.provision "shell", run: "once", inline: <<-SHELL
/opt/puppetlabs/bin/puppet config set server puppet.localdomain --section main
/opt/puppetlabs/bin/puppet config set environment #{vagrant_branch} --section agent
/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
SHELL
end
end