packerman 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/bin/packerman +5 -0
- data/lib/packerman/client.rb +19 -0
- data/lib/packerman/dsl/builders/amazon_chroot.rb +39 -0
- data/lib/packerman/dsl/builders/amazon_ebs.rb +71 -0
- data/lib/packerman/dsl/builders/amazon_instance.rb +63 -0
- data/lib/packerman/dsl/builders/docker.rb +28 -0
- data/lib/packerman/dsl/builders.rb +2 -0
- data/lib/packerman/dsl/hash_object.rb +20 -0
- data/lib/packerman/dsl/node.rb +35 -0
- data/lib/packerman/dsl/provisioners/chef_solo.rb +29 -0
- data/lib/packerman/dsl/provisioners/shell.rb +25 -0
- data/lib/packerman/dsl/provisioners.rb +2 -0
- data/lib/packerman/dsl.rb +17 -0
- data/lib/packerman/evaluator.rb +24 -0
- data/lib/packerman/repository.rb +32 -0
- data/lib/packerman/version.rb +3 -0
- data/lib/packerman.rb +23 -0
- data/packerman.gemspec +24 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c0c9763c417c163515c0f0288988a5e51fd5dac8
|
4
|
+
data.tar.gz: 856dee55d5daa41394f57e17197de2e01cceed39
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d3287f8c2a44164ed8bc2dce90de2b93ae55c7937d31730fd291861542aa314befc5f5c7d89df8d28d03caa89a0311e66d5b706d9957a3dc83f17953286c11d
|
7
|
+
data.tar.gz: 3078dc5f86650e11db601d9cb4f4aff1eaa37a8e5fc9cef74b10a2bb6fa26346a8325da099ce11212dafe2426beb135c2ab79c78cc658b6a332530140373627c
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
packerman (0.1.0)
|
5
|
+
activesupport
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (4.2.4)
|
11
|
+
i18n (~> 0.7)
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
i18n (0.7.0)
|
18
|
+
json (1.8.3)
|
19
|
+
minitest (5.8.1)
|
20
|
+
rake (10.4.2)
|
21
|
+
rspec (3.3.0)
|
22
|
+
rspec-core (~> 3.3.0)
|
23
|
+
rspec-expectations (~> 3.3.0)
|
24
|
+
rspec-mocks (~> 3.3.0)
|
25
|
+
rspec-core (3.3.2)
|
26
|
+
rspec-support (~> 3.3.0)
|
27
|
+
rspec-expectations (3.3.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.3.0)
|
30
|
+
rspec-mocks (3.3.2)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.3.0)
|
33
|
+
rspec-support (3.3.0)
|
34
|
+
thread_safe (0.3.5)
|
35
|
+
tzinfo (1.2.2)
|
36
|
+
thread_safe (~> 0.1)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
bundler (~> 1.10)
|
43
|
+
packerman!
|
44
|
+
rake (~> 10.0)
|
45
|
+
rspec
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
1.10.6
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Masashi AKISUE
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Masashi AKISUE
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# packerman
|
2
|
+
Ruby DSL for Packer by HashiCorp.
|
3
|
+
|
4
|
+
# Usage
|
5
|
+
|
6
|
+
Packerman is converter ruby DSL to Packer template.<br>
|
7
|
+
Currently, Packerman is supporting these template structures.
|
8
|
+
|
9
|
+
### Builders
|
10
|
+
* amazon-ebs
|
11
|
+
* amazon-instance
|
12
|
+
* amazon-chroot
|
13
|
+
* docker
|
14
|
+
|
15
|
+
### Provisioners
|
16
|
+
* shell
|
17
|
+
* chef-solo
|
18
|
+
|
19
|
+
# DSL
|
20
|
+
|
21
|
+
use this command to convert DSL.
|
22
|
+
|
23
|
+
```
|
24
|
+
$ bundle exec packerman <filename>
|
25
|
+
```
|
26
|
+
|
27
|
+
Here is DSL sample.
|
28
|
+
|
29
|
+
```rb:sample.rb
|
30
|
+
Builders type: "docker" do
|
31
|
+
image "centos"
|
32
|
+
export_path "image.tar"
|
33
|
+
end
|
34
|
+
|
35
|
+
Provisioners type: "shell" do
|
36
|
+
inline ['echo Hello Packerman']
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
```json:sample.json
|
41
|
+
{
|
42
|
+
"builders": [
|
43
|
+
{
|
44
|
+
"type": "docker",
|
45
|
+
"export_path": "image.tar",
|
46
|
+
"image": "centos"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"provisioners": [
|
50
|
+
{
|
51
|
+
"type": "shell",
|
52
|
+
"inline": [
|
53
|
+
"echo Hello Packerman"
|
54
|
+
]
|
55
|
+
}
|
56
|
+
]
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
## Installation
|
61
|
+
add this line to your Gemfile
|
62
|
+
|
63
|
+
```
|
64
|
+
gem 'packerman'
|
65
|
+
```
|
66
|
+
|
67
|
+
then
|
68
|
+
|
69
|
+
```
|
70
|
+
$ bundle install
|
71
|
+
```
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
1. Fork it ( https://github.com/the40san/packerman/fork )
|
76
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
77
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
78
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
79
|
+
5. Create a new Pull Request
|
80
|
+
|
81
|
+
Welcome :)
|
data/Rakefile
ADDED
data/bin/packerman
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Packerman::Client
|
2
|
+
def convert(file)
|
3
|
+
basename = File.basename(file, ".*")
|
4
|
+
puts "converting #{file} to #{basename}.json ..."
|
5
|
+
|
6
|
+
template = File.open(file).read
|
7
|
+
File.open("#{basename}.json", "w") do |f|
|
8
|
+
f.write to_json(template)
|
9
|
+
end
|
10
|
+
puts "converted!"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def to_json(template)
|
16
|
+
converted_hash = Packerman::Evaluator.new.evaluate(template)
|
17
|
+
JSON.pretty_generate(converted_hash)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Packerman::Dsl::Builders::AmazonChroot< Packerman::Dsl::Builders
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
|
4
|
+
def type
|
5
|
+
"amazon-chroot"
|
6
|
+
end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def require_keys
|
10
|
+
[
|
11
|
+
:access_key,
|
12
|
+
:ami_name,
|
13
|
+
:secret_key,
|
14
|
+
:source_ami
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def optional_keys
|
19
|
+
[
|
20
|
+
:ami_description,
|
21
|
+
:ami_groups,
|
22
|
+
:ami_product_codes,
|
23
|
+
:ami_regions,
|
24
|
+
:ami_users,
|
25
|
+
:ami_virtualization_type,
|
26
|
+
:chroot_mounts,
|
27
|
+
:command_wrapper,
|
28
|
+
:copy_files,
|
29
|
+
:device_path,
|
30
|
+
:enhanced_networking,
|
31
|
+
:force_deregister,
|
32
|
+
:mount_path,
|
33
|
+
:mount_options,
|
34
|
+
:root_volume_size,
|
35
|
+
:tags
|
36
|
+
]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
class Packerman::Dsl::Builders::AmazonEbs < Packerman::Dsl::Builders
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
|
4
|
+
def type
|
5
|
+
"amazon-ebs"
|
6
|
+
end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def require_keys
|
10
|
+
[
|
11
|
+
:access_key,
|
12
|
+
:ami_name,
|
13
|
+
:instance_type,
|
14
|
+
:region,
|
15
|
+
:secret_key,
|
16
|
+
:source_ami,
|
17
|
+
:ssh_username,
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def optional_keys
|
22
|
+
[
|
23
|
+
:ami_block_device_mappings,
|
24
|
+
:ami_description,
|
25
|
+
:ami_groups,
|
26
|
+
:ami_product_codes,
|
27
|
+
:ami_regions,
|
28
|
+
:ami_users,
|
29
|
+
:associate_public_ip_address,
|
30
|
+
:availability_zone,
|
31
|
+
:enhanced_networking,
|
32
|
+
:force_deregister,
|
33
|
+
:iam_instance_profile,
|
34
|
+
:launch_block_device_mappings,
|
35
|
+
:run_tags,
|
36
|
+
:security_group_id,
|
37
|
+
:security_group_ids,
|
38
|
+
:spot_price,
|
39
|
+
:spot_price_auto_product,
|
40
|
+
:ssh_keypair_name,
|
41
|
+
:ssh_private_ip,
|
42
|
+
:subnet_id,
|
43
|
+
:tags,
|
44
|
+
:temporary_key_pair_name,
|
45
|
+
:token,
|
46
|
+
:user_data,
|
47
|
+
:user_data_file,
|
48
|
+
:vpc_id,
|
49
|
+
:windows_password_timeout,
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
class AmiBlockDeviceMapping < Packerman::Dsl::HashObject
|
54
|
+
class << self
|
55
|
+
def optional_keys
|
56
|
+
[
|
57
|
+
:delete_on_termination,
|
58
|
+
:device_name,
|
59
|
+
:encrypted,
|
60
|
+
:iops,
|
61
|
+
:no_device,
|
62
|
+
:snapshot_id,
|
63
|
+
:virtual_name,
|
64
|
+
:volume_type,
|
65
|
+
:volume_size
|
66
|
+
]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Packerman::Dsl::Builders::AmazonInstance < Packerman::Dsl::Builders
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
|
4
|
+
def type
|
5
|
+
"amazon-instance"
|
6
|
+
end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def require_keys
|
10
|
+
[
|
11
|
+
:access_key,
|
12
|
+
:account_id,
|
13
|
+
:ami_name,
|
14
|
+
:instance_type,
|
15
|
+
:region,
|
16
|
+
:s3_bucket,
|
17
|
+
:secret_key,
|
18
|
+
:source_ami,
|
19
|
+
:ssh_username,
|
20
|
+
:x509_cert_path,
|
21
|
+
:x509_key_path
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
def optional_keys
|
26
|
+
[
|
27
|
+
:ami_block_device_mappings,
|
28
|
+
:ami_description,
|
29
|
+
:ami_groups,
|
30
|
+
:ami_product_codes,
|
31
|
+
:ami_regions,
|
32
|
+
:ami_users,
|
33
|
+
:ami_virtualization_type,
|
34
|
+
:associate_public_ip_address,
|
35
|
+
:availability_zone,
|
36
|
+
:bundle_destination,
|
37
|
+
:bundle_prefix,
|
38
|
+
:bundle_upload_command,
|
39
|
+
:bundle_vol_command,
|
40
|
+
:ebs_optimized,
|
41
|
+
:enhanced_networking,
|
42
|
+
:force_deregister,
|
43
|
+
:iam_instance_profile,
|
44
|
+
:launch_block_device_mappings,
|
45
|
+
:run_tags,
|
46
|
+
:security_group_id,
|
47
|
+
:security_group_ids,
|
48
|
+
:spot_price,
|
49
|
+
:spot_price_auto_product,
|
50
|
+
:ssh_keypair_name,
|
51
|
+
:ssh_private_ip,
|
52
|
+
:subnet_id,
|
53
|
+
:tags,
|
54
|
+
:temporary_key_pair_name,
|
55
|
+
:user_data,
|
56
|
+
:user_data_file,
|
57
|
+
:vpc_id,
|
58
|
+
:x509_upload_path,
|
59
|
+
:windows_password_timeout
|
60
|
+
]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Packerman::Dsl::Builders::Docker < Packerman::Dsl::Builders
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def require_keys
|
6
|
+
[
|
7
|
+
#You must specify (only) one of commit, discard, or export_path.
|
8
|
+
:commit,
|
9
|
+
:discard,
|
10
|
+
:export_path,
|
11
|
+
:image
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
def optional_keys
|
16
|
+
[
|
17
|
+
:login,
|
18
|
+
:login_email,
|
19
|
+
:login_username,
|
20
|
+
:login_password,
|
21
|
+
:login_server,
|
22
|
+
:pull,
|
23
|
+
:run_command,
|
24
|
+
:volumes
|
25
|
+
]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Packerman::Dsl::HashObject < Packerman::Dsl
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
class << self
|
4
|
+
def register_to_repo(product)
|
5
|
+
product
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_subclass(_type)
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
def hash_key
|
13
|
+
require_keys + optional_keys
|
14
|
+
end
|
15
|
+
|
16
|
+
def inherited(klass)
|
17
|
+
Packerman::Dsl.const_set(klass.name.demodulize, klass)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Packerman::Dsl::Node
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@_hash = {}
|
6
|
+
@_hash[:type] = type
|
7
|
+
end
|
8
|
+
|
9
|
+
def type
|
10
|
+
self.class.name.demodulize.underscore
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(method, *args)
|
14
|
+
@_hash[method] ||= args.first
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_hash
|
18
|
+
keys = self.class.hash_key
|
19
|
+
@_hash.slice(*keys)
|
20
|
+
end
|
21
|
+
|
22
|
+
class_methods do
|
23
|
+
def hash_key
|
24
|
+
[:type] + require_keys + optional_keys
|
25
|
+
end
|
26
|
+
|
27
|
+
def require_keys
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
|
31
|
+
def optional_keys
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Packerman::Dsl::Provisioners::ChefSolo < Packerman::Dsl::Builders
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
|
4
|
+
def type
|
5
|
+
"chef-solo"
|
6
|
+
end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def optional_keys
|
10
|
+
[
|
11
|
+
:chef_environment,
|
12
|
+
:config_template,
|
13
|
+
:cookbook_paths,
|
14
|
+
:data_bags_path,
|
15
|
+
:encrypted_data_bag_secret_path,
|
16
|
+
:environments_path,
|
17
|
+
:execute_command,
|
18
|
+
:install_command,
|
19
|
+
:json,
|
20
|
+
:prevent_sudo,
|
21
|
+
:remote_cookbook_paths,
|
22
|
+
:roles_path,
|
23
|
+
:run_list,
|
24
|
+
:skip_install,
|
25
|
+
:staging_directory
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Packerman::Dsl::Provisioners::Shell < Packerman::Dsl::Builders
|
2
|
+
include Packerman::Dsl::Node
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def require_keys
|
6
|
+
[
|
7
|
+
# Exactly one of the following is required
|
8
|
+
:inline,
|
9
|
+
:script,
|
10
|
+
:scripts
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
def optional_keys
|
15
|
+
[
|
16
|
+
:binary,
|
17
|
+
:environment_vars,
|
18
|
+
:execute_command,
|
19
|
+
:inline_shebang,
|
20
|
+
:remote_path,
|
21
|
+
:start_retry_timeout
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Packerman::Dsl
|
2
|
+
class << self
|
3
|
+
def register(type: "", &block)
|
4
|
+
product = to_subclass(type).new
|
5
|
+
product.instance_eval(&block)
|
6
|
+
register_to_repo(product.to_hash)
|
7
|
+
end
|
8
|
+
|
9
|
+
def register_to_repo(product)
|
10
|
+
Packerman::Repository.instance.send("add_#{name.demodulize.underscore}", product)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_subclass(type)
|
14
|
+
"#{name}/#{type}".underscore.camelize.constantize
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Packerman::Evaluator
|
2
|
+
def evaluate(template)
|
3
|
+
Packerman::Repository.gather do
|
4
|
+
instance_eval(on_packerman(template))
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def on_packerman(template)
|
11
|
+
<<-EOS
|
12
|
+
class Packerman::Dsl
|
13
|
+
#{parse(template)}
|
14
|
+
end
|
15
|
+
EOS
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse(template)
|
19
|
+
parts = %w(Builders Provisioners)
|
20
|
+
parts.inject(template) do |memo, part|
|
21
|
+
memo.gsub(part, "#{part}.register")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Packerman::Repository
|
2
|
+
TEMPLATE_ATTRIBUTES = [:builders, :provisioners]
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@_repo = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
TEMPLATE_ATTRIBUTES.each do |attr|
|
9
|
+
define_method "add_#{attr}" do |hash|
|
10
|
+
@_repo[attr] ||= []
|
11
|
+
@_repo[attr] << hash
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_hash
|
17
|
+
@_repo
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def gather
|
22
|
+
yield
|
23
|
+
@_current_instance.to_hash.tap do
|
24
|
+
@_current_instance = nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def instance
|
29
|
+
@_current_instance ||= new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/packerman.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
3
|
+
require 'active_support/core_ext/object/json'
|
4
|
+
|
5
|
+
require 'singleton'
|
6
|
+
require 'packerman/version'
|
7
|
+
require 'packerman/repository'
|
8
|
+
require 'packerman/client'
|
9
|
+
require 'packerman/evaluator'
|
10
|
+
require 'packerman/dsl'
|
11
|
+
require 'packerman/dsl/node'
|
12
|
+
require 'packerman/dsl/hash_object'
|
13
|
+
require 'packerman/dsl/builders'
|
14
|
+
require 'packerman/dsl/builders/amazon_ebs'
|
15
|
+
require 'packerman/dsl/builders/amazon_instance'
|
16
|
+
require 'packerman/dsl/builders/amazon_chroot'
|
17
|
+
require 'packerman/dsl/builders/docker'
|
18
|
+
require 'packerman/dsl/provisioners'
|
19
|
+
require 'packerman/dsl/provisioners/shell'
|
20
|
+
require 'packerman/dsl/provisioners/chef_solo'
|
21
|
+
|
22
|
+
module Packerman
|
23
|
+
end
|
data/packerman.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'packerman/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "packerman"
|
8
|
+
spec.version = Packerman::VERSION
|
9
|
+
spec.authors = ["Masashi AKISUE"]
|
10
|
+
spec.email = ["masashi.akisue@aktsk.jp"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby DSL for Packer(www.packer.io)}
|
13
|
+
spec.homepage = "https://github.com/the40san/packerman"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = ["packerman"]
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "activesupport"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: packerman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masashi AKISUE
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- masashi.akisue@aktsk.jp
|
72
|
+
executables:
|
73
|
+
- packerman
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/packerman
|
87
|
+
- lib/packerman.rb
|
88
|
+
- lib/packerman/client.rb
|
89
|
+
- lib/packerman/dsl.rb
|
90
|
+
- lib/packerman/dsl/builders.rb
|
91
|
+
- lib/packerman/dsl/builders/amazon_chroot.rb
|
92
|
+
- lib/packerman/dsl/builders/amazon_ebs.rb
|
93
|
+
- lib/packerman/dsl/builders/amazon_instance.rb
|
94
|
+
- lib/packerman/dsl/builders/docker.rb
|
95
|
+
- lib/packerman/dsl/hash_object.rb
|
96
|
+
- lib/packerman/dsl/node.rb
|
97
|
+
- lib/packerman/dsl/provisioners.rb
|
98
|
+
- lib/packerman/dsl/provisioners/chef_solo.rb
|
99
|
+
- lib/packerman/dsl/provisioners/shell.rb
|
100
|
+
- lib/packerman/evaluator.rb
|
101
|
+
- lib/packerman/repository.rb
|
102
|
+
- lib/packerman/version.rb
|
103
|
+
- packerman.gemspec
|
104
|
+
homepage: https://github.com/the40san/packerman
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.5
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Ruby DSL for Packer(www.packer.io)
|
128
|
+
test_files: []
|