Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scott coulton committed Jul 14, 2015
0 parents commit 8224804
Show file tree
Hide file tree
Showing 29 changed files with 553 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.tmp
/.vagrant/
/.DS_Store
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source "https://rubygems.org"

gem "rake"
gem "vagrant-wrapper"



12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GEM
remote: https://rubygems.org/
specs:
rake (10.3.2)
vagrant-wrapper (2.0.2)

PLATFORMS
ruby

DEPENDENCIES
rake
vagrant-wrapper
19 changes: 19 additions & 0 deletions Puppetfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/ruby env

require "socket"
$hostname = Socket.gethostname

forge 'http://forge.puppetlabs.com'


mod 'puppetlabs/stdlib'
mod 'puppetlabs/vcsrepo'
mod 'nanliu/staging'
mod 'KyleAnderson/consul'
mod 'scottyc/golang'
mod 'scottyc/docker_swarm'
mod 'garethr/docker', :git => "https://github.com/scotty-c/garethr-docker.git"
mod 'stankevich/python'
mod 'stahnma/epel'
mod 'tayzlor/weave'

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Puppet Meetup Demo
```
Prerequisites:
- Vagrant
- Ruby
```


# Install dependencies
```
git clone to a new directory
cd that directory
vagrant up
```
This will build a demo environment of 3 boxes in Docker Swarm cluster and 1 Swarm Manager. It also configurers Conul so we can monitor the cluster and contianers on the cluster.
We use weave to network between the containers and Docker compose to roll out the apps (Jenkins, Nginx, Rabitmq). This is all automated and controlled with Puppet.

Please note that this takes some time to build, almost 40 mins.

# URL
consul
````
127.0.0.1:9500
````
Jenkins
````
127.0.0.1:9808
````
Nginx
`````
127.0.0.1:5080
````
Rabitmq
````
127.0.0.1:9083
````
18 changes: 18 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "rake"
require 'bundler'
Bundler.require(:rake)
require 'rake/clean'


desc "Executes Vagrant up"
task :build do
def execute(command)
puts command
system command
end
execute "vagrant up"
end




52 changes: 52 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- mode: ruby -*-
# # vi: set ft=ruby :

# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"

# Require YAML module
require 'yaml'

# Read YAML file with box details
servers = YAML.load_file('servers.yaml')

# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Iterate through entries in YAML file
servers.each do |servers|

config.vm.define servers["name"] do |srv|

srv.vm.hostname = servers["name"]

srv.vm.box = servers["box"]

srv.vm.network "private_network", ip: servers["ip"]


servers["forward_ports"].each do |port|
srv.vm.network :forwarded_port, guest: port["guest"], host: port["host"]
end

srv.vm.provider :virtualbox do |v|
v.cpus = servers["cpu"]
v.memory = servers["ram"]
end

srv.vm.synced_folder "./", "/home/vagrant/#{servers['name']}"

servers["shell_commands"].each do |sh|
srv.vm.provision "shell", inline: sh["shell"]
end

srv.vm.provision :puppet do |puppet|
puppet.temp_dir = "/tmp"
puppet.options = ['--pluginsync', '--modulepath=/tmp/modules', '--verbose', '--debug']
puppet.hiera_config_path = "hiera.yaml"

end
end
end
end
7 changes: 7 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:backends:
- yaml
:hierarchy:
- global

:yaml:
:datadir: /vagrant/hieradata
3 changes: 3 additions & 0 deletions hieradata/global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
golang::version: go1.4.2
consul::version: 0.5.2

7 changes: 7 additions & 0 deletions manifests/default.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node 'consul-node-101' { include config }

node 'consul-node-102' { include config }

node 'consul-node-103' { include config }

node 'consul-node-104' { include config }
3 changes: 3 additions & 0 deletions modules/config/.fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixtures:
symlinks:
config: "#{source_dir}"
4 changes: 4 additions & 0 deletions modules/config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.sw[op]
/junit.xml
/spec/fixtures
/pkg
2 changes: 2 additions & 0 deletions modules/config/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--require spec_helper
--pattern spec/*/*_spec.rb
16 changes: 16 additions & 0 deletions modules/config/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source "https://rubygems.org"

gem 'rake', :group => [:development, :test]

group :development do
gem 'pry'
gem 'puppet-lint'
end

group :test do
gem 'puppet', "~> 3.4"
gem 'puppetlabs_spec_helper'
gem 'rspec', "< 2.99"
gem 'rspec-puppet'
gem 'yarjuf' #Rspec Junit formatter
end
62 changes: 62 additions & 0 deletions modules/config/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.8)
builder (3.2.2)
coderay (1.1.0)
diff-lcs (1.2.5)
facter (2.0.2)
CFPropertyList (~> 2.2.6)
hiera (1.3.4)
json_pure
json_pure (1.8.1)
metaclass (0.0.4)
method_source (0.8.2)
mocha (1.1.0)
metaclass (~> 0.0.1)
pry (0.10.0)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
puppet (3.6.2)
facter (> 1.6, < 3)
hiera (~> 1.0)
json_pure
rgen (~> 0.6.5)
puppet-lint (0.3.2)
puppetlabs_spec_helper (0.5.1)
mocha
puppet
puppet-lint
rake
rspec
rspec-puppet
rake (10.3.2)
rgen (0.6.6)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-puppet (1.0.1)
rspec
slop (3.5.0)
yarjuf (1.0.5)
builder
rspec (>= 2.0)

PLATFORMS
ruby

DEPENDENCIES
pry
puppet (~> 3.4)
puppet-lint
puppetlabs_spec_helper
rake
rspec (< 2.99)
rspec-puppet
yarjuf
21 changes: 21 additions & 0 deletions modules/config/Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name 'scottyc-config'
version '0.1.0'

author 'scottyc'
summary 'config module'
description 'config module'
project_page 'https://stash.healthdirect.org.au/projects/puppet/repos/config'

# Add dependencies here, if any (NB: Must be in the form 'author/modulename')

dependency 'puppetlabs/stdlib'
dependency 'puppetlabs/vcsrepo'
dependency 'nanliu/staging'
dependency 'KyleAnderson/consul'
dependency 'scottyc/golang'
dependency 'scottyc/docker_swarm'
dependency 'garethr/docker'
dependency 'scottc/config'
dependency 'stankevich/python'
dependency 'stahnma/epel'
dependency 'tayzlor/weave'
3 changes: 3 additions & 0 deletions modules/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# config

Demo Puppet Meetup
14 changes: 14 additions & 0 deletions modules/config/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'rake'

require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
require 'rspec/core/rake_task'
require 'puppet-lint'

PuppetLint.configuration.send('disable_autoloader_layout')

RSpec::Core::RakeTask.new(:ci) do |task|
task.rspec_opts = "--format JUnit --out junit.xml"
end

task :ci => :spec_prep
46 changes: 46 additions & 0 deletions modules/config/manifests/compose.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
class config::compose {

if $hostname =~ /^*104*$/ {

notice ["This server is the Swarm Manager."]

}

else {

$ip = $::hostname ? {
/.*101$/ => '10.0.1.10/24',
/.*102$/ => '10.0.1.20/24',
/.*103$/ => '10.0.1.30/24',
}

class { 'weave':
peers => ['172.17.8.101','172.17.8.103','172.17.8.103'],
expose => $ip,
client_ip => $::ipaddress_enp0s8,
require => Service['docker']
}

$erb = $::hostname ? {
/.*101$/ => 'jenkins.yml',
/.*102$/ => 'nginx.yml',
/.*103$/ => 'rabbitmq.yml',
}

docker::image { 'jenkins':} ->
docker::image { 'nginx':} ->
docker::image { 'gliderlabs/registrator':} ->
docker::image {'rabbitmq:3-management':} ->

file { '/root/docker-compose.yml':
ensure => file,
content => template("config/$erb.erb"),
} ->

docker_compose {'swarm app':
ensure => present,
source => '/root',
scale => ['1']
}
}
}
Loading

0 comments on commit 8224804

Please sign in to comment.