Skip to content

Instantly share code, notes, and snippets.

@crissilvaeng
Created March 16, 2019 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save crissilvaeng/9c1744df2d6216964cf5f72f8a3c01ef to your computer and use it in GitHub Desktop.
Save crissilvaeng/9c1744df2d6216964cf5f72f8a3c01ef to your computer and use it in GitHub Desktop.
Puppet Lab with Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<-SCRIPT
wget https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
dpkg -i puppetlabs-release-pc1-xenial.deb
apt-get update
SCRIPT
$server = <<-SCRIPT
apt-get install puppetserver -y
ufw allow 8140
systemctl enable puppetserver
systemctl start puppetserver
systemctl status puppetserver
SCRIPT
$agent = <<-SCRIPT
apt-get install puppet-agent -y
systemctl enable puppet
systemctl start puppet
systemctl status puppet
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provision "shell", privileged: true, inline: $script
config.vm.provision :hosts do |provisioner|
provisioner.add_host "10.0.0.10", ['puppet']
end
config.vm.define :puppet do |puppet|
puppet.vm.network :private_network, ip: "10.0.0.10"
puppet.vm.provision "shell", privileged: true, inline: $server
puppet.vm.provider :virtualbox do |vb|
vb.memory = 4096
vb.cpus = 2
end
end
(1..3).each do |i|
config.vm.define "node-#{i}" do |node|
node.vm.provision "shell", privileged: true, inline: $agent
end
end
end
@crissilvaeng
Copy link
Author

Vagrant Hosts plugin is required!

https://github.com/oscar-stack/vagrant-hosts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment