vanagon 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +130 -23
  3. data/bin/build +0 -4
  4. data/bin/build_host_info +21 -0
  5. data/bin/inspect +25 -0
  6. data/lib/vanagon/driver.rb +17 -8
  7. data/lib/vanagon/engine/base.rb +11 -2
  8. data/lib/vanagon/engine/docker.rb +21 -6
  9. data/lib/vanagon/engine/ec2.rb +75 -0
  10. data/lib/vanagon/engine/hardware.rb +20 -3
  11. data/lib/vanagon/engine/local.rb +18 -3
  12. data/lib/vanagon/engine/pooler.rb +22 -7
  13. data/lib/vanagon/extensions/hashable.rb +41 -0
  14. data/lib/vanagon/extensions/ostruct/json.rb +12 -0
  15. data/lib/vanagon/extensions/set/json.rb +12 -0
  16. data/lib/vanagon/extensions/string.rb +1 -1
  17. data/lib/vanagon/platform.rb +2 -0
  18. data/lib/vanagon/platform/dsl.rb +63 -0
  19. data/lib/vanagon/platform/osx.rb +6 -0
  20. data/lib/vanagon/project/dsl.rb +1 -1
  21. data/lib/vanagon/utilities.rb +10 -4
  22. data/resources/osx/uninstaller.tool.erb +24 -0
  23. data/resources/rpm/project.spec.erb +6 -0
  24. data/spec/lib/vanagon/driver_spec.rb +88 -0
  25. data/spec/lib/vanagon/engine/docker_spec.rb +6 -0
  26. data/spec/lib/vanagon/engine/ec2_spec.rb +33 -0
  27. data/spec/lib/vanagon/engine/hardware_spec.rb +4 -0
  28. data/spec/lib/vanagon/engine/local_spec.rb +5 -0
  29. data/spec/lib/vanagon/engine/pooler_spec.rb +5 -0
  30. data/spec/lib/vanagon/extensions/ostruct/json_spec.rb +16 -0
  31. data/spec/lib/vanagon/extensions/set/json_spec.rb +17 -0
  32. data/spec/lib/vanagon/extensions/string_spec.rb +30 -0
  33. data/spec/lib/vanagon/utilities_spec.rb +1 -1
  34. metadata +22 -6
  35. data/resources/windows/wix/componentgroup.wxs.erb +0 -33
  36. data/resources/windows/wix/project.wxs.erb +0 -34
  37. data/resources/windows/wix/registryEntries.wxs.erb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e69b827c87e42df5740b868926ede94d03ffe23
4
- data.tar.gz: 48063c4f0fff9db3c8c40b8eaf55930d930ff516
3
+ metadata.gz: f994fbe98407e4e849e71d44ad56a8f6a0ce4946
4
+ data.tar.gz: 03f24c4388823870073e63f32a653701658cd0aa
5
5
  SHA512:
6
- metadata.gz: ba1e2146ea55742e934e53b59807042e569a048d9a8f215f7ee3acbeb9026772659d836cefb0ffb15924c13085c2a676cfe25b3d41200c92826d34cda7b46b70
7
- data.tar.gz: dc76822ffe4ea4bcf888ead30e16de669ea021211a6b0fe9d11bbda772f2f35887947a4e3e932f994ffd97e0ec8d62bc00eded1fe02362c852bf5cb0fc2566b1
6
+ metadata.gz: a65988af487b4e29e440afaab76e67eb5dec9fc231a87ff86688227d9104b7e2a6c1089da1daac5f03692181758f595ecb705686faf271245a8dbd66fa23e7a6
7
+ data.tar.gz: fffaf35d8867478976545d26c0ccdfd4b3dc55edcd7e7817a4ac9f4ef4b23ef4513bfc173ebf7bf1da8ae8725abf17fc6955ba283f8655db86e05899dd608af6
data/README.md CHANGED
@@ -42,31 +42,32 @@ define any platforms you want to build for. Vanagon ships with some simple
42
42
  binaries to use, but the one you probably care about is named 'build'.
43
43
 
44
44
  ### `build` usage
45
-
46
45
  The build command has positional arguments and position independent flags.
47
46
 
47
+
48
48
  #### Arguments (position dependent)
49
49
 
50
50
  ##### project name
51
- The name of the project to build, and a file named \<project\_name\>.rb must be
52
- present in configs/projects in the working directory.
51
+ The name of the project to build; a file named `<project_name>.rb` must be
52
+ present under `configs/projects` in the working directory.
53
53
 
54
54
  ##### platform name
55
- The name of the platform to build against, and a file named
56
- \<platform\_name\>.rb must be present in configs/platforms in the working
57
- directory.
58
-
59
- Platform can also be a comma separated list of platforms such as platform1,platform2.
55
+ The name of the target platform to build `<project_name>` against; a file named
56
+ `<platform_name>.rb` must be present under `configs/platforms` in the working
57
+ directory. This can also be a comma separated list of platforms such as `platform1,platform2`;
58
+ note that there are no spaces after the comma.
60
59
 
61
60
  ##### target host [optional]
62
61
  Target host is an optional argument to override the host selection. Instead of using
63
- a vm collected from the pooler, the build will attempt to ssh to target as the
64
- root user.
62
+ a random VM collected from the pooler (Vanagon's default build engine), the build will
63
+ attempt connect to the target host over SSH as the `root` user.
65
64
 
66
65
  If building on multiple platforms, multiple targets can also be specified using
67
- a comma separated list such as host1,host2. If less targets are specified than
68
- platforms, the default engine (the pooler) will be used for platforms without a
69
- target. If more targets are specified than platforms, the extra will be ignored.
66
+ a comma separated list such as `host1,host2` (note that there are no spaces after
67
+ the comma). If less targets are specified than platforms, the default engine
68
+ (`pooler`) will be used for platforms without a target. If more targets are specified
69
+ than platforms, the extra platforms will be ignored.
70
+
70
71
 
71
72
  #### Flagged arguments (can be anywhere in the command)
72
73
 
@@ -85,6 +86,7 @@ Currently supported engines are:
85
86
  * `docker` - Builds in a docker container
86
87
  * `pooler` - Selects a vm from Puppet Labs' vm pooler to build on
87
88
  * `hardware` - Build on a specific taget and lock it in redis
89
+ * `ec2` - Build on a specific AWS instance.
88
90
 
89
91
  #### Flags (can be anywhere in the command)
90
92
 
@@ -99,28 +101,40 @@ Increase verbosity of output.
99
101
  ##### -h, --help
100
102
  Display command-line help.
101
103
 
104
+
102
105
  #### Environment variables
103
106
 
104
- ##### VANAGON\_SSH\_KEY
107
+ ##### `VANAGON_SSH_KEY`
105
108
  A full path on disk for a private ssh key to be used in ssh and rsync
106
109
  communications. This will be used instead of whatever defaults are configured
107
110
  in .ssh/config.
108
111
 
109
- ##### VANAGON\_SSH\_AGENT
110
- When set, Vanagon will forward the ssh authentication agent connection.
112
+ ##### `VANAGON_SSH_AGENT`
113
+ When set, Vanagon will forward the ssh authentication agent connection.
111
114
 
112
- ##### VMPOOLER\_TOKEN
115
+ ##### `VMPOOLER_TOKEN`
113
116
  Used in conjunction with the pooler engine, this is a token to pass to the
114
117
  vmpooler to access the API. Without this token, the default lifetime of vms
115
118
  will be much shorter.
116
119
 
117
- ##### LOCK\_MANAGER\_HOST
120
+ ##### `LOCK_MANAGER_HOST`
118
121
  The name of the host where redis is running. Redis is used to handle a lock
119
122
  when using the hardware engine. It defaults to *redis*, with no domain.
120
123
 
121
- #### LOCK\_MANAGER\_PORT
124
+ ##### `LOCK_MANAGER_PORT`
122
125
  Port of the system where redis is running. Defaults to *6379*.
123
126
 
127
+ ##### `VANAGON_RETRY_COUNT`
128
+ Some phases of compilation support retries. The default value is *1* but
129
+ setting to any integer value greater than 1 will causes these components
130
+ to retry operations on failure until the `VANAGON_RETRY_COUNT` limit is reached.
131
+
132
+ ##### `VANAGON_TIMEOUT`
133
+ Some phases of compilation can take an indeterminate (but substantial) amount of
134
+ time. The default value is *7200* seconds(120 minutes) but setting to any
135
+ integer value these components to fail after the `VANAGON_TIMEOUT` count is reached.
136
+ Note that this value is expected to be in seconds.
137
+
124
138
  #### Example usage
125
139
  `build --preserve puppet-agent el-6-i386` will build the puppet-agent project
126
140
  on the el-6-i386 platform and leave the host intact afterward.
@@ -129,6 +143,67 @@ on the el-6-i386 platform and leave the host intact afterward.
129
143
  project on the el-6-i386 platform using the docker engine (the platform must
130
144
  have a docker\_image defined in its config).
131
145
 
146
+ ---
147
+
148
+ ### `inspect` usage
149
+
150
+ The `inspect` command has positional arguments and position independent flags. It
151
+ mirrors the `build` command, but exits with success after loading and interpolating
152
+ all of the components in the given project. No attempt is made to actually build
153
+ the given project; instead, a JSON formatted array of hashes is returned and printed
154
+ to `stdout`. This JSON array can be further processed by external tooling, such as `jq`.
155
+
156
+ #### Arguments (position dependent)
157
+
158
+ ##### project name
159
+ The name of the project to build, and a file named \<project\_name\>.rb must be
160
+ present in configs/projects in the working directory.
161
+
162
+ ##### platform name
163
+ The name of the platform to build against, and a file named
164
+ \<platform\_name\>.rb must be present in configs/platforms in the working
165
+ directory.
166
+
167
+ Platform can also be a comma separated list of platforms such as platform1,platform2.
168
+
169
+ #### Flagged arguments (can be anywhere in the command)
170
+
171
+ ##### -w DIR, --workdir DIR
172
+ Specifies a directory where the sources should be placed and builds performed.
173
+ Defaults to a temporary directory created with Ruby's Dir.mktmpdir.
174
+
175
+ ##### -c DIR, --configdir DIR
176
+ Specifies where project configuration is found. Defaults to $pwd/configs.
177
+
178
+ ##### -e ENGINE, --engine ENGINE
179
+ Choose a different virtualization engine to use to select the build target.
180
+ Engines are respected, but only insofar as components and projects are
181
+ rendered -- the `inspect` command performs no compilation.
182
+
183
+ Supported engines are the same as the `build` command.
184
+
185
+ #### Flags (can be anywhere in the command)
186
+
187
+ ##### -v, --verbose (not yet implemented)
188
+ Increase verbosity of output.
189
+
190
+ ##### -h, --help
191
+ Display command-line help.
192
+
193
+ #### Environment variables
194
+
195
+ Environment variables are respected, but only insofar as components and projects are
196
+ rendered -- the `inspect` command has no behavior to alter.
197
+
198
+ Supported environment variables are the same as the `build` command.
199
+
200
+ #### Example usage
201
+ `inspect puppet-agent el-6-i386` will load the puppet-agent project
202
+ on the el-6-i386 platform and print the resulting list of dependencies,
203
+ build-time configuration, environment variables, and expected artifacts.
204
+
205
+ ---
206
+
132
207
  ### `devkit` usage
133
208
 
134
209
  The devkit command has positional arguments and position independent flagged
@@ -160,10 +235,43 @@ As in the `build` target host optional argument.
160
235
  ##### -h, --help
161
236
  Display command-line help.
162
237
 
238
+ ---
239
+
240
+ Engines
241
+ ---
242
+
243
+ ### Amazon Ec2
244
+
245
+ Note: If you have the `aws_ami` setup vanagon will default to the ec2 engine.
246
+
247
+ To use the ec2 engine you should have your credentials set either via your `~/.aws/credentials` or environment variables.
248
+ After this you can setup your `configs/platforms/<platform>.rb` to use your
249
+ ami, instance type, and key_name to setup the instance.
250
+
251
+ A simple one looks like this
252
+
253
+ ```ruby
254
+ # configs/platforms/el-7-x86_64.rb
255
+ platform "el-7-x86_64" do |plat|
256
+ plat.aws_ami "your-ami-id-here" # You must set this
257
+ plat.aws_instance_type "t2.small" # Defaults to t1.micro
258
+ plat.aws_key_name "vanagon" # this is the default but you can use whichever
259
+ plat.aws_user_data <<-eos
260
+ #cloud-config
261
+ runcmds:
262
+ - echo #{my_ssh_key} > /root/.ssh/authorized_keys # Most amis block you from logging in as root.
263
+ eos
264
+
265
+ ### Rest of your code here
266
+
267
+ end
268
+ ```
269
+
270
+
163
271
  Contributing
164
272
  ---
165
273
  We'd love to get contributions from you! Once you are up and running, take a look at the
166
- [Contribution Documents](https://github.com/puppetlabs/vanagon/blob/master/CONTRIBUTING.md) to see how to get your changes merged
274
+ [Contribution Documents](https://github.com/puppetlabs/vanagon/blob/master/docs/CONTRIBUTING.md) to see how to get your changes merged
167
275
  in.
168
276
 
169
277
  License
@@ -183,11 +291,10 @@ For more detailed examples of the DSLs available, please see the
183
291
  [examples](https://github.com/puppetlabs/vanagon/tree/master/examples) directory and the YARD documentation for vanagon.
184
292
 
185
293
  ## Maintainers
186
- ---
187
294
  The Release Engineering team at Puppet Labs
188
295
 
189
- Maintainer: Michael Stahnke <stahnma@puppetlabs.com>
296
+ Maintainer: Michael Stahnke <stahnma@puppet.com>
190
297
 
191
- Please log tickets and issues at our [Issue Tracker](https://tickets.puppetlabs.com/browse/CPR). Set compononent to Vanagon.
298
+ Please log tickets and issues at our [Issue Tracker](https://tickets.puppet.com/browse/CPR). Set compononent to Vanagon.
192
299
 
193
300
  In addition there is an active #puppet-dev channel on Freenode.
data/bin/build CHANGED
@@ -25,9 +25,5 @@ end
25
25
  platform_list.zip(target_list).each do |pair|
26
26
  platform, target = pair
27
27
  artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
28
-
29
- artifact.verbose = true if options[:verbose]
30
- artifact.preserve = true if options[:preserve]
31
-
32
28
  artifact.run
33
29
  end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ require 'json'
3
+
4
+ load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
5
+
6
+ optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", [:workdir, :configdir, :engine])
7
+ options = optparse.parse! ARGV
8
+
9
+ project = ARGV[0]
10
+ platforms = ARGV[1]
11
+
12
+ if project.nil? or platforms.nil?
13
+ warn "project and platform are both required arguments."
14
+ puts optparse
15
+ exit 1
16
+ end
17
+
18
+ platforms.split(',').each do |platform|
19
+ driver = Vanagon::Driver.new(platform, project, options)
20
+ puts JSON.generate(driver.build_host_info)
21
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ require 'json'
3
+ require 'vanagon/extensions/ostruct/json'
4
+ require 'vanagon/extensions/set/json'
5
+ require 'vanagon/extensions/hashable'
6
+
7
+ load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
8
+
9
+ optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", [:workdir, :configdir, :engine])
10
+ options = optparse.parse! ARGV
11
+
12
+ project = ARGV[0]
13
+ platforms = ARGV[1]
14
+
15
+ unless project or platforms
16
+ warn "project and platform are both required arguments."
17
+ puts optparse
18
+ exit 1
19
+ end
20
+
21
+ platforms.split(',').each do |platform|
22
+ driver = Vanagon::Driver.new(platform, project, options)
23
+ components = driver.project.components.map(&:to_hash)
24
+ puts JSON.pretty_generate(components)
25
+ end
@@ -13,9 +13,9 @@ class Vanagon
13
13
  attr_accessor :platform, :project, :target, :workdir, :verbose, :preserve
14
14
  attr_accessor :timeout, :retry_count
15
15
 
16
- def initialize(platform, project, options = { :configdir => nil, :target => nil, :engine => nil, :components => nil, :skipcheck => false })
17
- @verbose = false
18
- @preserve = false
16
+ def initialize(platform, project, options = { :configdir => nil, :target => nil, :engine => nil, :components => nil, :skipcheck => false, :verbose => false, :preserve => false })
17
+ @verbose = options[:verbose]
18
+ @preserve = options[:preserve]
19
19
 
20
20
  @@configdir = options[:configdir] || File.join(Dir.pwd, "configs")
21
21
  components = options[:components] || []
@@ -24,6 +24,7 @@ class Vanagon
24
24
 
25
25
  @platform = Vanagon::Platform.load_platform(platform, File.join(@@configdir, "platforms"))
26
26
  @project = Vanagon::Project.load_project(project, File.join(@@configdir, "projects"), @platform, components)
27
+ @project.settings[:verbose] = options[:verbose]
27
28
  @project.settings[:skipcheck] = options[:skipcheck]
28
29
  loginit('vanagon_hosts.log')
29
30
 
@@ -35,6 +36,10 @@ class Vanagon
35
36
  def load_engine(engine_type, platform, target)
36
37
  if platform.build_hosts
37
38
  engine_type = 'hardware'
39
+ elsif platform.aws_ami
40
+ engine_type = 'ec2'
41
+ elsif platform.docker_image
42
+ engine_type = 'docker'
38
43
  elsif target
39
44
  engine_type = 'base'
40
45
  end
@@ -60,6 +65,10 @@ class Vanagon
60
65
  @@logger
61
66
  end
62
67
 
68
+ def build_host_info
69
+ { "name" => @engine.build_host_name, "engine" => @engine.name }
70
+ end
71
+
63
72
  # Returns the set difference between the build_requires and the components to get a list of external dependencies that need to be installed.
64
73
  def list_build_dependencies
65
74
  @project.components.map(&:build_requires).flatten.uniq - @project.components.map(&:name)
@@ -87,12 +96,12 @@ class Vanagon
87
96
 
88
97
  puts "Target is #{@engine.target}"
89
98
  retry_task { install_build_dependencies }
90
- @project.fetch_sources(@workdir)
99
+ retry_task { @project.fetch_sources(@workdir) }
91
100
  @project.make_makefile(@workdir)
92
101
  @project.make_bill_of_materials(@workdir)
93
102
  @project.generate_packaging_artifacts(@workdir)
94
103
  @engine.ship_workdir(@workdir)
95
- retry_task { @engine.dispatch("(cd #{@engine.remote_workdir}; #{@platform.make})") }
104
+ @engine.dispatch("(cd #{@engine.remote_workdir}; #{@platform.make})")
96
105
  @engine.retrieve_built_artifact
97
106
  @engine.teardown unless @preserve
98
107
  cleanup_workdir unless @preserve
@@ -101,7 +110,7 @@ class Vanagon
101
110
  puts e.backtrace.join("\n")
102
111
  raise e
103
112
  ensure
104
- if @engine.name == "hardware"
113
+ if ["hardware", "ec2"].include?(@engine.name)
105
114
  @engine.teardown
106
115
  end
107
116
  end
@@ -129,8 +138,8 @@ class Vanagon
129
138
  # values from the project, if available, otherwise use some
130
139
  # sane defaults.
131
140
  def retry_task(&block)
132
- @timeout = @project.timeout || 3600
133
- @retry_count = @project.retry_count || 3
141
+ @timeout = @project.timeout || ENV["VANAGON_TIMEOUT"] || 7200
142
+ @retry_count = @project.retry_count || ENV["VANAGON_RETRY_COUNT"] || 1
134
143
  Vanagon::Utilities.retry_with_timeout(@retry_count, @timeout) { yield }
135
144
  end
136
145
  private :retry_task
@@ -4,14 +4,23 @@ require 'vanagon/errors'
4
4
  class Vanagon
5
5
  class Engine
6
6
  class Base
7
- attr_accessor :target, :remote_workdir, :name
7
+ attr_accessor :target, :remote_workdir
8
8
 
9
9
  def initialize(platform, target = nil)
10
10
  @platform = platform
11
11
  @required_attributes = ["ssh_port"]
12
12
  @target = target if target
13
13
  @target_user = @platform.target_user
14
- @name = 'base'
14
+ end
15
+
16
+ # Get the engine name
17
+ def name
18
+ 'base'
19
+ end
20
+
21
+ # Get the engine specific name of the host to build on
22
+ def build_host_name
23
+ raise Vanagon::Error, '#build_host_name has not been implemented for your engine.'
15
24
  end
16
25
 
17
26
  # This method is used to obtain a vm to build upon
@@ -6,17 +6,32 @@ class Vanagon
6
6
  # Both the docker_image and the docker command itself are required for
7
7
  # the docker engine to work
8
8
  def initialize(platform, target = nil)
9
- @docker_cmd = Vanagon::Utilities.find_program_on_path('docker')
10
- @name = 'docker'
11
9
  super
10
+
11
+ @docker_cmd = Vanagon::Utilities.find_program_on_path('docker')
12
12
  @required_attributes << "docker_image"
13
13
  end
14
14
 
15
+ # Get the engine name
16
+ def name
17
+ 'docker'
18
+ end
19
+
20
+ # Return the docker image name to build on
21
+ def build_host_name
22
+ if @build_host_name.nil?
23
+ validate_platform
24
+ @build_host_name = @platform.docker_image
25
+ end
26
+
27
+ @build_host_name
28
+ end
29
+
15
30
  # This method is used to obtain a vm to build upon using
16
31
  # a docker container.
17
32
  # @raise [Vanagon::Error] if a target cannot be obtained
18
33
  def select_target
19
- Vanagon::Utilities.ex("#{@docker_cmd} run -d --name #{@platform.docker_image}-builder -p #{@platform.ssh_port}:22 #{@platform.docker_image}")
34
+ Vanagon::Utilities.ex("#{@docker_cmd} run -d --name #{build_host_name}-builder -p #{@platform.ssh_port}:22 #{build_host_name}")
20
35
  @target = 'localhost'
21
36
 
22
37
  # Wait for ssh to come up in the container
@@ -30,10 +45,10 @@ class Vanagon
30
45
  # This method is used to tell the vmpooler to delete the instance of the
31
46
  # vm that was being used so the pool can be replenished.
32
47
  def teardown
33
- Vanagon::Utilities.ex("#{@docker_cmd} stop #{@platform.docker_image}-builder")
34
- Vanagon::Utilities.ex("#{@docker_cmd} rm #{@platform.docker_image}-builder")
48
+ Vanagon::Utilities.ex("#{@docker_cmd} stop #{build_host_name}-builder")
49
+ Vanagon::Utilities.ex("#{@docker_cmd} rm #{build_host_name}-builder")
35
50
  rescue Vanagon::Error => e
36
- warn "There was a problem tearing down the docker container #{@platform.docker_image}-builder (#{e.message})."
51
+ warn "There was a problem tearing down the docker container #{build_host_name}-builder (#{e.message})."
37
52
  end
38
53
  end
39
54
  end