garcun 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/garcon/chef/chef_helpers.rb +22 -4
- data/lib/garcon/chef/provider/civilize.rb +59 -13
- data/lib/garcon/chef/provider/development.rb +12 -12
- data/lib/garcon/chef/provider/download.rb +7 -5
- data/lib/garcon/chef/provider/zip_file.rb +7 -11
- data/lib/garcon/core_ext/time.rb +3 -4
- data/lib/garcon/utility/at_random.rb +8 -0
- data/lib/garcon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 091b57cc6a987848fc8f7e9497367c90f3b3e141
|
4
|
+
data.tar.gz: cc6405bab9133f36b7c26f27d20711c2d3ecf667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72ae5eb6840593c0ade85fe6f18a2d394adc6c479a58f7e194d95647fb349dc317cc9316f8b3c65c97b6606f242f985d2a045ec519bb69981bef35f35b3b81a
|
7
|
+
data.tar.gz: 2020ed1a932abb9cccdefa20ae85fd95080663edf5516e53d177ecfaf4852479896d86958aeb98bf1090559c1b5e516969ba4c922c1636149132896078737029
|
@@ -69,7 +69,9 @@ module Garcon
|
|
69
69
|
def find_by(type, filter, single = true, &block)
|
70
70
|
nodes = []
|
71
71
|
env = node.chef_environment
|
72
|
-
|
72
|
+
type = Inflections.pluralize(type.to_s)
|
73
|
+
|
74
|
+
if node.public_send(type).include? filter
|
73
75
|
nodes << node
|
74
76
|
end
|
75
77
|
if !single || nodes.empty?
|
@@ -81,7 +83,7 @@ module Garcon
|
|
81
83
|
if block_given?
|
82
84
|
nodes.each { |n| yield n }
|
83
85
|
else
|
84
|
-
single ? nodes.first : nodes
|
86
|
+
single ? [nodes.first] : nodes
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
@@ -310,15 +312,31 @@ module Garcon
|
|
310
312
|
# Boolean method to check if a command line utility is installed.
|
311
313
|
#
|
312
314
|
# @param [String] cmd
|
313
|
-
#
|
315
|
+
# The command to find.
|
314
316
|
#
|
315
317
|
# @return [TrueClass, FalseClass]
|
316
|
-
# true if the command is found in the path
|
318
|
+
# true if the command is found in the path.
|
317
319
|
#
|
318
320
|
def installed?(cmd)
|
319
321
|
!Garcon::FileHelper.which(cmd).nil?
|
320
322
|
end
|
321
323
|
|
324
|
+
# Boolean method to check if a package is installed.
|
325
|
+
#
|
326
|
+
# @param [String] pkg
|
327
|
+
# The package to check for.
|
328
|
+
#
|
329
|
+
# @return [TrueClass, FalseClass]
|
330
|
+
# True if the package is found in the path.
|
331
|
+
#
|
332
|
+
def pkg_installed?(pkg)
|
333
|
+
if node.platform_family == 'debian'
|
334
|
+
shell_out("dpkg -l #{pkg}").exitstatus == 0 ? true : false
|
335
|
+
elsif node.platform_family == 'rhel'
|
336
|
+
shell_out("rpm -qa | grep #{pkg}").exitstatus == 0 ? true : false
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
322
340
|
# @return [String] object inspection
|
323
341
|
# @api public
|
324
342
|
def inspect
|
@@ -35,26 +35,27 @@ class Chef
|
|
35
35
|
# Attributes
|
36
36
|
attribute :name,
|
37
37
|
kind_of: String
|
38
|
+
attribute :local,
|
39
|
+
kind_of: [String],
|
40
|
+
default: 'en_US.UTF-8'
|
38
41
|
attribute :iptables,
|
39
42
|
kind_of: [TrueClass, FalseClass],
|
40
|
-
default:
|
43
|
+
default: lazy { node[:garcon][:civilize][:iptables] }
|
41
44
|
attribute :selinux,
|
42
45
|
kind_of: [TrueClass, FalseClass],
|
43
|
-
default:
|
46
|
+
default: lazy { node[:garcon][:civilize][:selinux] }
|
44
47
|
attribute :dotfiles,
|
45
48
|
kind_of: [TrueClass, FalseClass, String, Array],
|
46
|
-
default:
|
49
|
+
default: lazy { node[:garcon][:civilize][:dotfiles] }
|
47
50
|
attribute :ruby,
|
48
51
|
kind_of: [TrueClass, FalseClass],
|
49
|
-
default:
|
52
|
+
default: lazy { node[:garcon][:civilize][:ruby] }
|
50
53
|
attribute :docker,
|
51
54
|
kind_of: Array,
|
52
|
-
default:
|
55
|
+
default: lazy { node[:garcon][:civilize][:docker] }
|
53
56
|
attribute :rhel_svcs,
|
54
57
|
kind_of: Array,
|
55
|
-
default:
|
56
|
-
autofs avahi-daemon bluetooth cpuspeed cups gpm haldaemon messagebus
|
57
|
-
]
|
58
|
+
default: lazy { node[:garcon][:civilize][:rhel_svcs] }
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -86,16 +87,61 @@ class Chef
|
|
86
87
|
end
|
87
88
|
|
88
89
|
def action_run
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
civilize_platform
|
91
|
+
civilize_locale
|
92
|
+
civilize_docker if docker? && r.docker
|
93
|
+
rhel_services if r.rhel_svcs
|
94
|
+
iptables if !docker? && r.iptables
|
95
|
+
selinux if selinux? && r.selinux
|
93
96
|
ps1prompt
|
94
|
-
dotfiles
|
97
|
+
dotfiles if r.dotfiles
|
95
98
|
end
|
96
99
|
|
97
100
|
private # P R O P R I E T À P R I V A T A Vietato L'accesso
|
98
101
|
|
102
|
+
def omnibus_updater
|
103
|
+
node.default[:omnibus_updater][:restart_chef_service] = true
|
104
|
+
node.default[:omnibus_updater][:force_latest] = false
|
105
|
+
end
|
106
|
+
|
107
|
+
def civilize_locale
|
108
|
+
case node[:platform_family]
|
109
|
+
when 'debian'
|
110
|
+
e = Chef::Resource::Execute.new('Set locale', run_context)
|
111
|
+
e.command "/usr/sbin/update-locale LANG=#{r.local}"
|
112
|
+
e.not_if { docker? }
|
113
|
+
e.action :run
|
114
|
+
when 'rhel'
|
115
|
+
t ||= Chef::Resource::Template.new('/etc/sysconfig/i18n', run_context)
|
116
|
+
t.cookbook 'garcon'
|
117
|
+
t.owner 'root'
|
118
|
+
t.group 'root'
|
119
|
+
t.mode 00644
|
120
|
+
t.variables local: r.local
|
121
|
+
e.not_if { docker? }
|
122
|
+
t.run_action :create
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def civilize_platform
|
127
|
+
case node[:platform]
|
128
|
+
when 'debian', 'ubuntu'
|
129
|
+
run_context.include_recipe 'apt::default'
|
130
|
+
run_context.include_recipe 'motd-tail::default'
|
131
|
+
m = Chef::Resource::MotdTail.new('/etc/motd.tail', run_context)
|
132
|
+
m.template_source 'motd.erb'
|
133
|
+
m.action :create
|
134
|
+
when 'fedora'
|
135
|
+
run_context.include_recipe 'yum-fedora::default'
|
136
|
+
when 'centos'
|
137
|
+
run_context.include_recipe 'yum-epel::default'
|
138
|
+
run_context.include_recipe 'yum-centos::default'
|
139
|
+
when 'amazon'
|
140
|
+
run_context.include_recipe 'yum-epel::default'
|
141
|
+
run_context.include_recipe 'yum-amazon::default'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
99
145
|
def civilize_docker
|
100
146
|
r.docker.each { |pkg| package pkg }
|
101
147
|
end
|
@@ -57,7 +57,7 @@ class Chef
|
|
57
57
|
|
58
58
|
# Load and return the current resource.
|
59
59
|
#
|
60
|
-
# @return [Chef::Provider
|
60
|
+
# @return [Chef::Provider:Development]
|
61
61
|
#
|
62
62
|
# @api private
|
63
63
|
def load_current_resource
|
@@ -76,7 +76,7 @@ class Chef
|
|
76
76
|
private # P R O P R I E T À P R I V A T A Vietato L'accesso
|
77
77
|
|
78
78
|
def chef_handler
|
79
|
-
include_recipe 'chef_handler::default'
|
79
|
+
run_context.include_recipe 'chef_handler::default'
|
80
80
|
|
81
81
|
file = ::File.join(node[:chef_handler][:handler_path], 'devreporter.rb')
|
82
82
|
f ||= Chef::Resource::CookbookFile.new(file, run_context)
|
@@ -110,8 +110,8 @@ end
|
|
110
110
|
# @api private.
|
111
111
|
Chef::Platform.set(
|
112
112
|
platform: :amazon,
|
113
|
-
resource: :
|
114
|
-
provider: Chef::Provider::
|
113
|
+
resource: :development,
|
114
|
+
provider: Chef::Provider::Development
|
115
115
|
)
|
116
116
|
|
117
117
|
# Chef::Platform mapping for resource and providers
|
@@ -121,8 +121,8 @@ Chef::Platform.set(
|
|
121
121
|
# @api private.
|
122
122
|
Chef::Platform.set(
|
123
123
|
platform: :centos,
|
124
|
-
resource: :
|
125
|
-
provider: Chef::Provider::
|
124
|
+
resource: :development,
|
125
|
+
provider: Chef::Provider::Development
|
126
126
|
)
|
127
127
|
|
128
128
|
# Chef::Platform mapping for resource and providers
|
@@ -132,8 +132,8 @@ Chef::Platform.set(
|
|
132
132
|
# @api private.
|
133
133
|
Chef::Platform.set(
|
134
134
|
platform: :oracle,
|
135
|
-
resource: :
|
136
|
-
provider: Chef::Provider::
|
135
|
+
resource: :development,
|
136
|
+
provider: Chef::Provider::Development
|
137
137
|
)
|
138
138
|
|
139
139
|
# Chef::Platform mapping for resource and providers
|
@@ -143,8 +143,8 @@ Chef::Platform.set(
|
|
143
143
|
# @api private.
|
144
144
|
Chef::Platform.set(
|
145
145
|
platform: :redhat,
|
146
|
-
resource: :
|
147
|
-
provider: Chef::Provider::
|
146
|
+
resource: :development,
|
147
|
+
provider: Chef::Provider::Development
|
148
148
|
)
|
149
149
|
|
150
150
|
# Chef::Platform mapping for resource and providers
|
@@ -154,6 +154,6 @@ Chef::Platform.set(
|
|
154
154
|
# @api private.
|
155
155
|
Chef::Platform.set(
|
156
156
|
platform: :scientific,
|
157
|
-
resource: :
|
158
|
-
provider: Chef::Provider::
|
157
|
+
resource: :development,
|
158
|
+
provider: Chef::Provider::Development
|
159
159
|
)
|
@@ -302,8 +302,10 @@ class Chef
|
|
302
302
|
end
|
303
303
|
|
304
304
|
def handle_prerequisites
|
305
|
-
|
306
|
-
|
305
|
+
if node.platform_family == 'rhel'
|
306
|
+
package 'gnutls', :install
|
307
|
+
yumrepo(:create)
|
308
|
+
end
|
307
309
|
package 'aria2', :install
|
308
310
|
wipe_repo if node.platform_family == 'rhel'
|
309
311
|
end
|
@@ -317,9 +319,9 @@ class Chef
|
|
317
319
|
|
318
320
|
def yumrepo(action = :nothing)
|
319
321
|
y = Chef::Resource::YumRepository.new('garcon', run_context)
|
320
|
-
y.mirrorlist
|
321
|
-
y.
|
322
|
-
y.
|
322
|
+
y.mirrorlist Repos.mirrorlist
|
323
|
+
y.gpgkey Repos.gpgkey
|
324
|
+
y.gpgcheck true
|
323
325
|
y.run_action action
|
324
326
|
end
|
325
327
|
|
@@ -75,7 +75,7 @@ class Chef
|
|
75
75
|
|
76
76
|
def initialize(new_resource, run_context)
|
77
77
|
super
|
78
|
-
|
78
|
+
__zip__ unless defined?(Zip)
|
79
79
|
end
|
80
80
|
|
81
81
|
# Shortcut to new_resource.
|
@@ -137,7 +137,7 @@ class Chef
|
|
137
137
|
r.updated_by_last_action(true)
|
138
138
|
end
|
139
139
|
else
|
140
|
-
Chef::Log.
|
140
|
+
Chef::Log.warn 'A valid directory must be specified for ziping.'
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -170,17 +170,13 @@ class Chef
|
|
170
170
|
# @return [undefined]
|
171
171
|
#
|
172
172
|
# @api private
|
173
|
-
def
|
174
|
-
require 'zip'
|
173
|
+
def __zip__
|
174
|
+
require 'zip' unless defined?(Zip)
|
175
175
|
rescue LoadError
|
176
|
-
|
177
|
-
require 'zip'
|
178
|
-
end
|
179
|
-
|
180
|
-
def gem_rubyzip
|
181
|
-
g ||= Chef::Resource::ChefGem.new('rubyzip', run_context)
|
176
|
+
g = Chef::Resource::ChefGem.new('zip', run_context)
|
182
177
|
g.compile_time(false) if respond_to?(:compile_time)
|
183
|
-
g.run_action
|
178
|
+
g.run_action(:install)
|
179
|
+
require 'zip'
|
184
180
|
end
|
185
181
|
|
186
182
|
# Cache a file locally in Chef::Config[:file_cache_path].
|
data/lib/garcon/core_ext/time.rb
CHANGED
@@ -132,14 +132,13 @@ class Time
|
|
132
132
|
# t.shift(:days=>4, :hours=>3) # => Time.utc(2010,10,14,3,0,0)
|
133
133
|
#
|
134
134
|
def shift(*time_units)
|
135
|
-
time_hash
|
136
|
-
time_units
|
135
|
+
time_hash = Hash===time_units.last ? time_units.pop : {}
|
136
|
+
time_units = time_units.flatten
|
137
137
|
time_units << :seconds if time_units.size % 2 == 1
|
138
|
-
time_hash.each{ |units, number| time_units << number; time_units << units }
|
138
|
+
time_hash.each { |units, number| time_units << number; time_units << units }
|
139
139
|
|
140
140
|
time = self
|
141
141
|
time_units.each_slice(2) do |number, units|
|
142
|
-
#next time = time.ago(-number, units) if number < 0
|
143
142
|
time = (
|
144
143
|
case units.to_s.downcase.to_sym
|
145
144
|
when :years, :year
|
@@ -39,6 +39,14 @@ module Garcon
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
# Hook called when module is included, extends a descendant with class
|
43
|
+
# and instance methods.
|
44
|
+
#
|
45
|
+
# @param [Module] descendant
|
46
|
+
# the module or class including Garcon::Resource::BaseDSL
|
47
|
+
#
|
48
|
+
# @return [self]
|
49
|
+
#
|
42
50
|
def self.included(other)
|
43
51
|
other.extend(ClassMethods)
|
44
52
|
end
|
data/lib/garcon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garcun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Harding
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|