From e1d30e6710a9e1397ba12b6ec1ddf0c4c9ef4f94 Mon Sep 17 00:00:00 2001 From: scott coulton Date: Mon, 17 Jul 2017 11:21:22 +1000 Subject: [PATCH] fix for issue #2 --- Puppetfile | 4 +- Vagrantfile | 39 +++++----- modules/config/manifests/compose.pp | 16 ++-- modules/config/manifests/consul_config.pp | 28 +++---- modules/config/manifests/swarm.pp | 11 ++- servers.yaml | 95 ++++++++++++----------- 6 files changed, 98 insertions(+), 95 deletions(-) diff --git a/Puppetfile b/Puppetfile index b59028f..1ac06e1 100644 --- a/Puppetfile +++ b/Puppetfile @@ -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' diff --git a/Vagrantfile b/Vagrantfile index 872cbaa..c7930ee 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,33 +1,33 @@ # -*- 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 @@ -35,18 +35,21 @@ servers.each do |servers| 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 diff --git a/modules/config/manifests/compose.pp b/modules/config/manifests/compose.pp index 19148da..4d944d6 100644 --- a/modules/config/manifests/compose.pp +++ b/modules/config/manifests/compose.pp @@ -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, } } -} \ No newline at end of file +} diff --git a/modules/config/manifests/consul_config.pp b/modules/config/manifests/consul_config.pp index 798e5b5..4a2d4db 100644 --- a/modules/config/manifests/consul_config.pp +++ b/modules/config/manifests/consul_config.pp @@ -15,8 +15,8 @@ 'server' => true } } - } - + } + else { class { 'consul': @@ -33,7 +33,7 @@ 'server' => false } } - } + } consul::service { 'docker-service': checks => [ @@ -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 => [ # { @@ -69,8 +69,8 @@ # } # ], # address => $::ipaddress_enp0s8, -# } - +# } + # consul::service { 'swarm-master-02': # checks => [ # { @@ -80,6 +80,6 @@ # } # ], # address => $::ipaddress_enp0s8, -# } +# } # } - } \ No newline at end of file + } diff --git a/modules/config/manifests/swarm.pp b/modules/config/manifests/swarm.pp index 5b2efdc..3756233 100644 --- a/modules/config/manifests/swarm.pp +++ b/modules/config/manifests/swarm.pp @@ -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', @@ -21,7 +20,7 @@ address => '172.17.8.101', advertise => $::ipaddress_enp0s8, path => 'swarm', - } + } } else { @@ -33,6 +32,6 @@ port => '8500', address => '172.17.8.101', path => 'swarm' - } + } } -} \ No newline at end of file +} diff --git a/servers.yaml b/servers.yaml index 413f08f..a8d2e42 100644 --- a/servers.yaml +++ b/servers.yaml @@ -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 @@ -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 @@ -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 @@ -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' } +