garcun 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +17 -0
  3. data/.gitignore +197 -0
  4. data/.rspec +2 -0
  5. data/Gemfile +22 -0
  6. data/LICENSE +201 -0
  7. data/README.md +521 -0
  8. data/Rakefile +47 -0
  9. data/garcun.gemspec +83 -0
  10. data/lib/garcon.rb +290 -0
  11. data/lib/garcon/chef/chef_helpers.rb +343 -0
  12. data/lib/garcon/chef/coerce/coercer.rb +134 -0
  13. data/lib/garcon/chef/coerce/coercions/boolean_definitions.rb +34 -0
  14. data/lib/garcon/chef/coerce/coercions/date_definitions.rb +32 -0
  15. data/lib/garcon/chef/coerce/coercions/date_time_definitions.rb +32 -0
  16. data/lib/garcon/chef/coerce/coercions/fixnum_definitions.rb +34 -0
  17. data/lib/garcon/chef/coerce/coercions/float_definitions.rb +32 -0
  18. data/lib/garcon/chef/coerce/coercions/hash_definitions.rb +29 -0
  19. data/lib/garcon/chef/coerce/coercions/integer_definitions.rb +31 -0
  20. data/lib/garcon/chef/coerce/coercions/string_definitions.rb +45 -0
  21. data/lib/garcon/chef/coerce/coercions/time_definitions.rb +32 -0
  22. data/lib/garcon/chef/handler/devreporter.rb +127 -0
  23. data/lib/garcon/chef/log.rb +64 -0
  24. data/lib/garcon/chef/node.rb +100 -0
  25. data/lib/garcon/chef/provider/civilize.rb +209 -0
  26. data/lib/garcon/chef/provider/development.rb +159 -0
  27. data/lib/garcon/chef/provider/download.rb +420 -0
  28. data/lib/garcon/chef/provider/house_keeping.rb +265 -0
  29. data/lib/garcon/chef/provider/node_cache.rb +31 -0
  30. data/lib/garcon/chef/provider/partial.rb +183 -0
  31. data/lib/garcon/chef/provider/recovery.rb +80 -0
  32. data/lib/garcon/chef/provider/zip_file.rb +271 -0
  33. data/lib/garcon/chef/resource/attribute.rb +52 -0
  34. data/lib/garcon/chef/resource/base_dsl.rb +174 -0
  35. data/lib/garcon/chef/resource/blender.rb +140 -0
  36. data/lib/garcon/chef/resource/lazy_eval.rb +66 -0
  37. data/lib/garcon/chef/resource/resource_name.rb +109 -0
  38. data/lib/garcon/chef/secret_bag.rb +204 -0
  39. data/lib/garcon/chef/validations.rb +76 -0
  40. data/lib/garcon/chef_inclusions.rb +151 -0
  41. data/lib/garcon/configuration.rb +138 -0
  42. data/lib/garcon/core_ext.rb +39 -0
  43. data/lib/garcon/core_ext/array.rb +27 -0
  44. data/lib/garcon/core_ext/binding.rb +64 -0
  45. data/lib/garcon/core_ext/boolean.rb +66 -0
  46. data/lib/garcon/core_ext/duration.rb +271 -0
  47. data/lib/garcon/core_ext/enumerable.rb +34 -0
  48. data/lib/garcon/core_ext/file.rb +127 -0
  49. data/lib/garcon/core_ext/filetest.rb +62 -0
  50. data/lib/garcon/core_ext/hash.rb +279 -0
  51. data/lib/garcon/core_ext/kernel.rb +159 -0
  52. data/lib/garcon/core_ext/lazy.rb +222 -0
  53. data/lib/garcon/core_ext/method_access.rb +243 -0
  54. data/lib/garcon/core_ext/module.rb +92 -0
  55. data/lib/garcon/core_ext/nil.rb +53 -0
  56. data/lib/garcon/core_ext/numeric.rb +44 -0
  57. data/lib/garcon/core_ext/object.rb +342 -0
  58. data/lib/garcon/core_ext/pathname.rb +152 -0
  59. data/lib/garcon/core_ext/process.rb +41 -0
  60. data/lib/garcon/core_ext/random.rb +497 -0
  61. data/lib/garcon/core_ext/string.rb +312 -0
  62. data/lib/garcon/core_ext/struct.rb +49 -0
  63. data/lib/garcon/core_ext/symbol.rb +170 -0
  64. data/lib/garcon/core_ext/time.rb +234 -0
  65. data/lib/garcon/exceptions.rb +101 -0
  66. data/lib/garcon/inflections.rb +237 -0
  67. data/lib/garcon/inflections/defaults.rb +79 -0
  68. data/lib/garcon/inflections/inflections.rb +182 -0
  69. data/lib/garcon/inflections/rules_collection.rb +37 -0
  70. data/lib/garcon/secret.rb +271 -0
  71. data/lib/garcon/stash/format.rb +114 -0
  72. data/lib/garcon/stash/journal.rb +226 -0
  73. data/lib/garcon/stash/queue.rb +83 -0
  74. data/lib/garcon/stash/serializer.rb +86 -0
  75. data/lib/garcon/stash/store.rb +435 -0
  76. data/lib/garcon/task.rb +31 -0
  77. data/lib/garcon/task/atomic.rb +151 -0
  78. data/lib/garcon/task/atomic_boolean.rb +127 -0
  79. data/lib/garcon/task/condition.rb +99 -0
  80. data/lib/garcon/task/copy_on_notify_observer_set.rb +154 -0
  81. data/lib/garcon/task/copy_on_write_observer_set.rb +153 -0
  82. data/lib/garcon/task/count_down_latch.rb +92 -0
  83. data/lib/garcon/task/delay.rb +196 -0
  84. data/lib/garcon/task/dereferenceable.rb +144 -0
  85. data/lib/garcon/task/event.rb +119 -0
  86. data/lib/garcon/task/executor.rb +275 -0
  87. data/lib/garcon/task/executor_options.rb +59 -0
  88. data/lib/garcon/task/future.rb +107 -0
  89. data/lib/garcon/task/immediate_executor.rb +84 -0
  90. data/lib/garcon/task/ivar.rb +171 -0
  91. data/lib/garcon/task/lazy_reference.rb +74 -0
  92. data/lib/garcon/task/monotonic_time.rb +69 -0
  93. data/lib/garcon/task/obligation.rb +256 -0
  94. data/lib/garcon/task/observable.rb +101 -0
  95. data/lib/garcon/task/priority_queue.rb +234 -0
  96. data/lib/garcon/task/processor_count.rb +128 -0
  97. data/lib/garcon/task/read_write_lock.rb +304 -0
  98. data/lib/garcon/task/safe_task_executor.rb +58 -0
  99. data/lib/garcon/task/single_thread_executor.rb +97 -0
  100. data/lib/garcon/task/thread_pool/cached.rb +71 -0
  101. data/lib/garcon/task/thread_pool/executor.rb +294 -0
  102. data/lib/garcon/task/thread_pool/fixed.rb +61 -0
  103. data/lib/garcon/task/thread_pool/worker.rb +90 -0
  104. data/lib/garcon/task/timer.rb +44 -0
  105. data/lib/garcon/task/timer_set.rb +194 -0
  106. data/lib/garcon/task/timer_task.rb +377 -0
  107. data/lib/garcon/task/waitable_list.rb +58 -0
  108. data/lib/garcon/utility/ansi.rb +199 -0
  109. data/lib/garcon/utility/at_random.rb +77 -0
  110. data/lib/garcon/utility/crypto.rb +292 -0
  111. data/lib/garcon/utility/equalizer.rb +146 -0
  112. data/lib/garcon/utility/faker/extensions/array.rb +22 -0
  113. data/lib/garcon/utility/faker/extensions/symbol.rb +9 -0
  114. data/lib/garcon/utility/faker/faker.rb +164 -0
  115. data/lib/garcon/utility/faker/faker/company.rb +17 -0
  116. data/lib/garcon/utility/faker/faker/hacker.rb +30 -0
  117. data/lib/garcon/utility/faker/faker/version.rb +3 -0
  118. data/lib/garcon/utility/faker/locales/en-US.yml +83 -0
  119. data/lib/garcon/utility/faker/locales/en.yml +21 -0
  120. data/lib/garcon/utility/file_helper.rb +170 -0
  121. data/lib/garcon/utility/hookers.rb +178 -0
  122. data/lib/garcon/utility/interpolation.rb +90 -0
  123. data/lib/garcon/utility/memstash.rb +364 -0
  124. data/lib/garcon/utility/misc.rb +54 -0
  125. data/lib/garcon/utility/msg_from_god.rb +62 -0
  126. data/lib/garcon/utility/retry.rb +238 -0
  127. data/lib/garcon/utility/timeout.rb +58 -0
  128. data/lib/garcon/utility/uber/builder.rb +91 -0
  129. data/lib/garcon/utility/uber/callable.rb +7 -0
  130. data/lib/garcon/utility/uber/delegates.rb +13 -0
  131. data/lib/garcon/utility/uber/inheritable_attr.rb +37 -0
  132. data/lib/garcon/utility/uber/options.rb +101 -0
  133. data/lib/garcon/utility/uber/uber_version.rb +3 -0
  134. data/lib/garcon/utility/uber/version.rb +33 -0
  135. data/lib/garcon/utility/url_helper.rb +100 -0
  136. data/lib/garcon/utils.rb +29 -0
  137. data/lib/garcon/version.rb +62 -0
  138. data/lib/garcun.rb +24 -0
  139. metadata +680 -0
@@ -0,0 +1,127 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Author: Stefano Harding <riddopic@gmail.com>
4
+ # License: Apache License, Version 2.0
5
+ # Copyright: (C) 2014-2015 Stefano Harding
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'chef'
21
+ require 'chef/log'
22
+ require 'chef/handler'
23
+ require 'garcon'
24
+
25
+ class DevReporter < Chef::Handler
26
+ attr_reader :resources, :immediate, :delayed, :always
27
+
28
+ def initialize(opts = {})
29
+ end
30
+
31
+ def full_name(resource)
32
+ "#{resource.resource_name}[#{resource.name}]"
33
+ end
34
+
35
+ def humanize(seconds)
36
+ [[60, :seconds],
37
+ [60, :minutes],
38
+ [24, :hours],
39
+ [1000, :days] ].map do |count, name|
40
+ if seconds > 0
41
+ seconds, n = seconds.divmod(count)
42
+ "#{n.to_i} #{name}"
43
+ end
44
+ end.compact.reverse.join(' ')
45
+ end
46
+
47
+ def banner
48
+ puts <<-EOF
49
+
50
+
51
+ .: ;:. .:;S;:. .:;.;:. .:;S;:. .:;S;:.
52
+ S ' S S S S S S S /
53
+ `:;S;:' `:;S;:' `:;S;:' `:;S;:' `:;S;:'
54
+ .g8"""bgd
55
+ .dP' `M
56
+ dM' ` ,6"Yb. `7Mb,od8 ,p6"bo ,pW"Wq.`7MMpMMMb.
57
+ MM 8) MM MM' "'6M' OO 6W' `Wb MM MM
58
+ MM. `7MMF',pm9MM MM 8M 8M M8 MM MM
59
+ `Mb. MM 8M MM MM YM. , YA. ,A9 MM MM
60
+ `"bmmmdPY `Moo9^Yo..JMML. YMbmd' `Ybmd9'.JMML JMML.
61
+ bog
62
+ od V #{Garcon::VERSION}
63
+
64
+ EOF
65
+ end
66
+
67
+ def report
68
+ if run_status.success?
69
+ cookbooks = Hash.new(0)
70
+ recipes = Hash.new(0)
71
+ resources = Hash.new(0)
72
+ run_time = humanize(run_status.elapsed_time)
73
+ updates = run_status.updated_resources.length
74
+ total = run_status.all_resources.length
75
+
76
+ all_resources.each do |r|
77
+ cookbooks[r.cookbook_name] += r.elapsed_time
78
+ recipes["#{r.cookbook_name}::#{r.recipe_name}"] += r.elapsed_time
79
+ resources["#{r.resource_name}[#{r.name}]"] = r.elapsed_time
80
+ end
81
+
82
+ @max_time = all_resources.max_by { |r| r.elapsed_time }.elapsed_time
83
+ @max = all_resources.max_by { |r| full_name(r).length }
84
+
85
+ # Start droping puts because mash grinder faceplanted Chef::Log.info
86
+ # logging changes random so excelent thanks Chef!
87
+ #
88
+ puts ''
89
+ puts '*|*|*|*|*|*|*|*|* <`)))>< '
90
+ banner
91
+ puts 'Elapsed Time Cookbook Version'.yellow
92
+ puts '------------ ------------------- ----------------------'.green
93
+ cookbooks.sort_by { |k, v| -v }.each do |cookbook, run_time|
94
+ ver = run_context.cookbook_collection[cookbook.to_sym].version
95
+ puts '%19f %-20s %-7s' % [run_time, cookbook, ver]
96
+ end
97
+ puts ''
98
+ puts 'Elapsed Time Recipe'.orange
99
+ puts '------------ -------------------------------------------'.green
100
+ recipes.sort_by { |k, v| -v }.each do |recipe, run_time|
101
+ puts '%19f %s' % [run_time, recipe]
102
+ end
103
+ puts ''
104
+ puts 'Elapsed Time Resource'.orange
105
+ puts '------------ -------------------------------------------'.green
106
+ resources.sort_by { |k, v| -v }.each do |resource, run_time|
107
+ puts '%19f %s' % [run_time, resource]
108
+ end
109
+ puts '+-----------------------------------------------------------------'\
110
+ '-------------+'.purple
111
+ puts ''
112
+ puts "Chef Run Completed in #{run_time} on #{node.name}. Updated " \
113
+ "#{updates} of #{total} resources."
114
+
115
+ cookbooks = run_context.cookbook_collection
116
+ puts
117
+ puts "Slowest Resource: #{full_name(@max)} (%.6fs)"%[@max_time]
118
+ puts ''
119
+ puts Faker::Hacker.say_something_smart
120
+ puts ''
121
+ elsif run_status.failed?
122
+ banner
123
+ puts "Chef FAILED in #{run_time} on #{node.name} with exception:".orange
124
+ puts run_status.formatted_exception
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Author: Stefano Harding <riddopic@gmail.com>
4
+ # License: Apache License, Version 2.0
5
+ # Copyright: (C) 2014-2015 Stefano Harding
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'mixlib/log/formatter'
21
+
22
+ module Mixlib
23
+ module Log
24
+ class Formatter < Logger::Formatter
25
+ # Set Chef::Log::Formatter.show_time == true/false to enable/disable the
26
+ # printing of the time with the message.
27
+
28
+ def call(severity, time, progname, msg)
29
+ format % [
30
+ format_datetime(time).blue,
31
+ format_severity(severity),
32
+ msg2str(msg).strip
33
+ ]
34
+ end
35
+
36
+ private # P R O P R I E T À P R I V A T A Vietato L'accesso
37
+
38
+ def format
39
+ "\n[%s] %5s: %s\n"
40
+ end
41
+
42
+ def format_severity(severity)
43
+ case severity
44
+ when 'FATAL'
45
+ severity.bright_red
46
+ when 'ERROR'
47
+ severity.red
48
+ when 'WARN'
49
+ severity.yellow
50
+ when 'DEBUG'
51
+ severity.light_gray
52
+ when 'INFO'
53
+ severity.green
54
+ else
55
+ severity
56
+ end
57
+ end
58
+
59
+ def format_datetime(time)
60
+ time.strftime('%T')
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,100 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Author: Stefano Harding <riddopic@gmail.com>
4
+ # License: Apache License, Version 2.0
5
+ # Copyright: (C) 2014-2015 Stefano Harding
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ # To get to node we have to go through Chef, happy Rubocop?
21
+ #
22
+ class Chef
23
+ # Slap some dandy handy methods to stick on a node.
24
+ #
25
+ class Node
26
+ # Boolean to check if a recipe is loaded in the run list.
27
+ #
28
+ # @param [String] recipe
29
+ # the command to find
30
+ #
31
+ # @return [TrueClass, FalseClass]
32
+ # true if the command is found in the path, false otherwise
33
+ #
34
+ # @api public
35
+ def has_recipe?(recipe)
36
+ loaded_recipes.include?(with_default(recipe))
37
+ end
38
+ alias_method :include_recipe?, :has_recipe?
39
+ alias_method :includes_recipe?, :has_recipe?
40
+
41
+ # Determine if the current node is in the given Chef environment
42
+ # (or matches the given regular expression).
43
+ #
44
+ # @param [String, Regex] environment
45
+ #
46
+ # @return [Boolean]
47
+ #
48
+ # @api public
49
+ def in?(environment)
50
+ environment === chef_environment
51
+ end
52
+
53
+ # Recursively searchs a nested datastructure for a key and returns the
54
+ # value. If a block is provided its value will be returned if the key does
55
+ # not exist, otherwise UndefinedAttributeError is raised.
56
+ #
57
+ # @param [Array<String, Symbol>] keys
58
+ # the list of keys to kdeep fetch
59
+ #
60
+ # @yield optional block to execute if no value is found
61
+ #
62
+ # @return [Object]
63
+ #
64
+ # @api public
65
+ def get(*keys, &block)
66
+ args.reduce(self) do |obj, arg|
67
+ begin
68
+ arg = Integer(arg) if obj.is_a? Array
69
+ obj.fetch(arg)
70
+ rescue ArgumentError, IndexError, NoMethodError
71
+ break block.call(arg) if block
72
+ raise UndefinedAttributeError
73
+ end
74
+ end
75
+ end
76
+ alias_method :deep_fetch, :get
77
+
78
+ private # P R O P R I E T À P R I V A T A Vietato L'accesso
79
+
80
+ # Automatically appends "::default" to recipes that need them.
81
+ #
82
+ # @param [String] recipe
83
+ #
84
+ # @return [String]
85
+ #
86
+ # @api private
87
+ def with_default(recipe)
88
+ name.include?('::') ? name : "#{recipe}::default"
89
+ end
90
+
91
+ # The list of loaded recipes on the Chef run (normalized)
92
+ #
93
+ # @return [Array<String>]
94
+ #
95
+ # @api private
96
+ def loaded_recipes
97
+ node.run_context.loaded_recipes.map { |name| with_default(name) }
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,209 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Author: Stefano Harding <riddopic@gmail.com>
4
+ # License: Apache License, Version 2.0
5
+ # Copyright: (C) 2014-2015 Stefano Harding
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'garcon'
21
+
22
+ class Chef
23
+ class Resource
24
+ class Civilize < Chef::Resource
25
+ include Garcon
26
+
27
+ # Chef attributes
28
+ identity_attr :name
29
+ provides :civilize
30
+
31
+ # Actions
32
+ actions :run
33
+ default_action :run
34
+
35
+ # Attributes
36
+ attribute :name,
37
+ kind_of: String
38
+ attribute :iptables,
39
+ kind_of: [TrueClass, FalseClass],
40
+ default: true
41
+ attribute :selinux,
42
+ kind_of: [TrueClass, FalseClass],
43
+ default: true
44
+ attribute :dotfiles,
45
+ kind_of: [TrueClass, FalseClass, String, Array],
46
+ default: true
47
+ attribute :ruby,
48
+ kind_of: [TrueClass, FalseClass],
49
+ default: true
50
+ attribute :docker,
51
+ kind_of: Array,
52
+ default: %w[tar htop initscripts]
53
+ attribute :rhel_svcs,
54
+ kind_of: Array,
55
+ default: %w[
56
+ autofs avahi-daemon bluetooth cpuspeed cups gpm haldaemon messagebus
57
+ ]
58
+ end
59
+ end
60
+
61
+ class Provider
62
+ class Civilize < Chef::Provider
63
+ include Garcon
64
+
65
+ # Shortcut to new_resource.
66
+ #
67
+ alias_method :r, :new_resource
68
+
69
+ # Boolean indicating if WhyRun is supported by this provider
70
+ #
71
+ # @return [TrueClass, FalseClass]
72
+ #
73
+ # @api private
74
+ def whyrun_supported?
75
+ true
76
+ end
77
+
78
+ # Load and return the current resource.
79
+ #
80
+ # @return [Chef::Provider::Civilize]
81
+ #
82
+ # @api private
83
+ def load_current_resource
84
+ @current_resource ||= Chef::Resource::Civilize.new(r.name)
85
+ @current_resource
86
+ end
87
+
88
+ def action_run
89
+ civilize_docker if docker? && r.docker
90
+ rhel_services if r.rhel_svcs
91
+ iptables if !docker? && r.iptables
92
+ selinux if selinux? && r.selinux
93
+ ps1prompt
94
+ dotfiles if r.dotfiles
95
+ end
96
+
97
+ private # P R O P R I E T À P R I V A T A Vietato L'accesso
98
+
99
+ def civilize_docker
100
+ r.docker.each { |pkg| package pkg }
101
+ end
102
+
103
+ def rhel_services
104
+ r.rhel_svcs.each do |svc|
105
+ service(svc) { action [:stop, :disable] }
106
+ end
107
+ end
108
+
109
+ def iptables
110
+ shell_out!('iptables -F')
111
+ end
112
+
113
+ def selinux
114
+ shell_out!('setenforce 0')
115
+ end
116
+
117
+ def ps1prompt
118
+ ver = run_context.cookbook_collection[cookbook_name].metadata.version
119
+ t ||= Chef::Resource::Template.new('/etc/profile.d/ps1.sh', run_context)
120
+ t.cookbook 'garcon'
121
+ t.owner 'root'
122
+ t.group 'root'
123
+ t.mode 00644
124
+ t.variables version: ver
125
+ t.run_action :create
126
+ end
127
+
128
+ def dotfiles
129
+ users = if r.dotfiles.is_a?(TrueClass)
130
+ Array('root')
131
+ elsif r.dotfiles.respond_to?(:to_ary)
132
+ users = r.dotfiles
133
+ elsif r.dotfiles.respond_to?(:to_str)
134
+ users = Array(r.dotfiles)
135
+ end
136
+
137
+ users.each do |user|
138
+ home = user =~ /root/ ? '/root' : "/home/#{user}"
139
+ ['.bashrc', '.inputrc'].each do |dot|
140
+ file = ::File.join(home, dot)
141
+ f ||= Chef::Resource::CookbookFile.new(file, run_context)
142
+ f.source dot[1..-1]
143
+ f.cookbook 'garcon'
144
+ f.backup false
145
+ f.owner user
146
+ f.group user
147
+ f.mode 00644
148
+ f.run_action :create
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+ # Chef::Platform mapping for resource and providers
157
+ #
158
+ # @return [undefined]
159
+ #
160
+ # @api private.
161
+ Chef::Platform.set(
162
+ platform: :amazon,
163
+ resource: :civilize,
164
+ provider: Chef::Provider::Civilize
165
+ )
166
+
167
+ # Chef::Platform mapping for resource and providers
168
+ #
169
+ # @return [undefined]
170
+ #
171
+ # @api private.
172
+ Chef::Platform.set(
173
+ platform: :centos,
174
+ resource: :civilize,
175
+ provider: Chef::Provider::Civilize
176
+ )
177
+
178
+ # Chef::Platform mapping for resource and providers
179
+ #
180
+ # @return [undefined]
181
+ #
182
+ # @api private.
183
+ Chef::Platform.set(
184
+ platform: :oracle,
185
+ resource: :civilize,
186
+ provider: Chef::Provider::Civilize
187
+ )
188
+
189
+ # Chef::Platform mapping for resource and providers
190
+ #
191
+ # @return [undefined]
192
+ #
193
+ # @api private.
194
+ Chef::Platform.set(
195
+ platform: :redhat,
196
+ resource: :civilize,
197
+ provider: Chef::Provider::Civilize
198
+ )
199
+
200
+ # Chef::Platform mapping for resource and providers
201
+ #
202
+ # @return [undefined]
203
+ #
204
+ # @api private.
205
+ Chef::Platform.set(
206
+ platform: :scientific,
207
+ resource: :civilize,
208
+ provider: Chef::Provider::Civilize
209
+ )