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,142 @@
1
+ require 'spec_helper'
2
+
3
+ describe Boxes::Config do
4
+ let(:config) { Boxes::Config.new }
5
+
6
+ context 'with no ENV modification' do
7
+ it 'tries to load a user config file if one exists' do
8
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
9
+ allow(YAML).to receive(:load_file).and_return({})
10
+
11
+ config
12
+
13
+ config_path = Pathname.new('~/.boxes/config.yml').expand_path
14
+ expect(YAML).to have_received(:load_file).with(config_path)
15
+ end
16
+
17
+ it 'has a set of default config values' do
18
+ expect(described_class::DEFAULTS).to be_a(Hash)
19
+ end
20
+
21
+ it 'has a home directory' do
22
+ expect(config.home_dir).to eq Pathname.new('~/.boxes').expand_path
23
+ end
24
+
25
+ it 'has a working directory' do
26
+ expect(config.working_dir).to eq Pathname.new('~/.boxes/tmp').expand_path
27
+ end
28
+
29
+ it 'has an array of template paths' do
30
+ expect(config.template_paths).to be_a Array
31
+ end
32
+
33
+ it 'supports adding additional template paths' do
34
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
35
+ allow(YAML).to receive(:load_file).and_return(
36
+ template_paths: ['~/user_templates'])
37
+
38
+ default_templates = Boxes::Config::DEFAULTS[:template_paths]
39
+
40
+ expect(config.template_paths).to include('~/user_templates')
41
+ expect(config.template_paths).to include(default_templates.first)
42
+ end
43
+
44
+ it 'does not duplicate template path values' do
45
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
46
+
47
+ default_templates = Boxes::Config::DEFAULTS[:template_paths]
48
+
49
+ allow(YAML).to receive(:load_file).and_return(
50
+ template_paths: default_templates)
51
+
52
+ expect(config.template_paths).to include(default_templates.first)
53
+ expect(config.template_paths.count).to eq default_templates.count
54
+ end
55
+
56
+ it 'has an array of script paths' do
57
+ expect(config.script_paths).to be_a Array
58
+ end
59
+
60
+ it 'supports adding additional script paths' do
61
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
62
+ allow(YAML).to receive(:load_file).and_return(
63
+ script_paths: ['~/user_scripts'])
64
+
65
+ default_scripts = Boxes::Config::DEFAULTS[:script_paths]
66
+
67
+ expect(config.script_paths).to include('~/user_scripts')
68
+ expect(config.script_paths).to include(default_scripts.first)
69
+ end
70
+
71
+ it 'does not duplicate script path values' do
72
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
73
+
74
+ default_scripts = Boxes::Config::DEFAULTS[:script_paths]
75
+
76
+ allow(YAML).to receive(:load_file).and_return(
77
+ script_paths: default_scripts)
78
+
79
+ expect(config.script_paths).to include(default_scripts.first)
80
+ expect(config.script_paths.count).to eq default_scripts.count
81
+ end
82
+
83
+ it 'has an array of environment variables' do
84
+ expect(config.environment_vars).to be_a Array
85
+ end
86
+
87
+ it 'supports adding additional environment variables' do
88
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
89
+ allow(YAML).to receive(:load_file).and_return(
90
+ environment_vars: [{ 'CUSTOM_VAR' => 'TRUE' }])
91
+
92
+ default_env_vars = Boxes::Config::DEFAULTS[:environment_vars]
93
+
94
+ expect(config.environment_vars).to include('CUSTOM_VAR' => 'TRUE')
95
+ expect(config.environment_vars).to include(default_env_vars.first)
96
+ end
97
+
98
+ it 'does not duplicate environment variable values' do
99
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
100
+
101
+ default_env_vars = Boxes::Config::DEFAULTS[:environment_vars]
102
+
103
+ allow(YAML).to receive(:load_file).and_return(
104
+ environment_vars: default_env_vars)
105
+
106
+ expect(config.environment_vars).to include(default_env_vars.first)
107
+ expect(config.environment_vars.count).to eq default_env_vars.count
108
+ end
109
+ end
110
+
111
+ context 'with ENV modification' do
112
+ it 'tries to load a different user config file' do
113
+ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true)
114
+ allow(YAML).to receive(:load_file).and_return({})
115
+
116
+ ENV['BOXES_HOME_DIR'] = '/something'
117
+
118
+ config
119
+
120
+ config_path = Pathname.new('/something/config.yml').expand_path
121
+ expect(YAML).to have_received(:load_file).with(config_path)
122
+
123
+ ENV.delete 'BOXES_HOME_DIR'
124
+ end
125
+
126
+ it 'can change the home directory' do
127
+ ENV['BOXES_HOME_DIR'] = '/something'
128
+
129
+ expect(config.home_dir).to eq Pathname.new('/something')
130
+
131
+ ENV.delete 'BOXES_HOME_DIR'
132
+ end
133
+
134
+ it 'can change the working directory' do
135
+ ENV['BOXES_WORKING_DIR'] = '/something'
136
+
137
+ expect(config.working_dir).to eq Pathname.new('/something')
138
+
139
+ ENV.delete 'BOXES_WORKING_DIR'
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Boxes::Environment do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:env) { Boxes::Environment.new }
7
+
8
+ before do
9
+ current_directory = File.expand_path('../../..', __FILE__)
10
+
11
+ FileUtils.mkdir_p(current_directory + '/templates')
12
+ FileUtils.mkdir_p(current_directory + '/templates/ubuntu')
13
+ FileUtils.touch(current_directory + '/templates/ubuntu/trusty64.erb')
14
+ FileUtils.touch(current_directory + '/templates/ubuntu/preseed.cfg')
15
+
16
+ FileUtils.mkdir_p(current_directory + '/scripts')
17
+ FileUtils.touch(current_directory + '/scripts/prepare.sh')
18
+ FileUtils.touch(current_directory + '/scripts/purge.sh')
19
+ end
20
+
21
+ describe '#initialize' do
22
+ it 'successfully builds up a working tree' do
23
+ working_dir = Boxes.config.working_dir
24
+ test_template = working_dir + 'templates/ubuntu/trusty64.erb'
25
+ test_script = working_dir + 'scripts/prepare.sh'
26
+
27
+ env
28
+
29
+ [working_dir,
30
+ working_dir + 'templates',
31
+ working_dir + 'scripts'].each do |e|
32
+ expect(File.directory?(e)).to be_truthy
33
+ end
34
+
35
+ expect(File.exist?(test_template)).to be_truthy
36
+ expect(File.exist?(test_script)).to be_truthy
37
+ end
38
+ end
39
+
40
+ describe '#available_templates' do
41
+ it 'lists available templates' do
42
+ expect(env.available_templates).to be_a(Array)
43
+ expect(env.available_templates).to include('ubuntu/trusty64')
44
+ end
45
+
46
+ it 'doesn\'t include hidden templates' do
47
+ expect(env.available_templates).not_to include('ubuntu/preseed.cfg')
48
+ end
49
+ end
50
+
51
+ describe '#hidden_templates' do
52
+ it 'lists hidden templates' do
53
+ expect(env.hidden_templates).to include('ubuntu/preseed.cfg')
54
+ end
55
+ end
56
+
57
+ describe '#available_scripts' do
58
+ it 'lists available scripts' do
59
+ expect(env.available_scripts).to be_a(Array)
60
+ expect(env.available_scripts).to include('prepare.sh')
61
+ end
62
+
63
+ it 'doesn\'t include hidden scripts' do
64
+ expect(env.available_scripts).not_to include('purge.sh')
65
+ end
66
+ end
67
+
68
+ describe '#hidden_scripts' do
69
+ it 'lists hidden scripts' do
70
+ expect(env.hidden_scripts).to include('purge.sh')
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Boxes::Subprocess do
4
+ let(:command) do
5
+ File.expand_path 'spec/support/subprocess_command.rb'
6
+ end
7
+
8
+ it 'runs a command and yields a block' do
9
+ expect { |b| Boxes::Subprocess.run(command, &b) }.to yield_control
10
+ end
11
+
12
+ it 'runs a command and returns stdout' do
13
+ total_stdout = ''
14
+ Boxes::Subprocess.run(command) do |stdout, _stderr, _thread|
15
+ total_stdout << stdout
16
+ end
17
+
18
+ expect(total_stdout).to eq "A happy output.\n"
19
+ end
20
+
21
+ it 'runs a command and returns stderr' do
22
+ total_stderr = ''
23
+ Boxes::Subprocess.run(command) do |_stdout, stderr, _thread|
24
+ total_stderr << stderr
25
+ end
26
+
27
+ expect(total_stderr).to eq "An unhappy output.\n"
28
+ end
29
+
30
+ it 'returns a status code' do
31
+ status = Boxes::Subprocess.run(command) { |_stdout, _stderr, _thread| }
32
+
33
+ expect(status.exitstatus).to eq 5
34
+ end
35
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Boxes::Template do
4
+ include FakeFS::SpecHelpers
5
+
6
+ let(:env) { Boxes::Environment.new }
7
+
8
+ before do
9
+ current_directory = File.expand_path('../../..', __FILE__)
10
+
11
+ FileUtils.mkdir_p(current_directory + '/templates')
12
+ FileUtils.mkdir_p(current_directory + '/templates/ubuntu')
13
+
14
+ mock_template = <<-EOF
15
+ <% @scripts.each do |s| %>
16
+ <%= s %>
17
+ <% end %>
18
+ EOF
19
+
20
+ File.open(current_directory + '/templates/ubuntu/trusty64.erb', 'w') do |f|
21
+ f.puts mock_template
22
+ end
23
+ end
24
+
25
+ describe '#initialize' do
26
+ it 'can read in a known template' do
27
+ template = described_class.new(env, 'ubuntu/trusty64')
28
+
29
+ expect(template.template).to be_a(String)
30
+ end
31
+
32
+ it 'throws an exception if the template is missing' do
33
+ expect do
34
+ described_class.new(env, 'nope/nope')
35
+ end.to raise_error(Boxes::Errors::TemplateNotFoundError)
36
+ end
37
+
38
+ it 'stores the template name' do
39
+ template = described_class.new(env, 'ubuntu/trusty64')
40
+
41
+ expect(template.name).to eq 'ubuntu/trusty64'
42
+ end
43
+ end
44
+
45
+ describe '#render' do
46
+ it 'renders a template with a set of variables' do
47
+ template = described_class.new(env, 'ubuntu/trusty64')
48
+ rendered = template.render(scripts: ['ruby.sh'])
49
+
50
+ expect(rendered).to include('ruby.sh')
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'fakefs/spec_helpers'
4
+
5
+ require 'boxes'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ STDOUT.puts 'A happy output.'
4
+
5
+ STDERR.puts 'An unhappy output.'
6
+
7
+ exit 5
@@ -0,0 +1,206 @@
1
+ {
2
+ "variables": {
3
+ "name": "<%= @name || '{{ .Name }}' %>",
4
+ "created_by": "<%= @app_creator || ENV['USER'] %>",
5
+ "project": "<%= @app_project %>",
6
+ "version": "<%= @app_version %>",
7
+ <%- if @provisioner == "aws" -%>
8
+ "ami_name": "<%= @name %>-<%= @app_version %>-{{isotime \"200601021504\"}}",
9
+ "ami_description": "<%= @description %> <%= @app_version %> {{isotime \"2006-01-02@15:04\"}}",
10
+ "aws_access_key": "<%= @aws_access_key %>",
11
+ "aws_secret_key": "<%= @aws_secret_key %>",
12
+ "aws_region": "<%= @aws_region %>",
13
+ "source_ami": "<%= @aws_source_ami %>",
14
+ "user_data": "<%= @aws_user_data %>",
15
+ <%- end -%>
16
+ "provisioner": "<%= @provisioner %>"
17
+ },
18
+
19
+ "provisioners": [
20
+ <%- if @puppetserver -%>
21
+ {
22
+ "type": "shell-local",
23
+ "command": "scripts/local-ssh-keygen.sh"
24
+ },
25
+ {
26
+ "type": "file",
27
+ "source": "keys",
28
+ "destination": "/tmp"
29
+ },
30
+ <%- end -%>
31
+ {
32
+ "type": "shell",
33
+ "environment_vars": [
34
+ "PACKER_PROVISIONER=<%= @provisioner %>"
35
+ ],
36
+ "scripts": [
37
+ "scripts/prepare.sh",
38
+ <%- if @provisioner == "vagrant" -%>
39
+ "scripts/vagrant.sh",
40
+ "scripts/vmtools.sh",
41
+ <%- end -%>
42
+ <%- if @puppetserver -%>
43
+ "scripts/puppetserver.sh",
44
+ <%- elsif @puppet -%>
45
+ "scripts/puppet.sh",
46
+ <%- end -%>
47
+ <%- if @chef -%>
48
+ "scripts/chef.sh",
49
+ <%- end -%>
50
+ <%- if @ansible -%>
51
+ "scripts/ansible.sh",
52
+ <%- end -%>
53
+ <%- if @docker -%>
54
+ "scripts/docker.sh",
55
+ <%- end -%>
56
+ <%- @scripts.each do |script| -%>
57
+ "scripts/<%= script %>",
58
+ <%- end -%>
59
+ "scripts/prepare-done.sh"
60
+ ],
61
+ "execute_command": "<%= @shell_exec_cmd %>"
62
+ },
63
+ <%- if @bootstrap -%>
64
+ {
65
+ "type": "file",
66
+ "source": "puppet/hieradata",
67
+ "destination": "/tmp"
68
+ },
69
+ {
70
+ "type": "file",
71
+ "source": "puppet/Puppetfile",
72
+ "destination": "/tmp/Puppetfile"
73
+ },
74
+ {
75
+ "type": "puppet-masterless",
76
+ "facter": {
77
+ "provisioner": "{{user `provisioner`}}",
78
+ "app_project": "{{user `project`}}",
79
+ "app_creator": "{{user `created_by`}}",
80
+ "app_version": "{{user `version`}}"
81
+ },
82
+ "manifest_file": "puppet/manifests/r10k_bootstrap.pp",
83
+ "extra_arguments": [
84
+ "--show_diff --verbose"
85
+ ],
86
+ "hiera_config_path": "puppet/hiera.yaml"
87
+ },
88
+ {
89
+ "type": "puppet-masterless",
90
+ "facter": {
91
+ "provisioner": "{{user `provisioner`}}",
92
+ "puppetversion": "4.0",
93
+ "app_project": "{{user `project`}}",
94
+ "app_creator": "{{user `created_by`}}",
95
+ "app_version": "{{user `version`}}"
96
+ },
97
+ "manifest_file": "puppet/environments/<%= @provisioner %>/manifests/base.pp",
98
+ "module_paths": [
99
+ "puppet/modules"
100
+ ],
101
+ "extra_arguments": [
102
+ "--show_diff --verbose"
103
+ ],
104
+ "hiera_config_path": "puppet/hiera.yaml",
105
+ "execute_command": "cd {{.WorkingDir}} && {{.FacterVars}}{{if .Sudo}} sudo -E {{end}}puppet apply --verbose --modulepath='{{.ModulePath}}:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules' {{if ne .HieraConfigPath \"\"}}--hiera_config='{{.HieraConfigPath}}' {{end}} {{if ne .ManifestDir \"\"}}--manifestdir='{{.ManifestDir}}' {{end}} --detailed-exitcodes {{.ManifestFile}}"
106
+ },
107
+ <%- end -%>
108
+ <%- if @puppetserver -%>
109
+ {
110
+ "type": "shell",
111
+ "scripts": [
112
+ "scripts/puppetserver-post.sh"
113
+ ],
114
+ "execute_command": "<%= @shell_exec_cmd %>"
115
+ },
116
+ <%- end -%>
117
+ {
118
+ "type": "shell",
119
+ "scripts": [
120
+ "scripts/cleanup.sh",
121
+ "scripts/cleanup-<%= @provisioner %>.sh"
122
+ ],
123
+ "execute_command": "<%= @shell_exec_cmd %>"
124
+ }
125
+ ],
126
+
127
+ "builders": [
128
+ <%- if @provisioner == "aws" -%>
129
+ {
130
+ "type": "amazon-ebs",
131
+ "access_key": "{{user `aws_access_key`}}",
132
+ "secret_key": "{{user `aws_secret_key`}}",
133
+ "region": "{{user `aws_region`}}",
134
+ "source_ami": "{{user `source_ami`}}",
135
+ "instance_type": "c4.large",
136
+ "ssh_username": "admin",
137
+ "ami_description": "{{user `ami_description`}}",
138
+ "ami_name": "{{user `ami_name`}}",
139
+ "ssh_timeout": "10000s",
140
+ "ssh_pty": "true",
141
+ "user_data": "{{user `user_data`}}",
142
+ "run_tags": {
143
+ "created_by": "{{user `created_by`}}",
144
+ "project": "{{user `project`}}"
145
+ },
146
+ "tags": {
147
+ "created_by": "{{user `created_by`}}",
148
+ "project": "{{user `project`}}"
149
+ }
150
+ }
151
+ <%- elsif @provisioner == "vagrant" -%>
152
+ {
153
+ "name": "<%= @name %>",
154
+ "type": "<%= @provider %>-iso",
155
+ <%- if @provider == "vmware" -%>
156
+ "guest_os_type": "debian7-64",
157
+ "tools_upload_flavor": "linux",
158
+ <%- else -%>
159
+ "guest_os_type": "Debian_64",
160
+ <%- end -%>
161
+ "headless": true,
162
+
163
+ "iso_url": "http://cdimage.debian.org/debian-cd/8.5.0/amd64/iso-cd/debian-8.5.0-amd64-netinst.iso",
164
+ "iso_checksum": "ad4e8c27c561ad8248d5ebc1d36eb172f884057bfeb2c22ead823f59fa8c3dff",
165
+ "iso_checksum_type": "sha256",
166
+
167
+ "ssh_username": "vagrant",
168
+ "ssh_password": "vagrant",
169
+ "ssh_timeout": "15m",
170
+
171
+ "http_directory": "templates/debian",
172
+
173
+ "boot_command": [
174
+ "<esc><wait>",
175
+ "install ",
176
+ "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
177
+ "debian-installer=en_US auto=true locale=en_US kbd-chooser/method=us ",
178
+ "netcfg/get_hostname={{ .Name }} ",
179
+ "netcfg/get_domain=vagrantup.com ",
180
+ "fb=false debconf/frontend=noninteractive ",
181
+ "console-setup/ask_detect=false console-keymaps-at/keymap=us ",
182
+ "keyboard-configuration/xkb-keymap=us ",
183
+ "<enter>"
184
+ ],
185
+
186
+ <%- if @provider == "virtualbox" -%>
187
+ "vboxmanage": [
188
+ [ "modifyvm", "{{.Name}}", "--memory", "2048" ],
189
+ [ "modifyvm", "{{.Name}}", "--cpus", "2" ]
190
+ ],
191
+ <%- end -%>
192
+
193
+ "shutdown_command": "echo 'shutdown -h now' > shutdown.sh; echo 'vagrant'|sudo -S sh 'shutdown.sh'"
194
+ }
195
+ <%- end -%>
196
+ ],
197
+
198
+ "post-processors": [
199
+ <%- if @provisioner == "vagrant" -%>
200
+ {
201
+ "type": "vagrant",
202
+ "output": "<%= @name || '{{build_name}}' %>_<%= @app_version %>-{{isotime \"200601021504\"}}.box"
203
+ }
204
+ <%- end -%>
205
+ ]
206
+ }
@@ -0,0 +1,70 @@
1
+ #
2
+ # Based upon: https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
3
+ #
4
+
5
+ # localisation
6
+ d-i debian-installer/locale string en_US.utf8
7
+ d-i console-keymaps-at/keymap select us
8
+
9
+ # networking
10
+ d-i netcfg/choose_interface select auto
11
+ d-i netcfg/get_hostname string unassigned-hostname
12
+ d-i netcfg/get_domain string unassigned-domain
13
+ d-i netcfg/wireless_wep string
14
+
15
+ # apt mirrors
16
+ d-i mirror/country string manual
17
+ d-i mirror/http/hostname string http.us.debian.org
18
+ d-i mirror/http/directory string /debian
19
+ d-i mirror/http/proxy string
20
+
21
+ # clock and time zone
22
+ d-i clock-setup/utc boolean true
23
+ d-i time/zone string GMT
24
+ d-i clock-setup/ntp boolean true
25
+
26
+ # partitioning
27
+ d-i partman-auto/method string lvm
28
+ d-i partman-lvm/device_remove_lvm boolean true
29
+ d-i partman-md/device_remove_md boolean true
30
+ d-i partman-lvm/confirm boolean true
31
+ d-i partman-lvm/confirm_nooverwrite boolean true
32
+
33
+ #d-i partman-auto-lvm/guided_size string max
34
+ d-i partman-auto/choose_recipe select atomic
35
+ d-i partman-partitioning/confirm_write_new_label boolean true
36
+ d-i partman/choose_partition select finish
37
+ d-i partman/confirm boolean true
38
+ d-i partman/confirm_nooverwrite boolean true
39
+
40
+ # users
41
+ d-i passwd/root-login boolean false
42
+ d-i passwd/user-fullname string Vagrant User
43
+ d-i passwd/username string vagrant
44
+ d-i passwd/user-password password vagrant
45
+ d-i passwd/user-password-again password vagrant
46
+ d-i user-setup/allow-password-weak boolean true
47
+ d-i user-setup/encrypt-home boolean false
48
+
49
+ # packages
50
+ tasksel tasksel/first multiselect standard
51
+ #d-i pkgsel/install-language-support boolean false
52
+ d-i pkgsel/include string openssh-server nfs-common curl ntp acpid sudo bzip2 rsync git ca-certificates
53
+ d-i pkgsel/upgrade select full-upgrade
54
+ d-i pkgsel/update-policy select none
55
+ d-i popularity-contest/participate boolean false
56
+ postfix postfix/main_mailer_type select No configuration
57
+
58
+ # boot loader
59
+ d-i grub-installer/bootdev string default
60
+ d-i grub-installer/only_debian boolean true
61
+
62
+ # hide the shutdown notice
63
+ d-i finish-install/reboot_in_progress note
64
+
65
+ # advanced options
66
+
67
+ # ensure the default VirtualBox additions doesn't install
68
+ d-i preseed/early_command string sed -i \
69
+ '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \
70
+ /usr/lib/pre-pkgsel.d/20install-hwpackages