itamae 1.0.0.beta6 → 1.0.0.beta7
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 +4 -4
- data/Rakefile +1 -0
- data/lib/itamae/backend.rb +14 -9
- data/lib/itamae/cli.rb +2 -0
- data/lib/itamae/resource/service.rb +18 -0
- data/lib/itamae/runner.rb +10 -4
- data/lib/itamae/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef47c5b46afec4cac24288684ac44b1255f143b9
|
4
|
+
data.tar.gz: 2166fff3decaf2661fdfbb0cd85507c44e24264a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74ddbf1ad246f5c9b19a50a3e721543ca4b08d20c919e78bd6014fde7d9295afffdec00831327f99bf03aa979bec50bc94af841482a35dfb99c943b3b2885892
|
7
|
+
data.tar.gz: 85b8732740ffbe73919cb630f67ace5aeeff435e10d43390244ff20a08c438489e65977c0c2f894796954d8586772ebea2fbbb8f0c26c055ce6f989e7977985c
|
data/Rakefile
CHANGED
data/lib/itamae/backend.rb
CHANGED
@@ -48,16 +48,21 @@ module Itamae
|
|
48
48
|
Logger.public_send(method, message)
|
49
49
|
|
50
50
|
{"stdout" => result.stdout, "stderr" => result.stderr}.each_pair do |name, value|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
next unless value && value != ''
|
52
|
+
|
53
|
+
if value.bytesize > 1024
|
54
|
+
Logger.public_send(method, " #{name} is suppressed because it's too large")
|
55
|
+
next
|
56
|
+
end
|
57
|
+
|
58
|
+
value.each_line do |line|
|
59
|
+
# remove control chars
|
60
|
+
case line.encoding
|
61
|
+
when Encoding::UTF_8
|
62
|
+
line = line.tr("\u0000-\u001f\u007f\u2028",'')
|
60
63
|
end
|
64
|
+
|
65
|
+
Logger.public_send(method, " #{name} | #{line}")
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
data/lib/itamae/cli.rb
CHANGED
@@ -14,6 +14,7 @@ module Itamae
|
|
14
14
|
desc "local RECIPE [RECIPE...]", "Run Itamae locally"
|
15
15
|
option :node_json, type: :string, aliases: ['-j']
|
16
16
|
option :dry_run, type: :string, aliases: ['-n']
|
17
|
+
option :ohai, type: :boolean, default: false
|
17
18
|
def local(*recipe_files)
|
18
19
|
Runner.run(recipe_files, :local, options)
|
19
20
|
end
|
@@ -25,6 +26,7 @@ module Itamae
|
|
25
26
|
option :user, type: :string, aliases: ['-u']
|
26
27
|
option :key, type: :string, aliases: ['-i']
|
27
28
|
option :port, type: :numeric, aliases: ['-p']
|
29
|
+
option :ohai, type: :boolean, default: false
|
28
30
|
def ssh(*recipe_files)
|
29
31
|
Runner.run(recipe_files, :ssh, options)
|
30
32
|
end
|
@@ -6,6 +6,24 @@ module Itamae
|
|
6
6
|
define_attribute :action, default: :nothing
|
7
7
|
define_attribute :name, type: String, default_name: true
|
8
8
|
|
9
|
+
def set_current_attributes
|
10
|
+
@current_attributes[:running?] = run_specinfra(:check_service_is_running, name)
|
11
|
+
@current_attributes[:enabled?] = run_specinfra(:check_service_is_enabled, name)
|
12
|
+
|
13
|
+
actions = [action].flatten
|
14
|
+
if actions.include?(:start) || actions.include?(:restart)
|
15
|
+
@attributes[:running?] = true
|
16
|
+
elsif actions.include?(:stop)
|
17
|
+
@attributes[:running?] = false
|
18
|
+
end
|
19
|
+
|
20
|
+
if actions.include?(:enable)
|
21
|
+
@attributes[:enabled?] = true
|
22
|
+
elsif actions.include?(:disable)
|
23
|
+
@attributes[:enabled?] = false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
9
27
|
def start_action
|
10
28
|
run_specinfra(:start_service, name)
|
11
29
|
end
|
data/lib/itamae/runner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'itamae'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Itamae
|
4
5
|
class Runner
|
@@ -16,12 +17,17 @@ module Itamae
|
|
16
17
|
|
17
18
|
private
|
18
19
|
def node_from_options(options)
|
20
|
+
hash = {}
|
21
|
+
|
22
|
+
if options[:ohai]
|
23
|
+
Logger.info "Loading node data via ohai..."
|
24
|
+
hash.merge!(JSON.parse(Backend.instance.run_command("ohai").stdout))
|
25
|
+
end
|
26
|
+
|
19
27
|
if options[:node_json]
|
20
28
|
path = File.expand_path(options[:node_json])
|
21
|
-
Logger.
|
22
|
-
hash
|
23
|
-
else
|
24
|
-
hash = {}
|
29
|
+
Logger.info "Loading node data from #{path}..."
|
30
|
+
hash.merge!(JSON.load(open(path)))
|
25
31
|
end
|
26
32
|
|
27
33
|
Node.new(hash)
|
data/lib/itamae/version.rb
CHANGED