bitswarmbox 1.0.0.pre16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +70 -0
  3. data/.idea/.rakeTasks +7 -0
  4. data/.idea/compiler.xml +22 -0
  5. data/.idea/composerJson.xml +9 -0
  6. data/.idea/copyright/profiles_settings.xml +3 -0
  7. data/.idea/misc.xml +23 -0
  8. data/.idea/modules.xml +8 -0
  9. data/.ruby-version +1 -0
  10. data/.travis.yml +3 -0
  11. data/Gemfile +3 -0
  12. data/LICENSE +21 -0
  13. data/README.md +67 -0
  14. data/Rakefile +34 -0
  15. data/Vagrantfile +116 -0
  16. data/bin/bitswarmbox +6 -0
  17. data/bitswarmbox.gemspec +48 -0
  18. data/bitswarmbox.iml +51 -0
  19. data/builders/aws/build-all.sh +17 -0
  20. data/builders/aws/debian/build-base-jessie64.sh +11 -0
  21. data/builders/aws/debian/build-base-wheezy64.sh +11 -0
  22. data/builders/aws/debian/build-puppetmaster-jessie64.sh +11 -0
  23. data/builders/aws/ubuntu/build-base-precise64.sh +11 -0
  24. data/builders/aws/ubuntu/build-base-trusty64.sh +11 -0
  25. data/builders/aws/ubuntu/build-base-wily64.sh +11 -0
  26. data/builders/aws/ubuntu/build-base-xenial64.sh +11 -0
  27. data/builders/aws/ubuntu/build-puppetmaster-trusty64.sh +11 -0
  28. data/builders/aws/ubuntu/build-puppetmaster-xenial64.sh +11 -0
  29. data/builders/vagrant/build-all.sh +18 -0
  30. data/builders/vagrant/debian/build-base-jessie64.sh +9 -0
  31. data/builders/vagrant/debian/build-base-wheezy64.sh +9 -0
  32. data/builders/vagrant/debian/build-puppetmaster-jessie64.sh +9 -0
  33. data/builders/vagrant/ubuntu/build-base-precise64.sh +9 -0
  34. data/builders/vagrant/ubuntu/build-base-trusty64.sh +9 -0
  35. data/builders/vagrant/ubuntu/build-base-wily64.sh +9 -0
  36. data/builders/vagrant/ubuntu/build-base-xenial64.sh +9 -0
  37. data/builders/vagrant/ubuntu/build-puppetmaster-trusty64.sh +17 -0
  38. data/builders/vagrant/ubuntu/build-puppetmaster-xenial64.sh +17 -0
  39. data/features/boxes.feature +8 -0
  40. data/features/build.feature +16 -0
  41. data/features/env.feature +18 -0
  42. data/features/support/env.rb +1 -0
  43. data/lib/bitswarmbox/builder.rb +181 -0
  44. data/lib/bitswarmbox/command/build/aws.rb +90 -0
  45. data/lib/bitswarmbox/command/build/vagrant.rb +78 -0
  46. data/lib/bitswarmbox/command/build.rb +42 -0
  47. data/lib/bitswarmbox/command/env.rb +50 -0
  48. data/lib/bitswarmbox/command.rb +15 -0
  49. data/lib/bitswarmbox/config.rb +87 -0
  50. data/lib/bitswarmbox/environment.rb +128 -0
  51. data/lib/bitswarmbox/errors.rb +19 -0
  52. data/lib/bitswarmbox/subprocess.rb +39 -0
  53. data/lib/bitswarmbox/template.rb +50 -0
  54. data/lib/bitswarmbox/version.rb +4 -0
  55. data/lib/bitswarmbox.rb +29 -0
  56. data/lib/boxes.rb +29 -0
  57. data/puppet/Puppetfile +58 -0
  58. data/puppet/environments/aws/manifests/base.pp +3 -0
  59. data/puppet/environments/vagrant/environment.conf +1 -0
  60. data/puppet/environments/vagrant/manifests/base.pp +3 -0
  61. data/puppet/hiera.yaml +15 -0
  62. data/puppet/hieradata/aws.yaml +11 -0
  63. data/puppet/hieradata/common.yaml +9 -0
  64. data/puppet/hieradata/debian.yaml +6 -0
  65. data/puppet/hieradata/puppetmaster.yaml +7 -0
  66. data/puppet/hieradata/ubuntu.yaml +3 -0
  67. data/puppet/hieradata/vagrant.yaml +3 -0
  68. data/puppet/hieradata/vsphere.yaml +3 -0
  69. data/puppet/manifests/r10k_bootstrap.pp +37 -0
  70. data/puppet/modules/packer/manifests/aws/cloudinit.pp +20 -0
  71. data/puppet/modules/packer/manifests/aws/networking/params.pp +46 -0
  72. data/puppet/modules/packer/manifests/aws/networking.pp +23 -0
  73. data/puppet/modules/packer/manifests/aws/sshd.pp +10 -0
  74. data/puppet/modules/packer/manifests/aws/users.pp +26 -0
  75. data/puppet/modules/packer/manifests/aws.pp +7 -0
  76. data/puppet/modules/packer/manifests/clock.pp +10 -0
  77. data/puppet/modules/packer/manifests/updates.pp +27 -0
  78. data/puppet/modules/packer/manifests/vagrant/params.pp +14 -0
  79. data/puppet/modules/packer/manifests/vagrant.pp +63 -0
  80. data/puppet/modules/packer/manifests/vmtools/params.pp +35 -0
  81. data/puppet/modules/packer/manifests/vmtools.pp +52 -0
  82. data/puppet/modules/packer/manifests/vsphere/fw.pp +9 -0
  83. data/puppet/modules/packer/manifests/vsphere/networking.pp +29 -0
  84. data/puppet/modules/packer/manifests/vsphere/params.pp +56 -0
  85. data/puppet/modules/packer/manifests/vsphere/repos.pp +87 -0
  86. data/puppet/modules/packer/manifests/vsphere.pp +45 -0
  87. data/puppet/modules/packer/templates/ec2/ubuntu-cloud-cfg.erb +111 -0
  88. data/puppet/modules/packer/templates/vsphere/debian.rb.erb +45 -0
  89. data/puppet/modules/packer/templates/vsphere/rc.local +5 -0
  90. data/puppet/modules/packer/templates/vsphere/redhat.rb.erb +66 -0
  91. data/puppet/modules/packer/templates/vsphere/ubuntu.rb.erb +50 -0
  92. data/scripts/ansible.sh +17 -0
  93. data/scripts/chef.sh +30 -0
  94. data/scripts/cleanup-aws.sh +6 -0
  95. data/scripts/cleanup-vagrant.sh +26 -0
  96. data/scripts/cleanup.sh +48 -0
  97. data/scripts/docker.sh +23 -0
  98. data/scripts/local-ssh-keygen.sh +16 -0
  99. data/scripts/prepare-done.sh +3 -0
  100. data/scripts/prepare.sh +32 -0
  101. data/scripts/puppet.sh +31 -0
  102. data/scripts/puppetserver-post.sh +8 -0
  103. data/scripts/puppetserver.sh +44 -0
  104. data/scripts/ruby.sh +42 -0
  105. data/scripts/vagrant.sh +42 -0
  106. data/scripts/vmtools.sh +37 -0
  107. data/spec/boxes/builder_spec.rb +52 -0
  108. data/spec/boxes/config_spec.rb +142 -0
  109. data/spec/boxes/environment_spec.rb +73 -0
  110. data/spec/boxes/subprocess_spec.rb +35 -0
  111. data/spec/boxes/template_spec.rb +53 -0
  112. data/spec/spec_helper.rb +5 -0
  113. data/spec/support/subprocess_command.rb +7 -0
  114. data/templates/debian/jessie64.erb +206 -0
  115. data/templates/debian/preseed.cfg +70 -0
  116. data/templates/debian/wheezy64.erb +206 -0
  117. data/templates/ubuntu/precise64.erb +205 -0
  118. data/templates/ubuntu/preseed.cfg +61 -0
  119. data/templates/ubuntu/trusty64.erb +205 -0
  120. data/templates/ubuntu/wily64.erb +209 -0
  121. data/templates/ubuntu/xenial64.erb +209 -0
  122. metadata +349 -0
@@ -0,0 +1,87 @@
1
+ module BitswarmBox
2
+ # Stores the configuration for BitswarmBox.
3
+ class Config
4
+ # The default settings for the configuration.
5
+ DEFAULTS = {
6
+ environment_vars: [
7
+ { 'PACKER_CACHE_DIR' => (
8
+ Pathname.new(ENV['BOXES_HOME_DIR'] || '~/.bitswarmbox'
9
+ ).expand_path + 'packer_cache')
10
+ },
11
+ { 'AWS_ACCESS_KEY_ID' => ENV['AWS_ACCESS_KEY_ID'] },
12
+ { 'AWS_SECRET_ACCESS_KEY' => ENV['AWS_SECRET_ACCESS_KEY'] },
13
+ { 'AWS_DEFAULT_REGION' => ENV['AWS_DEFAULT_REGION'] },
14
+ ],
15
+ template_paths: [
16
+ # the gem install directory
17
+ File.expand_path('../../../templates', __FILE__)
18
+ ],
19
+ script_paths: [
20
+ # the gem install directory
21
+ File.expand_path('../../../scripts', __FILE__)
22
+ ],
23
+ puppet_lib_paths: [
24
+ # the gem install directory
25
+ File.expand_path('../../../puppet', __FILE__)
26
+ ],
27
+ ssh_key_paths: [
28
+ # the gem install directory
29
+ File.expand_path('../../../keys', __FILE__)
30
+ ]
31
+ }
32
+
33
+ # The directory which bitswarmbox works out of.
34
+ def home_dir
35
+ @home_dir ||= Pathname.new(
36
+ ENV['BOXES_HOME_DIR'] || '~/.bitswarmbox').expand_path
37
+ end
38
+
39
+ # The directory inside the `home_dir` which bitswarmbox runs builds inside of.
40
+ def working_dir
41
+ @working_dir ||= Pathname.new(
42
+ ENV['BOXES_WORKING_DIR'] || home_dir + 'tmp').expand_path
43
+ end
44
+
45
+ # Paths known to bitswarmbox for discovering templates.
46
+ attr_accessor :template_paths
47
+
48
+ # Paths known to bitswarmbox for discovering scripts.
49
+ attr_accessor :script_paths
50
+
51
+ attr_accessor :puppet_lib_paths, :ssh_key_paths
52
+
53
+ # A Hash of environment variables BitswarmBox sets in the run environment.
54
+ attr_accessor :environment_vars
55
+
56
+ def initialize
57
+ configure_with(DEFAULTS)
58
+
59
+ return unless user_settings_file.exist?
60
+
61
+ user_settings = YAML.load_file(user_settings_file)
62
+ configure_with(user_settings)
63
+ end
64
+
65
+ private
66
+
67
+ def user_settings_file
68
+ home_dir + 'config.yml'
69
+ end
70
+
71
+ def configure_with(opts = {}) # rubocop:disable Metrics/MethodLength
72
+ opts.each do |k, v|
73
+ next unless respond_to?("#{k}=")
74
+
75
+ if v.class == Array
76
+ v.each do |e|
77
+ set = Set.new(send("#{k}".to_sym))
78
+ set << e
79
+ send("#{k}=".to_sym, set.to_a)
80
+ end
81
+ else
82
+ send("#{k}=".to_sym, v)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,128 @@
1
+ require "rsync"
2
+
3
+ module BitswarmBox
4
+ # For creating and managing the environment which bitswarmbox uses.
5
+ class Environment
6
+ def initialize
7
+ FileUtils.mkdir_p(BitswarmBox.config.working_dir)
8
+
9
+ sync_templates
10
+ sync_scripts
11
+ sync_puppet
12
+ sync_ssh_keys
13
+ end
14
+
15
+ def available_templates
16
+ t = Dir.glob("#{BitswarmBox.config.working_dir}/templates/*/**")
17
+ a = t.collect { |c| c.include?('preseed.cfg') ? next : c }.compact
18
+
19
+ a.collect do |c|
20
+ c = c.gsub(BitswarmBox.config.working_dir.to_s + '/templates/', '')
21
+ c.gsub('.erb', '')
22
+ end
23
+ end
24
+
25
+ def hidden_templates
26
+ t = Dir.glob("#{BitswarmBox.config.working_dir}/templates/*/**")
27
+ a = t.collect { |c| c.include?('preseed.cfg') ? c : next }.compact
28
+
29
+ a.collect do |c|
30
+ c.gsub(BitswarmBox.config.working_dir.to_s + '/templates/', '')
31
+ end
32
+ end
33
+
34
+ def available_scripts
35
+ t = Dir.glob("#{BitswarmBox.config.working_dir}/scripts/*")
36
+ a = t.collect { |c| c.include?('purge.sh') ? next : c }.compact
37
+
38
+ a.collect do |c|
39
+ c.gsub(BitswarmBox.config.working_dir.to_s + '/scripts/', '')
40
+ end
41
+ end
42
+
43
+ def hidden_scripts
44
+ t = Dir.glob("#{BitswarmBox.config.working_dir}/scripts/*")
45
+ a = t.collect { |c| c.include?('purge.sh') ? c : next }.compact
46
+
47
+ a.collect do |c|
48
+ c.gsub(BitswarmBox.config.working_dir.to_s + '/scripts/', '')
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def sync_templates
55
+ BitswarmBox.config.template_paths.each do |template_path|
56
+ Rsync.run(template_path, BitswarmBox.config.working_dir, ['-av', '--delete']) do |result|
57
+ if result.success?
58
+ result.changes.each do |change|
59
+ puts "#{change.filename} (#{change.summary})"
60
+ end
61
+ else
62
+ fail BuildRunError, result.error
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ def sync_scripts
69
+ BitswarmBox.config.script_paths.each do |script_path|
70
+ Rsync.run(script_path, BitswarmBox.config.working_dir, ['-av', '--delete']) do |result|
71
+ if result.success?
72
+ result.changes.each do |change|
73
+ puts "#{change.filename} (#{change.summary})"
74
+ end
75
+ else
76
+ fail BuildRunError, result.error
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ def sync_puppet
83
+ BitswarmBox.config.puppet_lib_paths.each do |puppet_path|
84
+ Rsync.run(puppet_path, BitswarmBox.config.working_dir, ['-av', '--delete']) do |result|
85
+ if result.success?
86
+ result.changes.each do |change|
87
+ puts "#{change.filename} (#{change.summary})"
88
+ end
89
+ else
90
+ fail BuildRunError, result.error
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ public
97
+
98
+ def sync_ssh_keys(reverse = false)
99
+ key_dir = BitswarmBox.config.working_dir + 'keys'
100
+
101
+ FileUtils.mkdir_p(key_dir)
102
+
103
+ BitswarmBox.config.ssh_key_paths.each do |key_path|
104
+ if reverse
105
+ Rsync.run(key_dir, File.expand_path("#{key_path}/.."), ['-av']) do |result|
106
+ if result.success?
107
+ result.changes.each do |change|
108
+ puts "#{change.filename} (#{change.summary})"
109
+ end
110
+ else
111
+ fail BuildRunError, result.error
112
+ end
113
+ end
114
+ else
115
+ Rsync.run(key_path, BitswarmBox.config.working_dir, ['-av', '--delete']) do |result|
116
+ if result.success?
117
+ result.changes.each do |change|
118
+ puts "#{change.filename} (#{change.summary})"
119
+ end
120
+ else
121
+ fail BuildRunError, result.error
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,19 @@
1
+ module BitswarmBox
2
+ # A collection of errors which can be raised by bitswarmbox.
3
+ module Errors
4
+ # Base error class for all other errors.
5
+ class BitswarmBoxError < StandardError; end
6
+
7
+ # Raised when a template is missing.
8
+ class TemplateNotFoundError < BitswarmBoxError; end
9
+
10
+ # Raised when a script is missing.
11
+ class ScriptNotFoundError < BitswarmBoxError; end
12
+
13
+ # Raised when an expected argument is missing.
14
+ class MissingArgumentError < BitswarmBoxError; end
15
+
16
+ # Raised when a build fails.
17
+ class BuildRunError < BitswarmBoxError; end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ module BitswarmBox
2
+ # Standardise handling the stdout and stderr from Open3.
3
+ #
4
+ # @example Print the values returned to stdout and stderr
5
+ # BitswarmBox::Utils::Subprocess.run 'ls' do |stdout, stderr, thread|
6
+ # puts stdout unless stdout == nil
7
+ # puts stderr unless stderr == nil
8
+ # end
9
+ #
10
+ class Subprocess
11
+ # Create a new subprocess with a command, with a block for the response.
12
+ #
13
+ # @param cmd [String] the command to run
14
+ # @yield [stdout, stderr, thread] Gives the stdout, stderr and process
15
+ # thread to the block.
16
+ def self.run(command) # rubocop:disable Metrics/MethodLength
17
+ # see: http://stackoverflow.com/a/1162850/83386
18
+ Open3.popen3(command) do |_stdin, stdout, stderr, thread|
19
+ # read each stream from a new thread
20
+ { out: stdout, err: stderr }.each do |key, stream|
21
+ Thread.new do
22
+ stream.each_line do |line|
23
+ # yield the block depending on the stream
24
+ if key == :out
25
+ yield line, nil, thread if block_given?
26
+ else
27
+ yield nil, line, thread if block_given?
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ thread.join # don't exit until the external process is done
34
+
35
+ thread.value
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ module BitswarmBox
2
+ # Representations of Packer templates.
3
+ class Template
4
+ include BitswarmBox::Errors
5
+
6
+ attr_reader :name, :template
7
+
8
+ # Load a template with a given name.
9
+ #
10
+ # @param env [BitswarmBox::Environment] the environment to source templates.
11
+ # @param name [String] the name of the template.
12
+ #
13
+ # @return [BitswarmBox::Template] a template instance.
14
+ def initialize(env, name)
15
+ fail(TemplateNotFoundError) unless env.available_templates.include?(name)
16
+
17
+ @name = name
18
+ @template = ''
19
+ File.open(BitswarmBox.config.working_dir + "templates/#{name}.erb") do |f|
20
+ @template << f.read
21
+ end
22
+ end
23
+
24
+ # Render the template.
25
+ #
26
+ # @param args [Hash] the values to set.
27
+ #
28
+ # @return [String] the rendered template.
29
+ def render(args)
30
+ ERB.new(template, nil, '-').result(ERBContext.new(args).get_binding)
31
+ end
32
+
33
+ # A context to render inside, to avoid polluting other classes.
34
+ class ERBContext
35
+ # Create a new context with a given hash of values.
36
+ #
37
+ # @params args [Hash] the values to substitute.
38
+ def initialize(args = {})
39
+ args.each_pair do |k, v|
40
+ instance_variable_set('@' + k.to_s, v)
41
+ end
42
+ end
43
+
44
+ # The binding which is passed to ERB.
45
+ def get_binding # rubocop:disable Style/AccessorMethodName
46
+ binding
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,4 @@
1
+ # Versions and other declarations.
2
+ module BitswarmBox
3
+ VERSION = "1.0.0.pre16".freeze
4
+ end
@@ -0,0 +1,29 @@
1
+ require 'set'
2
+ require 'fileutils'
3
+ require 'pathname'
4
+ require 'yaml'
5
+ require 'open3'
6
+ require 'erb'
7
+
8
+ require 'claide'
9
+ require 'colored'
10
+
11
+ require 'bitswarmbox/version'
12
+ require 'bitswarmbox/errors'
13
+ require 'bitswarmbox/config'
14
+ require 'bitswarmbox/subprocess'
15
+ require 'bitswarmbox/environment'
16
+ require 'bitswarmbox/template'
17
+ require 'bitswarmbox/builder'
18
+ require 'bitswarmbox/command'
19
+
20
+ # Toolkit for building Vagrantboxes, VM and cloud images.
21
+ module BitswarmBox
22
+ class << self
23
+ attr_reader :config
24
+
25
+ def config
26
+ @config ||= Config.new
27
+ end
28
+ end
29
+ end
data/lib/boxes.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'set'
2
+ require 'fileutils'
3
+ require 'pathname'
4
+ require 'yaml'
5
+ require 'open3'
6
+ require 'erb'
7
+
8
+ require 'claide'
9
+ require 'colored'
10
+
11
+ require 'boxes/version'
12
+ require 'boxes/errors'
13
+ require 'boxes/config'
14
+ require 'boxes/subprocess'
15
+ require 'boxes/environment'
16
+ require 'boxes/template'
17
+ require 'boxes/builder'
18
+ require 'boxes/command'
19
+
20
+ # Toolkit for building Vagrantboxes, VM and cloud images.
21
+ module Boxes
22
+ class << self
23
+ attr_reader :config
24
+
25
+ def config
26
+ @config ||= Config.new
27
+ end
28
+ end
29
+ end
data/puppet/Puppetfile ADDED
@@ -0,0 +1,58 @@
1
+ forge 'http://forge.puppetlabs.com'
2
+
3
+ mod 'bitswarmlabs/bsl_puppet',
4
+ :git => 'https://github.com/bitswarmlabs/puppet-bsl_puppet.git',
5
+ :tag => '0.6.7'
6
+
7
+ mod 'bitswarmlabs/bsl_bootstrap',
8
+ :git => 'https://github.com/bitswarmlabs/puppet-bsl_bootstrap.git',
9
+ :tag => '0.6.7'
10
+
11
+ mod 'bitswarmlabs/aws',
12
+ :git => 'https://github.com/bitswarmlabs/puppetlabs-aws.git',
13
+ :tag => '1.4.0'
14
+
15
+ mod 'abrader/gms', '1.0.2'
16
+ mod 'adrien/alternatives', '0.3.0'
17
+ mod 'arnoudj/sudo', '1.3.0'
18
+ mod 'bitswarmlabs/ohmyzsh', :git => 'https://github.com/bitswarmlabs/puppet-ohmyzsh.git'
19
+ mod 'bryana/ec2tagfacts', '0.1.18'
20
+ mod 'conjur/conjur', '0.0.4'
21
+ mod 'croddy/make', '0.0.5'
22
+ mod 'garethr/docker', '5.2.0'
23
+ mod 'gentoo/portage', '2.3.0'
24
+ mod 'herculesteam/augeasproviders_core', '2.1.2'
25
+ mod 'herculesteam/augeasproviders_ssh', '2.5.0'
26
+ mod 'hunner/hiera', '2.0.1'
27
+ mod 'jamtur01/httpauth', '0.0.3'
28
+ mod 'jethrocarr/hostname', '1.0.2'
29
+ mod 'maestrodev/wget', '1.7.3'
30
+ mod 'puppet/extlib', '0.11.3'
31
+ mod 'puppet/puppetboard', '2.8.2'
32
+ mod 'puppetlabs/apache', '1.10.0'
33
+ mod 'puppetlabs/apt', '2.2.2'
34
+ mod 'puppetlabs/concat', '2.1.0'
35
+ mod 'puppetlabs/docker_platform', '2.1.0'
36
+ mod 'puppetlabs/firewall', '1.8.1'
37
+ mod 'puppetlabs/gcc', '0.3.0'
38
+ mod 'puppetlabs/git', '0.4.0'
39
+ mod 'puppetlabs/inifile', '1.5.0'
40
+ mod 'puppetlabs/java', '1.5.0'
41
+ mod 'puppetlabs/ntp', '4.2.0'
42
+ mod 'puppetlabs/pe_gem', '0.2.0'
43
+ mod 'puppetlabs/postgresql', '4.7.1'
44
+ mod 'puppetlabs/puppetdb', '5.1.2'
45
+ mod 'puppetlabs/reboot', '1.2.1'
46
+ mod 'puppetlabs/ruby', '0.5.0'
47
+ mod 'puppetlabs/stdlib', '4.12.0'
48
+ mod 'puppetlabs/vcsrepo', '1.3.2'
49
+ mod 'puppetlabs/xinetd', '2.0.0'
50
+ mod 'saz/rsyslog', '3.5.1'
51
+ mod 'saz/ssh', '2.8.1'
52
+ mod 'saz/timezone', '3.3.0'
53
+ mod 'stahnma/epel', '1.2.2'
54
+ mod 'stankevich/python', '1.12.0'
55
+ mod 'theforeman/foreman', '5.2.0'
56
+ mod 'theforeman/puppet', '5.0.0'
57
+ mod 'theforeman/tftp', '1.8.1'
58
+ mod 'zack/r10k', '3.2.0'
@@ -0,0 +1,3 @@
1
+ hiera_include('classes')
2
+
3
+ include bsl_puppet::agent
@@ -0,0 +1 @@
1
+ modulepath = /vagrant/puppet/modules:/etc/puppetlabs/code/environments/vagrant/modules:/etc/puppetlabs/code/environments/common/modules:/etc/puppetlabs/code/environments/common/dist:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules
@@ -0,0 +1,3 @@
1
+ hiera_include('classes')
2
+
3
+ include bsl_puppet::agent
data/puppet/hiera.yaml ADDED
@@ -0,0 +1,15 @@
1
+ # Hiera config file used by Packer provisioner.
2
+ ---
3
+ :logger: console
4
+ :backends:
5
+ - yaml
6
+ :hierarchy:
7
+ - "common"
8
+ - "%{::provisioner}"
9
+ - "%{::environment}"
10
+ - "%{::osfamily}"
11
+ - "%{::app_project}"
12
+ - "local"
13
+ :yaml:
14
+ :datadir: "/tmp/hieradata"
15
+ :merge_behavior: deeper
@@ -0,0 +1,11 @@
1
+ ---
2
+ classes:
3
+ - packer::aws
4
+ - packer::aws::networking
5
+ - packer::aws::users
6
+ # - packer::ec2::cloudinit
7
+ # - packer::ec2::sshd
8
+
9
+ packer::aws::users::ohmyzsh: true
10
+ ohmyzsh::plugins:
11
+ - aws
@@ -0,0 +1,9 @@
1
+ ---
2
+ classes:
3
+ - packer::updates
4
+ - packer::clock
5
+
6
+ puppetmaster: 'puppet'
7
+
8
+ hello_worlds:
9
+ - "hello from Packer's hieradata/common.yaml"
@@ -0,0 +1,6 @@
1
+ ---
2
+ packer::aws::local_service_acct_user: 'admin'
3
+ packer::aws::local_service_acct_gecos: 'Admin'
4
+
5
+ ohmyzsh::plugins:
6
+ - debian
@@ -0,0 +1,7 @@
1
+ ---
2
+ classes:
3
+ - bsl_bootstrap::puppetmaster::prepare
4
+ - bsl_bootstrap::puppetmaster::setup
5
+
6
+ hello_worlds:
7
+ - "hello from Packer's hieradata/puppetmaster.yaml"
@@ -0,0 +1,3 @@
1
+ ---
2
+ ohmyzsh::plugins:
3
+ - ubuntu
@@ -0,0 +1,3 @@
1
+ ---
2
+ classes:
3
+ - packer::vagrant
@@ -0,0 +1,3 @@
1
+ ---
2
+ classes:
3
+ - packer::vsphere
@@ -0,0 +1,37 @@
1
+ class r10k_bootstrap(
2
+ $project = "${::app_project}",
3
+ ) {
4
+ notify { "## Bootstrapping r10k and local Puppet module library": }
5
+
6
+ package { 'r10k':
7
+ provider => puppet_gem,
8
+ ensure => installed
9
+ }
10
+ ->
11
+ file { '/usr/bin/r10k':
12
+ ensure => link,
13
+ target => '/opt/puppetlabs/puppet/bin/r10k',
14
+ force => true,
15
+ }
16
+
17
+ if $project == 'puppetmaster' {
18
+ $data_root = '/etc/puppetlabs/code'
19
+ }
20
+ else {
21
+ $data_root = '/opt/puppetlabs/puppet'
22
+ }
23
+
24
+ file { "${data_root}/Puppetfile":
25
+ ensure => file,
26
+ source => '/tmp/Puppetfile',
27
+ }
28
+ ~>
29
+ exec { 'r10k puppetfile install -v':
30
+ logoutput => true,
31
+ refreshonly => true,
32
+ cwd => $data_root,
33
+ path => '/usr/bin:/bin',
34
+ }
35
+ }
36
+
37
+ include 'r10k_bootstrap'
@@ -0,0 +1,20 @@
1
+ class packer::aws::cloudinit {
2
+ include '::packer::aws'
3
+
4
+ $distro = $::operatingsystem ? {
5
+ /(RedHat|CentOS|Fedora|Scientific|SL|SLC|Ascendos|CloudLinux|PSBM|OracleLinux|OVS|OEL|Amazon|XenServer)/ => 'redhat',
6
+ 'Debian' => 'debian',
7
+ 'Ubuntu' => 'ubuntu',
8
+ 'Archlinux' => 'archlinux',
9
+ 'Gentoo' => 'gentoo',
10
+ }
11
+
12
+ file { '/etc/cloud':
13
+ ensure => directory,
14
+ }
15
+
16
+ file { '/etc/cloud/cloud.cfg':
17
+ ensure => file,
18
+ content => template("packer/ec2/${distro}-cloud-cfg.erb")
19
+ }
20
+ }
@@ -0,0 +1,46 @@
1
+ class packer::aws::networking::params {
2
+
3
+ case $::osfamily {
4
+ debian: {
5
+ $udev_rule = '/etc/udev/rules.d/70-persistent-net.rules'
6
+ $udev_rule_gen = '/lib/udev/rules.d/75-persistent-net-generator.rules'
7
+ }
8
+
9
+ redhat: {
10
+ case $::operatingsystemrelease {
11
+ '7.0.1406', '7.1.1503', '7.2.1511', '7.2': {
12
+ case $::provisioner {
13
+ 'virtualbox': { $interface_script = '/etc/sysconfig/network-scripts/ifcfg-enp0s3' }
14
+ 'vmware': { $interface_script = '/etc/sysconfig/network-scripts/ifcfg-ens33' }
15
+ }
16
+
17
+ $udev_rule = '/etc/udev/rules.d/70-persistent-net.rules'
18
+ $udev_rule_gen = '/lib/udev/rules.d/75-persistent-net-generator.rules'
19
+ }
20
+
21
+ '5.11': {
22
+ $interface_script = '/etc/sysconfig/network-scripts/ifcfg-eth0'
23
+ $udev_rule = '/etc/udev/rules.d/70-persistent-net.rules'
24
+ }
25
+
26
+ '21', '22', '23': {
27
+ case $::provisioner {
28
+ 'virtualbox': { $interface_script = '/etc/sysconfig/network-scripts/ifcfg-enp0s3' }
29
+ 'vmware': { $interface_script = '/etc/sysconfig/network-scripts/ifcfg-ens33' }
30
+ }
31
+ }
32
+
33
+ default: {
34
+ $interface_script = '/etc/sysconfig/network-scripts/ifcfg-eth0'
35
+ $udev_rule = '/etc/udev/rules.d/70-persistent-net.rules'
36
+ $udev_rule_gen = '/lib/udev/rules.d/75-persistent-net-generator.rules'
37
+ }
38
+ }
39
+ }
40
+
41
+ default: {
42
+ fail( "Unsupported platform: ${::osfamily}/${::operatingsystem}" )
43
+ }
44
+ }
45
+
46
+ }
@@ -0,0 +1,23 @@
1
+ class packer::aws::networking inherits packer::aws::networking::params {
2
+ if ( $udev_rule != undef ) {
3
+ file { $udev_rule:
4
+ ensure => absent,
5
+ }
6
+ }
7
+
8
+ if ( $udev_rule_gen != undef ) {
9
+ file { $udev_rule_gen:
10
+ ensure => link,
11
+ target => '/dev/null',
12
+ }
13
+ }
14
+
15
+ if ( $interface_script != undef ) {
16
+ file_line { "remove ${interface_script} hwaddr":
17
+ path => $interface_script,
18
+ line => '#HWADDR withheld',
19
+ match => 'HWADDR',
20
+ }
21
+ }
22
+
23
+ }
@@ -0,0 +1,10 @@
1
+ class packer::aws::sshd {
2
+
3
+ class { 'ssh::server':
4
+ storeconfigs_enabled => false,
5
+ options => {
6
+ 'PermitRootLogin' => 'without-password',
7
+ 'GSSAPIAuthentication' => 'no',
8
+ },
9
+ }
10
+ }