Skip to content

Commit

Permalink
fix for issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
scott coulton committed Jul 17, 2017
1 parent 44c0656 commit e1d30e6
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 95 deletions.
4 changes: 2 additions & 2 deletions Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ forge 'http://forge.puppetlabs.com'

mod 'puppetlabs/stdlib'
mod 'puppetlabs/vcsrepo'
mod 'puppet/archive'
mod 'puppet/archive', :git => 'https://github.com/voxpupuli/puppet-archive.git'
mod 'nanliu/staging'
mod 'KyleAnderson/consul', '1.0.5'
mod 'scottyc/docker_swarm'
mod 'scottyc/golang'
mod 'garethr/docker', :git => "https://github.com/scotty-c/garethr-docker.git"
mod 'garethr/docker', :git => 'https://github.com/garethr/garethr-docker.git'
mod 'stankevich/python'
mod 'stahnma/epel'
mod 'maestrodev/wget'
Expand Down
39 changes: 21 additions & 18 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
# -*- 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|

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"

puppet.options = ['--pluginsync', '--modulepath=/tmp/modules', '--verbose']
puppet.hiera_config_path = "hiera.yaml"
puppet.environment_path = './'
puppet.environment = 'production'
puppet.manifests_path = 'manifests'
puppet.manifest_file = 'default.pp'
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions modules/config/manifests/compose.pp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
class config::compose {

if $hostname =~ /^swarm-master*/ {

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

}

else {

class {'docker::compose':} ->

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

docker_compose {'swarm app':
ensure => present,
source => '/root',
scale => ['1']
docker_compose {'/root/docker-compose.yml':
ensure => present,
}
}
}
}
28 changes: 14 additions & 14 deletions modules/config/manifests/consul_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
'server' => true
}
}
}
}

else {

class { 'consul':
Expand All @@ -33,7 +33,7 @@
'server' => false
}
}
}
}

consul::service { 'docker-service':
checks => [
Expand All @@ -46,20 +46,20 @@
address => $::ipaddress_enp0s8,
}


# if $hostname =~ /^swarm-master*/ {
# consul::check { 'kibana':
# ensure => present,
# tcp => 'kibana.service.consul:80',
# ensure => present,
# tcp => 'kibana.service.consul:80',
# interval => '10s',
# }

# consul::check { 'logstash-5000':
# ensure => present,
# tcp => 'logstash-5000.service.consul:5000',
# ensure => present,
# tcp => 'logstash-5000.service.consul:5000',
# interval => '10s',
# }
# }

# consul::service { 'swarm-master-01':
# checks => [
# {
Expand All @@ -69,8 +69,8 @@
# }
# ],
# address => $::ipaddress_enp0s8,
# }
# }

# consul::service { 'swarm-master-02':
# checks => [
# {
Expand All @@ -80,6 +80,6 @@
# }
# ],
# address => $::ipaddress_enp0s8,
# }
# }
# }
}
}
11 changes: 5 additions & 6 deletions modules/config/manifests/swarm.pp
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
class config::swarm {

class { 'docker_swarm':
class { 'docker_swarm':
require => Class['config::consul_config']
}

docker_network { 'swarm-private':
ensure => present,
create => true,
driver => 'overlay',
require => Class['config::consul_config']
}

if $hostname =~ /^swarm-master*/ {

swarm_cluster {'cluster 1':
ensure => present,
backend => 'consul',
Expand All @@ -21,7 +20,7 @@
address => '172.17.8.101',
advertise => $::ipaddress_enp0s8,
path => 'swarm',
}
}
}

else {
Expand All @@ -33,6 +32,6 @@
port => '8500',
address => '172.17.8.101',
path => 'swarm'
}
}
}
}
}
95 changes: 48 additions & 47 deletions servers.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
-
box: scottyc/centos-7-puppet-kernel-4-4
---
-
#box: scottyc/centos-7-puppet-kernel-4-4
box: puppetlabs/centos-7.2-64-puppet
cpu: 1
ip: "172.17.8.101"
name: swarm-101
Expand All @@ -10,17 +11,17 @@
- { guest: 443, host: 8441 }
- { guest: 8080, host: 8081 }
ram: 4096
shell_commands:
- { shell: yum install -y git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld }
shell_commands:
- { shell: 'yum install -y rubygems ruby-devel git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld' }
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s3 && systemctl restart network'}
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: /opt/puppet/bin/gem install r10k }
- { shell: 'echo -e "172.17.8.101 swarm-101">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: cp /home/vagrant/swarm-101/Puppetfile /tmp && cd /tmp && /opt/puppet/bin/r10k puppetfile install -v }
- { shell: cp /home/vagrant/swarm-101/modules/* -R /tmp/modules }
- { shell: 'gem install puppet_forge -v 2.2.6 && gem install r10k'}
- { shell: 'echo -e "172.17.8.101 swarm-101">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: 'cp /home/vagrant/swarm-101/Puppetfile /tmp && cd /tmp && r10k puppetfile install -v' }
- { shell: 'cp /home/vagrant/swarm-101/modules/* -R /tmp/modules' }

-
box: scottyc/centos-7-puppet-kernel-4-4
-
box: puppetlabs/centos-7.2-64-puppet
cpu: 1
ip: "172.17.8.102"
name: swarm-102
Expand All @@ -30,17 +31,17 @@
- { guest: 443, host: 8442 }
- { guest: 8080, host: 8082 }
ram: 4096
shell_commands:
- { shell: yum install -y git wget curl lvm2 device-mapper-libs unzip && systemctl stop firewalld && systemctl disable firewalld }
shell_commands:
- { shell: 'yum install -y rubygems ruby-devel git wget curl lvm2 device-mapper-libs unzip && systemctl stop firewalld && systemctl disable firewalld' }
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s3 && systemctl restart network'}
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: /opt/puppet/bin/gem install r10k }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.102 swarm-102">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: cp /home/vagrant/swarm-102/Puppetfile /tmp && cd /tmp && /opt/puppet/bin/r10k puppetfile install -v }
- { shell: cp /home/vagrant/swarm-102/modules/* -R /tmp/modules }
-
box: scottyc/centos-7-puppet-kernel-4-4
- { shell: 'gem install puppet_forge -v 2.2.6 && gem install r10k' }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.102 swarm-102">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: 'cp /home/vagrant/swarm-102/Puppetfile /tmp && cd /tmp && r10k puppetfile install -v' }
- { shell: 'cp /home/vagrant/swarm-102/modules/* -R /tmp/modules' }

-
box: puppetlabs/centos-7.2-64-puppet
cpu: 1
ip: "172.17.8.103"
name: swarm-103
Expand All @@ -50,50 +51,50 @@
- { guest: 443, host: 8443 }
- { guest: 8080, host: 8083 }
ram: 4096
shell_commands:
- { shell: yum install -y git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld }
shell_commands:
- { shell: 'yum install -y rubygems ruby-devel git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld' }
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s3 && systemctl restart network'}
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: /opt/puppet/bin/gem install r10k }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.103 swarm-103">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: cp /home/vagrant/swarm-103/Puppetfile /tmp && cd /tmp && /opt/puppet/bin/r10k puppetfile install -v }
- { shell: cp /home/vagrant/swarm-103/modules/* -R /tmp/modules }
-
box: scottyc/centos-7-puppet-kernel-4-4
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: 'gem install puppet_forge -v 2.2.6 && gem install r10k' }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.103 swarm-103">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: 'cp /home/vagrant/swarm-103/Puppetfile /tmp && cd /tmp && r10k puppetfile install -v' }
- { shell: 'cp /home/vagrant/swarm-103/modules/* -R /tmp/modules' }


-
box: puppetlabs/centos-7.2-64-puppet
cpu: 1
ip: "172.17.8.114"
name: swarm-master-01
forward_ports:
- { guest: 8500, host: 9504 }
ram: 2048
shell_commands:
- { shell: yum install -y git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld }
shell_commands:
- { shell: 'yum install -y rubygems ruby-devel git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld' }
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s3 && systemctl restart network'}
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: /opt/puppet/bin/gem install r10k }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.114 swarm-master-01">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: cp /home/vagrant/swarm-master-01/Puppetfile /tmp && cd /tmp && /opt/puppet/bin/r10k puppetfile install -v }
- { shell: cp /home/vagrant/swarm-master-01/modules/* -R /tmp/modules }
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: 'gem install puppet_forge -v 2.2.6 && gem install r10k' }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.114 swarm-master-01">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: 'cp /home/vagrant/swarm-master-01/Puppetfile /tmp && cd /tmp && r10k puppetfile install -v' }
- { shell: 'cp /home/vagrant/swarm-master-01/modules/* -R /tmp/modules' }

-
box: puppetlabs/centos-7.0-64-puppet-enterprise
-
box: puppetlabs/centos-7.2-64-puppet
cpu: 1
ip: "172.17.8.115"
name: swarm-master-02
forward_ports:
- { guest: 8500, host: 9505 }
ram: 2048
shell_commands:
- { shell: yum install -y git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld }
shell_commands:
- { shell: 'yum install -y rubygems ruby-devel git wget curl lvm2 unzip device-mapper-libs && systemctl stop firewalld && systemctl disable firewalld' }
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s3 && systemctl restart network'}
- { shell: 'echo -e "PEERDNS=no\nDNS1=127.0.0.1\nDNS2=8.8.8.8">>/etc/sysconfig/network-scripts/ifcfg-enp0s8 && systemctl restart network'}
- { shell: /opt/puppet/bin/gem install r10k }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.115 swarm-master-02">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: cp /home/vagrant/swarm-master-02/Puppetfile /tmp && cd /tmp && /opt/puppet/bin/r10k puppetfile install -v }
- { shell: cp /home/vagrant/swarm-master-02/modules/* -R /tmp/modules }
- { shell: 'gem install puppet_forge -v 2.2.6 && gem install r10k' }
- { shell: 'echo -e "172.17.8.101 swarm-101\n172.17.8.115 swarm-master-02">/etc/hosts && echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc' }
- { shell: 'cp /home/vagrant/swarm-master-02/Puppetfile /tmp && cd /tmp && r10k puppetfile install -v' }
- { shell: 'cp /home/vagrant/swarm-master-02/modules/* -R /tmp/modules' }




Expand Down

0 comments on commit e1d30e6

Please sign in to comment.