chef 0.7.10 → 0.7.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/distro/debian/etc/init.d/chef-client +175 -0
- data/distro/debian/etc/init.d/chef-indexer +175 -0
- data/distro/debian/etc/init.d/chef-server +120 -0
- data/distro/debian/man/man1/chef-indexer.1 +42 -0
- data/distro/debian/man/man1/chef-server.1 +108 -0
- data/distro/debian/man/man8/chef-client.8 +61 -0
- data/distro/debian/man/man8/chef-solo.8 +58 -0
- data/distro/redhat/etc/chef/client.rb +16 -0
- data/distro/redhat/etc/chef/indexer.rb +10 -0
- data/distro/redhat/etc/chef/server.rb +22 -0
- data/distro/redhat/etc/init.d/chef-client +74 -0
- data/distro/redhat/etc/init.d/chef-indexer +76 -0
- data/distro/redhat/etc/init.d/chef-server +77 -0
- data/lib/chef.rb +1 -1
- data/lib/chef/client.rb +33 -8
- data/lib/chef/compile.rb +34 -2
- data/lib/chef/cookbook.rb +29 -2
- data/lib/chef/cookbook_loader.rb +61 -49
- data/lib/chef/couchdb.rb +7 -3
- data/lib/chef/mixin/command.rb +67 -32
- data/lib/chef/mixin/convert_to_class_name.rb +48 -0
- data/lib/chef/mixin/find_preferred_file.rb +5 -14
- data/lib/chef/mixin/from_file.rb +14 -0
- data/lib/chef/mixin/generate_url.rb +2 -1
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +77 -0
- data/lib/chef/platform.rb +1 -1
- data/lib/chef/provider.rb +63 -2
- data/lib/chef/provider/cron.rb +75 -25
- data/lib/chef/provider/deploy.rb +281 -0
- data/lib/chef/provider/deploy/revision.rb +70 -0
- data/lib/chef/provider/deploy/timestamped.rb +33 -0
- data/lib/chef/provider/git.rb +194 -0
- data/lib/chef/provider/group.rb +2 -2
- data/lib/chef/provider/group/gpasswd.rb +50 -0
- data/lib/chef/provider/group/groupadd.rb +2 -16
- data/lib/chef/provider/group/usermod.rb +57 -0
- data/lib/chef/provider/ifconfig.rb +3 -3
- data/lib/chef/provider/mount.rb +0 -4
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/package/apt.rb +4 -4
- data/lib/chef/provider/package/dpkg.rb +9 -13
- data/lib/chef/provider/package/freebsd.rb +6 -6
- data/lib/chef/provider/package/macports.rb +4 -4
- data/lib/chef/provider/package/portage.rb +3 -3
- data/lib/chef/provider/package/rpm.rb +4 -4
- data/lib/chef/provider/package/rubygems.rb +10 -4
- data/lib/chef/provider/package/yum.rb +6 -6
- data/lib/chef/provider/remote_file.rb +14 -7
- data/lib/chef/provider/service.rb +8 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +8 -63
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/simple.rb +115 -0
- data/lib/chef/provider/subversion.rb +145 -0
- data/lib/chef/provider/template.rb +2 -0
- data/lib/chef/provider/user.rb +2 -2
- data/lib/chef/recipe.rb +9 -75
- data/lib/chef/resource.rb +131 -7
- data/lib/chef/resource/cron.rb +36 -0
- data/lib/chef/resource/deploy.rb +360 -0
- data/lib/chef/resource/deploy_revision.rb +35 -0
- data/lib/chef/resource/git.rb +36 -0
- data/lib/chef/resource/group.rb +2 -0
- data/lib/chef/resource/scm.rb +129 -0
- data/lib/chef/resource/subversion.rb +33 -0
- data/lib/chef/resource/timestamped_deploy.rb +31 -0
- data/lib/chef/resource_collection.rb +32 -4
- data/lib/chef/runner.rb +35 -28
- metadata +40 -11
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
class Resource
|
21
|
+
|
22
|
+
# Convenience class for using the deploy resource with the revision
|
23
|
+
# deployment strategy (provider)
|
24
|
+
class DeployRevision < Chef::Resource::Deploy
|
25
|
+
def initialize(*args, &block)
|
26
|
+
super
|
27
|
+
@provider = Chef::Provider::Deploy::Revision
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class DeployBranch < Chef::Resource::DeployRevision
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "chef/resource/scm"
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Resource
|
23
|
+
class Git < Chef::Resource::Scm
|
24
|
+
|
25
|
+
def initialize(name, collection=nil, node=nil)
|
26
|
+
super(name, collection, node)
|
27
|
+
@resource_name = :git
|
28
|
+
@provider = Chef::Provider::Git
|
29
|
+
end
|
30
|
+
|
31
|
+
alias :branch :revision
|
32
|
+
alias :reference :revision
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/chef/resource/group.rb
CHANGED
@@ -0,0 +1,129 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
|
20
|
+
require 'chef/resource'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Resource
|
24
|
+
class Scm < Chef::Resource
|
25
|
+
|
26
|
+
def initialize(name, collection=nil, node=nil)
|
27
|
+
super(name, collection, node)
|
28
|
+
@destination = name
|
29
|
+
@resource_name = :scm
|
30
|
+
@enable_submodules = false
|
31
|
+
@revision = "HEAD"
|
32
|
+
@remote = "origin"
|
33
|
+
@ssh_wrapper = nil
|
34
|
+
@depth = nil
|
35
|
+
@allowed_actions.push(:checkout, :export, :sync, :diff, :log)
|
36
|
+
end
|
37
|
+
|
38
|
+
def destination(arg=nil)
|
39
|
+
set_or_return(
|
40
|
+
:destination,
|
41
|
+
arg,
|
42
|
+
:kind_of => String
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def repository(arg=nil)
|
47
|
+
set_or_return(
|
48
|
+
:repository,
|
49
|
+
arg,
|
50
|
+
:kind_of => String
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def revision(arg=nil)
|
55
|
+
set_or_return(
|
56
|
+
:revision,
|
57
|
+
arg,
|
58
|
+
:kind_of => String
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def user(arg=nil)
|
63
|
+
set_or_return(
|
64
|
+
:user,
|
65
|
+
arg,
|
66
|
+
:kind_of => [String, Integer]
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def svn_username(arg=nil)
|
71
|
+
set_or_return(
|
72
|
+
:svn_username,
|
73
|
+
arg,
|
74
|
+
:kind_of => String
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def svn_password(arg=nil)
|
79
|
+
set_or_return(
|
80
|
+
:svn_password,
|
81
|
+
arg,
|
82
|
+
:kind_of => String
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
def svn_arguments(arg=nil)
|
87
|
+
set_or_return(
|
88
|
+
:svn_arguments,
|
89
|
+
arg,
|
90
|
+
:kind_of => String
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Capistrano and git-deploy use ``shallow clone''
|
95
|
+
def depth(arg=nil)
|
96
|
+
set_or_return(
|
97
|
+
:depth,
|
98
|
+
arg,
|
99
|
+
:kind_of => Integer
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
def enable_submodules(arg=nil)
|
104
|
+
set_or_return(
|
105
|
+
:enable_submodules,
|
106
|
+
arg,
|
107
|
+
:kind_of => [TrueClass, FalseClass]
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
def remote(arg=nil)
|
112
|
+
set_or_return(
|
113
|
+
:remote,
|
114
|
+
arg,
|
115
|
+
:kind_of => String
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
def ssh_wrapper(arg=nil)
|
120
|
+
set_or_return(
|
121
|
+
:ssh_wrapper,
|
122
|
+
arg,
|
123
|
+
:kind_of => String
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "chef/resource/scm"
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Resource
|
23
|
+
class Subversion < Chef::Resource::Scm
|
24
|
+
|
25
|
+
def initialize(name, collection=nil, node=nil)
|
26
|
+
super(name, collection, node)
|
27
|
+
@resource_name = :subversion
|
28
|
+
@provider = Chef::Provider::Subversion
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
class Resource
|
21
|
+
|
22
|
+
# Convenience class for using the deploy resource with the timestamped
|
23
|
+
# deployment strategy (provider)
|
24
|
+
class TimestampedDeploy < Chef::Resource::Deploy
|
25
|
+
def initialize(*args, &block)
|
26
|
+
super(*args, &block)
|
27
|
+
@provider = Chef::Provider::Deploy::Timestamped
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
#
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008, 2009 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -21,10 +22,11 @@ require 'chef/resource'
|
|
21
22
|
class Chef
|
22
23
|
class ResourceCollection
|
23
24
|
include Enumerable
|
24
|
-
|
25
|
+
|
25
26
|
def initialize
|
26
27
|
@resources = Array.new
|
27
28
|
@resources_by_name = Hash.new
|
29
|
+
@insert_after_idx = nil
|
28
30
|
end
|
29
31
|
|
30
32
|
def [](index)
|
@@ -36,7 +38,7 @@ class Chef
|
|
36
38
|
@resources[index] = arg
|
37
39
|
@resources_by_name[arg.to_s] = index
|
38
40
|
end
|
39
|
-
|
41
|
+
|
40
42
|
def <<(*args)
|
41
43
|
args.flatten.each do |a|
|
42
44
|
is_chef_resource(a)
|
@@ -44,6 +46,25 @@ class Chef
|
|
44
46
|
@resources_by_name[a.to_s] = @resources.length - 1
|
45
47
|
end
|
46
48
|
end
|
49
|
+
|
50
|
+
def insert(resource)
|
51
|
+
is_chef_resource(resource)
|
52
|
+
if @insert_after_idx
|
53
|
+
# in the middle of executing a run, so any resources inserted now should
|
54
|
+
# be placed after the most recent addition done by the currently executing
|
55
|
+
# resource
|
56
|
+
@resources.insert(@insert_after_idx + 1, resource)
|
57
|
+
# update name -> location mappings and register new resource
|
58
|
+
@resources_by_name.each_key do |key|
|
59
|
+
@resources_by_name[key] += 1 if @resources_by_name[key] > @insert_after_idx
|
60
|
+
end
|
61
|
+
@resources_by_name[resource.to_s] = @insert_after_idx + 1
|
62
|
+
@insert_after_idx += 1
|
63
|
+
else
|
64
|
+
@resources << resource
|
65
|
+
@resources_by_name[resource.to_s] = @resources.length - 1
|
66
|
+
end
|
67
|
+
end
|
47
68
|
|
48
69
|
def push(*args)
|
49
70
|
args.flatten.each do |a|
|
@@ -58,6 +79,13 @@ class Chef
|
|
58
79
|
yield r
|
59
80
|
end
|
60
81
|
end
|
82
|
+
|
83
|
+
def execute_each_resource
|
84
|
+
@resources.each_with_index do |r, idx|
|
85
|
+
@insert_after_idx = idx
|
86
|
+
yield r
|
87
|
+
end
|
88
|
+
end
|
61
89
|
|
62
90
|
def each_index
|
63
91
|
@resources.each_index do |i|
|
@@ -173,4 +201,4 @@ class Chef
|
|
173
201
|
true
|
174
202
|
end
|
175
203
|
end
|
176
|
-
end
|
204
|
+
end
|
data/lib/chef/runner.rb
CHANGED
@@ -26,7 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
include Chef::Mixin::ParamsValidate
|
28
28
|
|
29
|
-
def initialize(node, collection)
|
29
|
+
def initialize(node, collection, definitions={}, cookbook_loader=nil)
|
30
30
|
validate(
|
31
31
|
{
|
32
32
|
:node => node,
|
@@ -43,22 +43,49 @@ class Chef
|
|
43
43
|
)
|
44
44
|
@node = node
|
45
45
|
@collection = collection
|
46
|
+
@definitions = definitions
|
47
|
+
@cookbook_loader = cookbook_loader
|
46
48
|
end
|
47
49
|
|
48
50
|
def build_provider(resource)
|
49
51
|
provider_klass = resource.provider
|
50
52
|
provider_klass ||= Chef::Platform.find_provider_for_node(@node, resource)
|
51
53
|
Chef::Log.debug("#{resource} using #{provider_klass.to_s}")
|
52
|
-
provider = provider_klass.new(@node, resource)
|
54
|
+
provider = provider_klass.new(@node, resource, @collection, @definitions, @cookbook_loader)
|
53
55
|
provider.load_current_resource
|
54
56
|
provider
|
55
57
|
end
|
56
|
-
|
58
|
+
|
59
|
+
def run_action(resource, ra)
|
60
|
+
provider = build_provider(resource)
|
61
|
+
provider.send("action_#{ra}")
|
62
|
+
|
63
|
+
if resource.updated
|
64
|
+
resource.actions.each_key do |action|
|
65
|
+
if resource.actions[action].has_key?(:immediate)
|
66
|
+
resource.actions[action][:immediate].each do |r|
|
67
|
+
Chef::Log.info("#{resource} sending #{action} action to #{r} (immediate)")
|
68
|
+
run_action(r, action)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if resource.actions[action].has_key?(:delayed)
|
72
|
+
resource.actions[action][:delayed].each do |r|
|
73
|
+
@delayed_actions[r] = Hash.new unless @delayed_actions.has_key?(r)
|
74
|
+
@delayed_actions[r][action] = Array.new unless @delayed_actions[r].has_key?(action)
|
75
|
+
@delayed_actions[r][action] << lambda {
|
76
|
+
Chef::Log.info("#{resource} sending #{action} action to #{r} (delayed)")
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
57
84
|
def converge
|
58
85
|
|
59
|
-
delayed_actions = Hash.new
|
86
|
+
@delayed_actions = Hash.new
|
60
87
|
|
61
|
-
@collection.
|
88
|
+
@collection.execute_each_resource do |resource|
|
62
89
|
begin
|
63
90
|
Chef::Log.debug("Processing #{resource}")
|
64
91
|
|
@@ -81,27 +108,7 @@ class Chef
|
|
81
108
|
# Walk the actions for this resource, building the provider and running each.
|
82
109
|
action_list = resource.action.kind_of?(Array) ? resource.action : [ resource.action ]
|
83
110
|
action_list.each do |ra|
|
84
|
-
|
85
|
-
provider.send("action_#{ra}")
|
86
|
-
if resource.updated
|
87
|
-
resource.actions.each_key do |action|
|
88
|
-
if resource.actions[action].has_key?(:immediate)
|
89
|
-
resource.actions[action][:immediate].each do |r|
|
90
|
-
Chef::Log.info("#{resource} sending #{action} action to #{r} (immediate)")
|
91
|
-
build_provider(r).send("action_#{action}")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
if resource.actions[action].has_key?(:delayed)
|
95
|
-
resource.actions[action][:delayed].each do |r|
|
96
|
-
delayed_actions[r] = Hash.new unless delayed_actions.has_key?(r)
|
97
|
-
delayed_actions[r][action] = Array.new unless delayed_actions[r].has_key?(action)
|
98
|
-
delayed_actions[r][action] << lambda {
|
99
|
-
Chef::Log.info("#{resource} sending #{action} action to #{r} (delayed)")
|
100
|
-
}
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
111
|
+
run_action(resource, ra)
|
105
112
|
end
|
106
113
|
rescue => e
|
107
114
|
Chef::Log.error("#{resource} (#{resource.source_line}) had an error:\n#{e}\n#{e.backtrace}")
|
@@ -110,10 +117,10 @@ class Chef
|
|
110
117
|
end
|
111
118
|
|
112
119
|
# Run all our :delayed actions
|
113
|
-
delayed_actions.each do |resource, action_hash|
|
120
|
+
@delayed_actions.each do |resource, action_hash|
|
114
121
|
action_hash.each do |action, log_array|
|
115
122
|
log_array.each { |l| l.call } # Call each log message
|
116
|
-
|
123
|
+
run_action(resource, action)
|
117
124
|
end
|
118
125
|
end
|
119
126
|
|