chefdore 0.0.1 → 0.2.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 +4 -4
- data/README.md +1 -13
- data/bin/chefdore +6 -0
- data/lib/chefdore/cli.rb +36 -0
- data/lib/chefdore/utils.rb +8 -2
- data/lib/chefdore/version.rb +1 -1
- data/spec/test.rb +58 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1d16716d772aa3482523cbdbc05658ede58f67
|
4
|
+
data.tar.gz: db14b08e76f51ad2a3f55b5ff2ca1806e61a5f6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfd2d8e196e2396c1244504ab29031607c73c11f62bf00ffc5eabd010d2bb0892bf50f267c9c92d3fccca209638ac32cf0670b1f2b436f2e57b42f0d6469e959
|
7
|
+
data.tar.gz: dd310f0adab513395a0d1d3d0bd3901c2cecc2d6c0b6692e369ed087f394709cf8bcf8a8e2b62e150f5edd0c82213d005c01bfc78ad1d42c2cd0520879315b53
|
data/README.md
CHANGED
@@ -4,23 +4,11 @@ Chef tool that was named after Dumbledore.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'chefdore'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
7
|
$ gem install chefdore
|
20
8
|
|
21
9
|
## Usage
|
22
10
|
|
23
|
-
|
11
|
+
knife role show base --format json | chefdore convert
|
24
12
|
|
25
13
|
## Contributing
|
26
14
|
|
data/bin/chefdore
ADDED
data/lib/chefdore/cli.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'chefdore'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Chefdore
|
6
|
+
class Cli < Thor
|
7
|
+
namespace "chefdore"
|
8
|
+
map %w(v V -v -V ver --version) => :version
|
9
|
+
|
10
|
+
desc "convert", "Convert Chef role to a Chef cookbook. Expects the json formatted Chef Role to be piped to this command."
|
11
|
+
def convert
|
12
|
+
ARGV.replace []
|
13
|
+
stdin = ARGF.read
|
14
|
+
|
15
|
+
begin
|
16
|
+
json = JSON.parse(stdin)
|
17
|
+
rescue JSON::ParserError => e
|
18
|
+
puts e.message
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
22
|
+
toa = %w(default_attributes override_attributes)
|
23
|
+
|
24
|
+
toa.each do |type|
|
25
|
+
attr = json[type]
|
26
|
+
prefix = type.split('_').first
|
27
|
+
Chefdore::Magic.convert(attr, prefix)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "version", "Display version information"
|
32
|
+
def version
|
33
|
+
say Chefdore::VERSION
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/chefdore/utils.rb
CHANGED
@@ -6,9 +6,15 @@ module Chefdore
|
|
6
6
|
convert(subval, prefix, path+[subkey])
|
7
7
|
end
|
8
8
|
elsif value.is_a?(Array)
|
9
|
-
|
9
|
+
value.each do |i|
|
10
|
+
if i.is_a?(Hash)
|
11
|
+
convert(i, prefix, path)
|
12
|
+
else
|
13
|
+
puts "#{prefix}#{path.map{|p| "[#{p.inspect}]"}.join('')} = #{value.inspect}"
|
14
|
+
end
|
15
|
+
end
|
10
16
|
else
|
11
|
-
puts "#{prefix}#{path.map{|p| "[
|
17
|
+
puts "#{prefix}#{path.map{|p| "[#{p.inspect}]"}.join('')} = #{value.inspect}"
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
data/lib/chefdore/version.rb
CHANGED
data/spec/test.rb
CHANGED
@@ -13,5 +13,62 @@ my_stuff = {
|
|
13
13
|
},
|
14
14
|
}
|
15
15
|
|
16
|
-
|
16
|
+
example = {
|
17
|
+
"developer_mode" => false,
|
18
|
+
"glance" => {
|
19
|
+
"image_upload" => true,
|
20
|
+
"images" => [
|
21
|
+
"cirros",
|
22
|
+
"precise"
|
23
|
+
]
|
24
|
+
},
|
25
|
+
"monitoring" => {
|
26
|
+
"metric_provider" => "collectd",
|
27
|
+
"procmon_provider" => "monit"
|
28
|
+
},
|
29
|
+
"mysql" => {
|
30
|
+
"allow_remote_root" => true,
|
31
|
+
"root_network_acl" => "%"
|
32
|
+
},
|
33
|
+
"nova" => {
|
34
|
+
"libvirt" => {
|
35
|
+
"virt_type" => "qemu"
|
36
|
+
},
|
37
|
+
"networks" => {
|
38
|
+
"private" => {
|
39
|
+
"bridge" => "br101",
|
40
|
+
"bridge_dev" => "eth0.101",
|
41
|
+
"dns1" => "8.8.8.8",
|
42
|
+
"dns2" => "8.8.4.4",
|
43
|
+
"ipv4_cidr" => "172.16.101.0/24",
|
44
|
+
"label" => "private"
|
45
|
+
},
|
46
|
+
"public" => {
|
47
|
+
"bridge" => "br100",
|
48
|
+
"bridge_dev" => "eth0.100",
|
49
|
+
"dns1" => "8.8.8.8",
|
50
|
+
"dns2" => "8.8.4.4",
|
51
|
+
"ipv4_cidr" => "10.10.100.0/24",
|
52
|
+
"label" => "public"
|
53
|
+
}
|
54
|
+
},
|
55
|
+
"ratelimit" => {
|
56
|
+
"api" => {
|
57
|
+
"enabled" => true
|
58
|
+
},
|
59
|
+
"volume" => {
|
60
|
+
"enabled" => true
|
61
|
+
}
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"osops_networks" => {
|
65
|
+
"management" => "192.168.1.0/24",
|
66
|
+
"nova" => "192.168.1.0/24",
|
67
|
+
"public" => "192.168.1.0/24"
|
68
|
+
},
|
69
|
+
"package_component" => "folsom"
|
70
|
+
}
|
71
|
+
|
72
|
+
Chefdore::Magic.convert(my_stuff, "my_stuff")
|
73
|
+
Chefdore::Magic.convert(example, "example")
|
17
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chefdore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Barnett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -41,7 +41,8 @@ dependencies:
|
|
41
41
|
description: Chef tool that can be used to do some helpful things.
|
42
42
|
email:
|
43
43
|
- jason.w.barnett@gmail.com
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- chefdore
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
48
|
files:
|
@@ -50,8 +51,10 @@ files:
|
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
52
53
|
- Rakefile
|
54
|
+
- bin/chefdore
|
53
55
|
- chefdore.gemspec
|
54
56
|
- lib/chefdore.rb
|
57
|
+
- lib/chefdore/cli.rb
|
55
58
|
- lib/chefdore/utils.rb
|
56
59
|
- lib/chefdore/version.rb
|
57
60
|
- spec/test.rb
|