Skip to content

Instantly share code, notes, and snippets.

@tylerjl tylerjl/Vagrantfile
Created Apr 3, 2017

Embed
What would you like to do?
CentOS 7 puppet-elasticsearch test env
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Required:
# vagrant: 1.9.3
# vagrant plugin install vagrant-hosts
# vagrant plugin install vagrant-auto_network
require 'tempfile'
manifest = Tempfile.new('site.pp')
manifest << <<-EOS
notify { 'puppet is working' : }
node /^agent/ {
notify { 'this is the agent' : }
class { 'elasticsearch':
java_install => true,
manage_repo => true,
repo_version => '5.x',
restart_on_change => true,
jvm_options => [
'-Xms256m',
'-Xmx256m'
]
}
elasticsearch::instance { 'es-01' : }
}
node /^master/ {
notify { 'this is the master' : }
}
EOS
manifest.close
Vagrant.configure 2 do |config|
domain = 'local'
config.vm.box = 'boxcutter/centos73'
puppet_rpm = 'https://yum.puppetlabs.com/el/7/products/x86_64/puppetlabs-release-22.0-2.noarch.rpm'
config.vm.define :master do |node|
node.vm.hostname = "master.#{domain}"
node.vm.network :private_network, auto_network: true
node.vm.provision :hosts
node.vm.provision :shell,
inline: 'mkdir -p /etc/puppet/manifests ; chmod o+w /etc/puppet/manifests'
node.vm.provision :file,
source: manifest.path,
destination: '/etc/puppet/manifests/site.pp'
node.vm.provision :shell,
inline: <<-EOS
chmod o-w /etc/puppet/manifests
chown root:root /etc/puppet/manifests/site.pp
chmod 664 /etc/puppet/manifests/site.pp
EOS
node.vm.provision :shell,
inline: <<-EOS
if which puppet > /dev/null 2>&1; then
echo 'Puppet Installed.'
else
echo 'Installing Puppet Master.'
rpm -ivh #{puppet_rpm}
yum --nogpgcheck -y install puppetserver
echo '*.local' > /etc/puppet/autosign.conf
echo 'JAVA_ARGS="-Xms256m -Xmx256m -XX:MaxPermSize=256m"' >> /etc/sysconfig/puppetserver
puppet resource service puppetserver ensure=running enable=true
puppet module install elastic/elasticsearch
fi
EOS
end
config.vm.define :agent do |node|
node.vm.hostname = "agent.#{domain}"
node.vm.network :private_network, auto_network: true
node.vm.provision :hosts
node.vm.provision :shell,
inline: <<-EOS
if which puppet > /dev/null 2>&1; then
echo 'Puppet Installed.'
else
echo 'Installing Puppet Agent.'
rpm -ivh #{puppet_rpm}
yum --nogpgcheck -y install puppet
puppet config set --section main server master.local
fi
EOS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.