knife-stencil 1.0.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 +17 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE +674 -0
- data/README.md +128 -0
- data/Rakefile +6 -0
- data/examples/deadfish/Berksfile +3 -0
- data/examples/deadfish/Berksfile.lock +7 -0
- data/examples/deadfish/README.md +21 -0
- data/examples/deadfish/base.json +14 -0
- data/examples/deadfish/clouds/ec2.json +23 -0
- data/examples/deadfish/clouds/hp.json +19 -0
- data/examples/deadfish/environments/live.json +7 -0
- data/examples/deadfish/live-pretendtown-app.json +9 -0
- data/examples/deadfish/live-pretendtown-lb.json +9 -0
- data/examples/deadfish/services/app.json +7 -0
- data/examples/deadfish/services/lb.json +7 -0
- data/knife-stencil.gemspec +26 -0
- data/lib/chef/knife/stencil_base.rb +86 -0
- data/lib/chef/knife/stencil_collection.rb +96 -0
- data/lib/chef/knife/stencil_file.rb +44 -0
- data/lib/chef/knife/stencil_monkey_patch.rb +61 -0
- data/lib/chef/knife/stencil_node.rb +52 -0
- data/lib/chef/knife/stencil_server_create.rb +49 -0
- data/lib/chef/knife/stencil_server_delete.rb +52 -0
- data/lib/chef/knife/stencil_server_explain.rb +44 -0
- data/lib/knife-stencil/version.rb +6 -0
- metadata +128 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013, OpsUnit Ltd.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'chef/knife/stencil_base'
|
19
|
+
require 'json'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
|
24
|
+
# Objects of this class represent the contents of your various stencil files
|
25
|
+
class StencilFile
|
26
|
+
|
27
|
+
include JSON
|
28
|
+
include Knife::StencilBase
|
29
|
+
|
30
|
+
attr_accessor :path, :options, :inherits, :matches
|
31
|
+
|
32
|
+
def initialize(path, options={})
|
33
|
+
deserialized = JSON.parse(IO.read(path), :symbolize_names => true)
|
34
|
+
|
35
|
+
@path = normalize_path(path, stencil_root)
|
36
|
+
@options = deserialized[:options] || []
|
37
|
+
@inherits = deserialized[:inherits] || []
|
38
|
+
@matches = deserialized[:matches] || nil
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013, OpsUnit Ltd.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'chef/knife/stencil_base'
|
19
|
+
require 'chef/knife/stencil_collection'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
|
24
|
+
include Knife::StencilBase
|
25
|
+
|
26
|
+
def merge_configs
|
27
|
+
# Apply config file settings on top of mixlib-cli defaults
|
28
|
+
combined_config = default_config.merge(config_file_settings)
|
29
|
+
# Apply user-supplied options on top of the above combination
|
30
|
+
combined_config = combined_config.merge(config)
|
31
|
+
# replace the config hash from mixlib-cli with our own.
|
32
|
+
# Need to use the mutate-in-place #replace method instead of assigning to
|
33
|
+
# the instance variable because other code may have a reference to the
|
34
|
+
# original config hash object.
|
35
|
+
config.replace(combined_config)
|
36
|
+
|
37
|
+
# If the stencil plugin has been invoked, parse some additional configuration
|
38
|
+
# from the stencils.
|
39
|
+
if invoked_as_stencil?
|
40
|
+
new_config = config
|
41
|
+
stencil_collection = Knife::StencilCollection.new
|
42
|
+
|
43
|
+
stencil_collection.for_name(locate_config_value(:chef_node_name)).each do |stencil|
|
44
|
+
new_config.merge!(stencil.options)
|
45
|
+
end
|
46
|
+
|
47
|
+
config.replace(new_config)
|
48
|
+
combined_config = config
|
49
|
+
config.each_pair do |k,v|
|
50
|
+
Chef::Config[:knife][k.to_sym] = v
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def config
|
57
|
+
return Chef::Config[:knife]
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013, OpsUnit Ltd.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'chef/knife/stencil_base'
|
19
|
+
|
20
|
+
class Chef
|
21
|
+
class Knife
|
22
|
+
|
23
|
+
# A node (server/host)
|
24
|
+
class StencilNode
|
25
|
+
|
26
|
+
include Knife::StencilBase
|
27
|
+
|
28
|
+
attr_accessor :name, :config
|
29
|
+
|
30
|
+
def initialize(name, config, options={})
|
31
|
+
@name = name
|
32
|
+
@config = config
|
33
|
+
explain("Configuration #{config}")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create that node in the appropriate cloud
|
37
|
+
def create
|
38
|
+
klass = build_plugin_klass(config[:plugin], :server, :create)
|
39
|
+
obj = klass.new
|
40
|
+
obj.run
|
41
|
+
end
|
42
|
+
|
43
|
+
# Remove that node from the appropriate cloud
|
44
|
+
def delete
|
45
|
+
klass = build_plugin_klass(config[:plugin], :server, :delete)
|
46
|
+
obj = klass.new
|
47
|
+
obj.run
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013, OpsUnit Ltd.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require 'chef/knife/stencil_monkey_patch'
|
18
|
+
require 'chef/knife/stencil_node'
|
19
|
+
require 'chef/knife/stencil_base'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
|
24
|
+
# Knife-plugin boilerplate class for the 'create' sub-command
|
25
|
+
class StencilServerCreate < Knife
|
26
|
+
|
27
|
+
include Knife::StencilBase
|
28
|
+
|
29
|
+
deps do
|
30
|
+
require 'chef/knife/bootstrap'
|
31
|
+
Chef::Knife::Bootstrap.load_deps
|
32
|
+
end
|
33
|
+
|
34
|
+
banner "knife stencil server create -N HOSTNAME"
|
35
|
+
|
36
|
+
option :chef_node_name,
|
37
|
+
:short => "-N NAME",
|
38
|
+
:long => "--node-name",
|
39
|
+
:description => "The Chef node name for your new node",
|
40
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:chef_node_name] = key },
|
41
|
+
:required => true
|
42
|
+
|
43
|
+
def run
|
44
|
+
stencil_node = Chef::Knife::StencilNode.new(locate_config_value(:chef_node_name), config)
|
45
|
+
stencil_node.create
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013, OpsUnit Ltd.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Knife
|
20
|
+
|
21
|
+
# Knife-plugin boilerplate class for the 'delete' sub-command
|
22
|
+
class StencilServerDelete < Knife
|
23
|
+
|
24
|
+
include Knife::StencilBase
|
25
|
+
|
26
|
+
deps do
|
27
|
+
require 'chef/knife/bootstrap'
|
28
|
+
Chef::Knife::Bootstrap.load_deps
|
29
|
+
end
|
30
|
+
|
31
|
+
banner "knife stencil server delete -N HOSTNAME"
|
32
|
+
|
33
|
+
option :chef_node_name,
|
34
|
+
:short => "-N NAME",
|
35
|
+
:long => "--node-name",
|
36
|
+
:description => "The Chef node to delete",
|
37
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:chef_node_name] = key },
|
38
|
+
:required => true
|
39
|
+
|
40
|
+
option :purge,
|
41
|
+
:short => "-P",
|
42
|
+
:long => "--purge",
|
43
|
+
:description => "Destroy corresponding node and client on the Chef Server, in addition to destroying the node itself.",
|
44
|
+
:required => false
|
45
|
+
|
46
|
+
def run
|
47
|
+
stencil_node = Chef::Knife::StencilNode.new(locate_config_value(:chef_node_name), config)
|
48
|
+
stencil_node.delete
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2013, OpsUnit Ltd.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#
|
17
|
+
require 'chef/knife/stencil_monkey_patch'
|
18
|
+
require 'chef/knife/stencil_node'
|
19
|
+
require 'chef/knife/stencil_base'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
|
24
|
+
# Knife-plugin boilerplate class for the 'explain' sub-command
|
25
|
+
class StencilServerExplain < Knife
|
26
|
+
|
27
|
+
include Knife::StencilBase
|
28
|
+
|
29
|
+
banner "knife stencil server explain -N HOSTNAME"
|
30
|
+
|
31
|
+
option :chef_node_name,
|
32
|
+
:short => "-N NAME",
|
33
|
+
:long => "--node-name",
|
34
|
+
:description => "The Chef node name for your new node",
|
35
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:chef_node_name] = key },
|
36
|
+
:required => true
|
37
|
+
|
38
|
+
def run
|
39
|
+
stencil_node = Chef::Knife::StencilNode.new(locate_config_value(:chef_node_name), config)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-stencil
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sam
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: chef
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 11.6.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 11.6.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Chef knife plugin stencil system with multi-cloud support
|
70
|
+
email:
|
71
|
+
- sam.pointer@opsunit.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- examples/deadfish/Berksfile
|
83
|
+
- examples/deadfish/Berksfile.lock
|
84
|
+
- examples/deadfish/README.md
|
85
|
+
- examples/deadfish/base.json
|
86
|
+
- examples/deadfish/clouds/ec2.json
|
87
|
+
- examples/deadfish/clouds/hp.json
|
88
|
+
- examples/deadfish/environments/live.json
|
89
|
+
- examples/deadfish/live-pretendtown-app.json
|
90
|
+
- examples/deadfish/live-pretendtown-lb.json
|
91
|
+
- examples/deadfish/services/app.json
|
92
|
+
- examples/deadfish/services/lb.json
|
93
|
+
- knife-stencil.gemspec
|
94
|
+
- lib/chef/knife/stencil_base.rb
|
95
|
+
- lib/chef/knife/stencil_collection.rb
|
96
|
+
- lib/chef/knife/stencil_file.rb
|
97
|
+
- lib/chef/knife/stencil_monkey_patch.rb
|
98
|
+
- lib/chef/knife/stencil_node.rb
|
99
|
+
- lib/chef/knife/stencil_server_create.rb
|
100
|
+
- lib/chef/knife/stencil_server_delete.rb
|
101
|
+
- lib/chef/knife/stencil_server_explain.rb
|
102
|
+
- lib/knife-stencil/version.rb
|
103
|
+
homepage: https://github.com/opsunit/knife-stencil
|
104
|
+
licenses:
|
105
|
+
- GPL3
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Chef Knife plugin stencil system. Pass only the hostname and inherit all
|
127
|
+
other options. Seamlessly launch in multiple clouds
|
128
|
+
test_files: []
|