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,77 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Startup script for chef-server
|
3
|
+
#
|
4
|
+
# chkconfig: - 65 35
|
5
|
+
# description: Server component of the Chef systems integration framework.
|
6
|
+
# processname: chef-server
|
7
|
+
#
|
8
|
+
# config: /etc/sysconfig/chef-server
|
9
|
+
# pidfile: /var/run/chef/chef-server.pid
|
10
|
+
|
11
|
+
# Source function library
|
12
|
+
. /etc/init.d/functions
|
13
|
+
|
14
|
+
[ -f /etc/sysconfig/chef-server ] && . /etc/sysconfig/chef-server
|
15
|
+
|
16
|
+
prog="chef-server"
|
17
|
+
PIDFILE=/var/run/chef/chef-server.pid
|
18
|
+
LOCKFILE=/var/lock/subsys/$prog
|
19
|
+
CONFIG=/etc/chef/server.rb
|
20
|
+
USER="chef"
|
21
|
+
GROUP="chef"
|
22
|
+
CLUSTER_NODES=2
|
23
|
+
LOGFILE=/var/log/chef/chef-server-merb.log
|
24
|
+
OPTIONS=
|
25
|
+
|
26
|
+
start() {
|
27
|
+
echo -n "Starting $prog:"
|
28
|
+
daemon chef-server -d -c "$CLUSTER_NODES" -C "$CONFIG" -u "$USER" -G "$GROUP" -L "$LOGFILE" -P "$PIDFILE" "$OPTIONS" ">/dev/null"
|
29
|
+
RETVAL=$?
|
30
|
+
echo
|
31
|
+
[ $RETVAL -eq 0 ] && touch ${LOCKFILE}
|
32
|
+
return $RETVAL
|
33
|
+
}
|
34
|
+
|
35
|
+
stop() {
|
36
|
+
echo -n "Stopping $prog: "
|
37
|
+
if [ -f $PIDFILE ]; then
|
38
|
+
killproc chef-server
|
39
|
+
RETVAL=$?
|
40
|
+
if [ $RETVAL -ne 0 ]; then
|
41
|
+
failure;
|
42
|
+
fi;
|
43
|
+
else
|
44
|
+
RETVAL=1
|
45
|
+
failure;
|
46
|
+
fi
|
47
|
+
rm -f $LOCKFILE
|
48
|
+
echo
|
49
|
+
return $RETVAL
|
50
|
+
}
|
51
|
+
|
52
|
+
case "$1" in
|
53
|
+
start)
|
54
|
+
start
|
55
|
+
;;
|
56
|
+
stop)
|
57
|
+
stop
|
58
|
+
;;
|
59
|
+
restart)
|
60
|
+
stop
|
61
|
+
start
|
62
|
+
;;
|
63
|
+
condrestart)
|
64
|
+
if [ -f $LOCKFILE ]; then
|
65
|
+
stop
|
66
|
+
start
|
67
|
+
fi
|
68
|
+
;;
|
69
|
+
status)
|
70
|
+
status chef-server
|
71
|
+
;;
|
72
|
+
*)
|
73
|
+
echo "Usage: $0 {start|stop|restart|condrestart|status}"
|
74
|
+
exit 1
|
75
|
+
esac
|
76
|
+
|
77
|
+
exit $RETVAL
|
data/lib/chef.rb
CHANGED
data/lib/chef/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -56,6 +57,10 @@ class Chef
|
|
56
57
|
# * build_node - Get the last known state, merge with local changes
|
57
58
|
# * register - Make sure we have an openid
|
58
59
|
# * authenticate - Authenticate with our openid
|
60
|
+
# * sync_library_files - Populate the local cache with all the library files
|
61
|
+
# * sync_provider_files - Populate the local cache with all the provider files
|
62
|
+
# * sync_resource_files - Populate the local cache with all the resource files
|
63
|
+
# * sync_attribute_files - Populate the local cache with all the attribute files
|
59
64
|
# * sync_definitions - Populate the local cache with all the definitions
|
60
65
|
# * sync_recipes - Populate the local cache with all the recipes
|
61
66
|
# * do_attribute_files - Populate the local cache with all attributes, and execute them
|
@@ -75,6 +80,8 @@ class Chef
|
|
75
80
|
build_node(@node_name)
|
76
81
|
save_node
|
77
82
|
sync_library_files
|
83
|
+
sync_provider_files
|
84
|
+
sync_resource_files
|
78
85
|
sync_attribute_files
|
79
86
|
sync_definitions
|
80
87
|
sync_recipes
|
@@ -97,7 +104,7 @@ class Chef
|
|
97
104
|
def run_solo
|
98
105
|
start_time = Time.now
|
99
106
|
Chef::Log.info("Starting Chef Solo Run")
|
100
|
-
|
107
|
+
|
101
108
|
determine_node_name
|
102
109
|
build_node(@node_name, true)
|
103
110
|
converge(true)
|
@@ -117,7 +124,7 @@ class Chef
|
|
117
124
|
|
118
125
|
def determine_node_name
|
119
126
|
run_ohai
|
120
|
-
unless
|
127
|
+
unless safe_name && node_name
|
121
128
|
@node_name ||= @ohai[:fqdn] ? @ohai[:fqdn] : @ohai[:hostname]
|
122
129
|
@safe_name = @node_name.gsub(/\./, '_')
|
123
130
|
end
|
@@ -324,7 +331,29 @@ class Chef
|
|
324
331
|
update_file_cache("libraries", @rest.get_rest("cookbooks/_library_files?node=#{@node.name}"))
|
325
332
|
true
|
326
333
|
end
|
334
|
+
|
335
|
+
# Gets all the provider files included in all the cookbooks available on the server,
|
336
|
+
# and loads them.
|
337
|
+
#
|
338
|
+
# === Returns
|
339
|
+
# true:: Always returns true
|
340
|
+
def sync_provider_files
|
341
|
+
Chef::Log.debug("Synchronizing providers")
|
342
|
+
update_file_cache("providers", @rest.get_rest("cookbooks/_provider_files?node=#{@node.name}"))
|
343
|
+
true
|
344
|
+
end
|
327
345
|
|
346
|
+
# Gets all the resource files included in all the cookbooks available on the server,
|
347
|
+
# and loads them.
|
348
|
+
#
|
349
|
+
# === Returns
|
350
|
+
# true:: Always returns true
|
351
|
+
def sync_resource_files
|
352
|
+
Chef::Log.debug("Synchronizing resources")
|
353
|
+
update_file_cache("resources", @rest.get_rest("cookbooks/_resource_files?node=#{@node.name}"))
|
354
|
+
true
|
355
|
+
end
|
356
|
+
|
328
357
|
# Gets all the definition files included in all the cookbooks available on the server,
|
329
358
|
# and loads them.
|
330
359
|
#
|
@@ -372,13 +401,9 @@ class Chef
|
|
372
401
|
Chef::Config[:cookbook_path] = File.join(Chef::Config[:file_cache_path], "cookbooks")
|
373
402
|
end
|
374
403
|
compile = Chef::Compile.new(@node)
|
375
|
-
|
376
|
-
compile.load_attributes
|
377
|
-
compile.load_definitions
|
378
|
-
compile.load_recipes
|
379
|
-
|
404
|
+
|
380
405
|
Chef::Log.debug("Converging node #{@safe_name}")
|
381
|
-
cr = Chef::Runner.new(@node, compile.collection)
|
406
|
+
cr = Chef::Runner.new(@node, compile.collection, compile.definitions, compile.cookbook_loader)
|
382
407
|
cr.converge
|
383
408
|
true
|
384
409
|
end
|
data/lib/chef/compile.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -27,8 +28,8 @@ class Chef
|
|
27
28
|
|
28
29
|
attr_accessor :node, :cookbook_loader, :collection, :definitions
|
29
30
|
|
30
|
-
# Creates a new Chef::Compile object
|
31
|
-
# a fully compiled recipe list for a node.
|
31
|
+
# Creates a new Chef::Compile object and populates its fields. This object gets
|
32
|
+
# used by the Chef Server to generate a fully compiled recipe list for a node.
|
32
33
|
#
|
33
34
|
# === Returns
|
34
35
|
# object<Chef::Compile>:: Duh. :)
|
@@ -40,6 +41,13 @@ class Chef
|
|
40
41
|
@recipes = Array.new
|
41
42
|
@default_attributes = Array.new
|
42
43
|
@override_attributes = Array.new
|
44
|
+
|
45
|
+
load_libraries
|
46
|
+
load_providers
|
47
|
+
load_resources
|
48
|
+
load_attributes
|
49
|
+
load_definitions
|
50
|
+
load_recipes
|
43
51
|
end
|
44
52
|
|
45
53
|
# Looks up the node via the "name" argument, first from CouchDB, then by calling
|
@@ -97,6 +105,30 @@ class Chef
|
|
97
105
|
end
|
98
106
|
true
|
99
107
|
end
|
108
|
+
|
109
|
+
# Load all the providers, from every cookbook, so they are available when we process
|
110
|
+
# the recipes.
|
111
|
+
#
|
112
|
+
# === Returns
|
113
|
+
# true:: Always returns true
|
114
|
+
def load_providers()
|
115
|
+
@cookbook_loader.each do |cookbook|
|
116
|
+
cookbook.load_providers
|
117
|
+
end
|
118
|
+
true
|
119
|
+
end
|
120
|
+
|
121
|
+
# Load all the resources, from every cookbook, so they are available when we process
|
122
|
+
# the recipes.
|
123
|
+
#
|
124
|
+
# === Returns
|
125
|
+
# true:: Always returns true
|
126
|
+
def load_resources()
|
127
|
+
@cookbook_loader.each do |cookbook|
|
128
|
+
cookbook.load_resources
|
129
|
+
end
|
130
|
+
true
|
131
|
+
end
|
100
132
|
|
101
133
|
# Load all the recipes specified in the node data (loaded via load_node, above.)
|
102
134
|
#
|
data/lib/chef/cookbook.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -19,12 +20,14 @@ require 'chef/log'
|
|
19
20
|
require 'chef/node'
|
20
21
|
require 'chef/resource_definition'
|
21
22
|
require 'chef/recipe'
|
23
|
+
require 'chef/mixin/convert_to_class_name'
|
22
24
|
|
23
25
|
class Chef
|
24
26
|
class Cookbook
|
27
|
+
include Chef::Mixin::ConvertToClassName
|
25
28
|
|
26
29
|
attr_accessor :attribute_files, :definition_files, :template_files, :remote_files,
|
27
|
-
:lib_files, :name
|
30
|
+
:lib_files, :resource_files, :provider_files, :name
|
28
31
|
attr_reader :recipe_files
|
29
32
|
|
30
33
|
# Creates a new Chef::Cookbook object.
|
@@ -40,6 +43,8 @@ class Chef
|
|
40
43
|
@recipe_files = Array.new
|
41
44
|
@recipe_names = Hash.new
|
42
45
|
@lib_files = Array.new
|
46
|
+
@resource_files = Array.new
|
47
|
+
@provider_files = Array.new
|
43
48
|
end
|
44
49
|
|
45
50
|
# Loads all the library files in this cookbook via require.
|
@@ -89,6 +94,28 @@ class Chef
|
|
89
94
|
end
|
90
95
|
results
|
91
96
|
end
|
97
|
+
|
98
|
+
# Loads all the resources in this cookbook.
|
99
|
+
#
|
100
|
+
# === Returns
|
101
|
+
# true:: Always returns true
|
102
|
+
def load_resources
|
103
|
+
@resource_files.each do |file|
|
104
|
+
Chef::Log.debug("Loading cookbook #{name}'s resources from #{file}")
|
105
|
+
Chef::Resource.build_from_file(name, file)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Loads all the providers in this cookbook.
|
110
|
+
#
|
111
|
+
# === Returns
|
112
|
+
# true:: Always returns true
|
113
|
+
def load_providers
|
114
|
+
@provider_files.each do |file|
|
115
|
+
Chef::Log.debug("Loading cookbook #{name}'s providers from #{file}")
|
116
|
+
Chef::Provider.build_from_file(name, file)
|
117
|
+
end
|
118
|
+
end
|
92
119
|
|
93
120
|
def recipe_files=(*args)
|
94
121
|
@recipe_files = args.flatten
|
@@ -141,4 +168,4 @@ class Chef
|
|
141
168
|
end
|
142
169
|
|
143
170
|
end
|
144
|
-
end
|
171
|
+
end
|
data/lib/chef/cookbook_loader.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
5
|
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
6
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
4
7
|
# License:: Apache License, Version 2.0
|
5
8
|
#
|
6
9
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -29,74 +32,86 @@ class Chef
|
|
29
32
|
def initialize()
|
30
33
|
@cookbook = Hash.new
|
31
34
|
@metadata = Hash.new
|
35
|
+
@ignore_regexes = Hash.new { |hsh, key| hsh[key] = Array.new }
|
32
36
|
load_cookbooks
|
33
37
|
end
|
34
38
|
|
35
39
|
def load_cookbooks
|
36
40
|
cookbook_settings = Hash.new
|
37
|
-
Chef::Config.cookbook_path.each do |cb_path|
|
41
|
+
[Chef::Config.cookbook_path].flatten.reverse.each do |cb_path|
|
38
42
|
Dir[File.join(cb_path, "*")].each do |cookbook|
|
39
43
|
next unless File.directory?(cookbook)
|
40
44
|
cookbook_name = File.basename(cookbook).to_sym
|
41
45
|
unless cookbook_settings.has_key?(cookbook_name)
|
42
46
|
cookbook_settings[cookbook_name] = {
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
47
|
+
:attribute_files => Hash.new,
|
48
|
+
:definition_files => Hash.new,
|
49
|
+
:recipe_files => Hash.new,
|
50
|
+
:template_files => Hash.new,
|
51
|
+
:remote_files => Hash.new,
|
52
|
+
:lib_files => Hash.new,
|
53
|
+
:resource_files => Hash.new,
|
54
|
+
:provider_files => Hash.new,
|
55
|
+
:metadata_files => Array.new
|
51
56
|
}
|
52
57
|
end
|
53
58
|
ignore_regexes = load_ignore_file(File.join(cookbook, "ignore"))
|
54
|
-
|
59
|
+
@ignore_regexes[cookbook_name].concat(ignore_regexes)
|
60
|
+
|
55
61
|
load_files_unless_basename(
|
56
62
|
File.join(cookbook, "attributes", "*.rb"),
|
57
|
-
cookbook_settings[cookbook_name][:attribute_files]
|
58
|
-
cookbook_settings[cookbook_name][:ignore_regexes]
|
63
|
+
cookbook_settings[cookbook_name][:attribute_files]
|
59
64
|
)
|
60
65
|
load_files_unless_basename(
|
61
66
|
File.join(cookbook, "definitions", "*.rb"),
|
62
|
-
cookbook_settings[cookbook_name][:definition_files]
|
63
|
-
cookbook_settings[cookbook_name][:ignore_regexes]
|
67
|
+
cookbook_settings[cookbook_name][:definition_files]
|
64
68
|
)
|
65
69
|
load_files_unless_basename(
|
66
70
|
File.join(cookbook, "recipes", "*.rb"),
|
67
|
-
cookbook_settings[cookbook_name][:recipe_files]
|
68
|
-
cookbook_settings[cookbook_name][:ignore_regexes]
|
71
|
+
cookbook_settings[cookbook_name][:recipe_files]
|
69
72
|
)
|
70
73
|
load_files_unless_basename(
|
71
74
|
File.join(cookbook, "libraries", "*.rb"),
|
72
|
-
cookbook_settings[cookbook_name][:lib_files]
|
73
|
-
cookbook_settings[cookbook_name][:ignore_regexes]
|
75
|
+
cookbook_settings[cookbook_name][:lib_files]
|
74
76
|
)
|
75
77
|
load_cascading_files(
|
76
78
|
"*.erb",
|
77
79
|
File.join(cookbook, "templates"),
|
78
|
-
cookbook_settings[cookbook_name][:template_files]
|
79
|
-
cookbook_settings[cookbook_name][:ignore_regexes]
|
80
|
+
cookbook_settings[cookbook_name][:template_files]
|
80
81
|
)
|
81
82
|
load_cascading_files(
|
82
83
|
"*",
|
83
84
|
File.join(cookbook, "files"),
|
84
|
-
cookbook_settings[cookbook_name][:remote_files]
|
85
|
-
cookbook_settings[cookbook_name][:ignore_regexes]
|
85
|
+
cookbook_settings[cookbook_name][:remote_files]
|
86
86
|
)
|
87
|
+
load_cascading_files(
|
88
|
+
"*.rb",
|
89
|
+
File.join(cookbook, "resources"),
|
90
|
+
cookbook_settings[cookbook_name][:resource_files]
|
91
|
+
)
|
92
|
+
load_cascading_files(
|
93
|
+
"*.rb",
|
94
|
+
File.join(cookbook, "providers"),
|
95
|
+
cookbook_settings[cookbook_name][:provider_files]
|
96
|
+
)
|
97
|
+
|
87
98
|
if File.exists?(File.join(cookbook, "metadata.json"))
|
88
99
|
cookbook_settings[cookbook_name][:metadata_files] << File.join(cookbook, "metadata.json")
|
89
100
|
end
|
90
101
|
end
|
91
102
|
end
|
103
|
+
remove_ignored_files_from(cookbook_settings)
|
104
|
+
|
92
105
|
cookbook_settings.each_key do |cookbook|
|
93
106
|
@cookbook[cookbook] = Chef::Cookbook.new(cookbook)
|
94
|
-
@cookbook[cookbook].attribute_files = cookbook_settings[cookbook][:attribute_files]
|
95
|
-
@cookbook[cookbook].definition_files = cookbook_settings[cookbook][:definition_files]
|
96
|
-
@cookbook[cookbook].recipe_files = cookbook_settings[cookbook][:recipe_files]
|
97
|
-
@cookbook[cookbook].template_files = cookbook_settings[cookbook][:template_files]
|
98
|
-
@cookbook[cookbook].remote_files = cookbook_settings[cookbook][:remote_files]
|
99
|
-
@cookbook[cookbook].lib_files = cookbook_settings[cookbook][:lib_files]
|
107
|
+
@cookbook[cookbook].attribute_files = cookbook_settings[cookbook][:attribute_files].values
|
108
|
+
@cookbook[cookbook].definition_files = cookbook_settings[cookbook][:definition_files].values
|
109
|
+
@cookbook[cookbook].recipe_files = cookbook_settings[cookbook][:recipe_files].values
|
110
|
+
@cookbook[cookbook].template_files = cookbook_settings[cookbook][:template_files].values
|
111
|
+
@cookbook[cookbook].remote_files = cookbook_settings[cookbook][:remote_files].values
|
112
|
+
@cookbook[cookbook].lib_files = cookbook_settings[cookbook][:lib_files].values
|
113
|
+
@cookbook[cookbook].resource_files = cookbook_settings[cookbook][:resource_files].values
|
114
|
+
@cookbook[cookbook].provider_files = cookbook_settings[cookbook][:provider_files].values
|
100
115
|
@metadata[cookbook] = Chef::Cookbook::Metadata.new(@cookbook[cookbook])
|
101
116
|
cookbook_settings[cookbook][:metadata_files].each do |meta_json|
|
102
117
|
@metadata[cookbook].from_json(IO.read(meta_json))
|
@@ -133,35 +148,32 @@ class Chef
|
|
133
148
|
results
|
134
149
|
end
|
135
150
|
|
136
|
-
def
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
151
|
+
def remove_ignored_files_from(cookbook_settings)
|
152
|
+
file_types_to_inspect = [ :attribute_files, :definition_files, :recipe_files, :template_files,
|
153
|
+
:remote_files, :lib_files, :resource_files, :provider_files]
|
154
|
+
|
155
|
+
@ignore_regexes.each do |cookbook_name, regexes|
|
156
|
+
regexes.each do |regex|
|
157
|
+
settings = cookbook_settings[cookbook_name]
|
158
|
+
file_types_to_inspect.each do |file_type|
|
159
|
+
settings[file_type].delete_if { |uniqname, fullpath| fullpath.match(regex) }
|
160
|
+
end
|
144
161
|
end
|
145
162
|
end
|
146
163
|
end
|
147
164
|
|
148
|
-
def
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
unless result_array.detect { |f| File.basename(f) == file_basename }
|
154
|
-
result_array << file
|
155
|
-
end
|
165
|
+
def load_cascading_files(file_glob, base_path, result_hash)
|
166
|
+
rm_base_path = /^#{base_path}\/(.+)$/
|
167
|
+
# To handle dotfiles like .ssh
|
168
|
+
Dir.glob(File.join(base_path, "**/#{file_glob}"), File::FNM_DOTMATCH).each do |file|
|
169
|
+
result_hash[rm_base_path.match(file)[1]] = file
|
156
170
|
end
|
157
171
|
end
|
158
172
|
|
159
|
-
def
|
160
|
-
|
161
|
-
|
162
|
-
skip = true if exp.match(file)
|
173
|
+
def load_files_unless_basename(file_glob, result_hash)
|
174
|
+
Dir[file_glob].each do |file|
|
175
|
+
result_hash[File.basename(file)] = file
|
163
176
|
end
|
164
|
-
skip
|
165
177
|
end
|
166
178
|
|
167
179
|
end
|