Skip to content

Instantly share code, notes, and snippets.

@tylerjl tylerjl/.gitignore
Last active Jun 22, 2018

Embed
What would you like to do?
puppet-elasticsearch Vagrantfile
.vagrant
node /master/ {
service { 'puppetserver':
ensure => running,
enable => true,
}
}
node /agent/ {
class { 'elastic_stack::repo': oss => true }
class { 'elasticsearch':
jvm_options => [
'-Xms256m',
'-Xmx256m',
],
oss => true,
version => '6.3.0',
}
elasticsearch::instance { 'es-01' : }
}
.PHONY: all
all: vm
until vagrant ssh agent -- curl -s localhost:9200 ; do sleep 5 ; done
.PHONY: vm
vm: plugins
vagrant status | grep running || vagrant up
.PHONY: plugins
plugins:
vagrant plugin list | grep vagrant-hosts || vagrant plugin install vagrant-hosts
vagrant plugin list | grep vagrant-auto_network || vagrant plugin install vagrant-auto_network
.PHONY: clean
clean:
vagrant destroy -f
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Required:
# vagrant: >= 2.0.0
#
# Steps:
# $ make
#
# Cleanup:
# $ make clean
Vagrant.configure 2 do |config|
config.vm.box = 'debian/jessie64'
install = <<~SCRIPT
wget -O /tmp/puppet.deb https://apt.puppetlabs.com/puppetlabs-release-pc1-jessie.deb
dpkg -i /tmp/puppet.deb
apt update
rm /tmp/puppet.deb
SCRIPT
config.vm.define :master do |node|
node.vm.hostname = 'master.local'
node.vm.network :private_network, auto_network: true
node.vm.provision :hosts
node.vm.provision(
:shell,
inline: <<-SCRIPT
#{install}
apt install -y puppetserver
echo '*.local' > /etc/puppetlabs/puppet/autosign.conf
echo 'JAVA_ARGS="-Xms256m -Xmx256m -XX:MaxPermSize=128m"' >> /etc/default/puppetserver
chmod o+w /etc/puppetlabs/code/environments/production/manifests/
/opt/puppetlabs/bin/puppet module install puppetlabs/java
/opt/puppetlabs/bin/puppet module install elastic/elasticsearch
for f in $(find /etc/puppetlabs/code/environments/production/modules/elasticsearch/lib/puppet/provider/*/*.rb)
do
sed -i '1i$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "..", ".."))' $f
done
/opt/puppetlabs/bin/puppet resource service puppetserver ensure=running enable=true
SCRIPT
)
node.vm.provision(
:file,
source: 'default.pp',
destination: '/etc/puppetlabs/code/environments/production/manifests/site.pp'
)
node.vm.provision 'puppet_server' do |puppet|
puppet.binary_path = '/opt/puppetlabs/bin'
puppet.options = %w[--waitforcert 60 --verbose]
puppet.puppet_server = 'master.local'
end
end
config.vm.define :agent do |node|
node.vm.hostname = 'agent.local'
node.vm.network :private_network, auto_network: true
node.vm.provision :hosts
node.vm.provision(
:shell,
inline: <<-SCRIPT
#{install}
echo 'deb http://ftp.debian.org/debian jessie-backports main' >> /etc/apt/sources.list
apt-get update
apt-get install -yq -t jessie-backports openjdk-8-jre-headless apt-transport-https
apt install -y puppet-agent
SCRIPT
)
node.vm.provision 'puppet_server' do |puppet|
puppet.binary_path = '/opt/puppetlabs/bin'
puppet.options = %w[--waitforcert 60 --verbose]
puppet.puppet_server = 'master.local'
end
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.