itamae 1.0.0.beta6 → 1.0.0.beta7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32cd433377eae0ebf109bcb64076577f38e72d7c
4
- data.tar.gz: a83208334949e56c3597828e681d91a4050fb4ff
3
+ metadata.gz: ef47c5b46afec4cac24288684ac44b1255f143b9
4
+ data.tar.gz: 2166fff3decaf2661fdfbb0cd85507c44e24264a
5
5
  SHA512:
6
- metadata.gz: 6aaabb06cdcc15ac3fa157f9a3aa7196218fa689e481d8ffe1aa095e865cee4b96328e30024168db08adf1888f9562f69f8439ac4036433584e81b7442d5044d
7
- data.tar.gz: 095bcc26d0f2dd25320241f4ff651980a2beb212e0e4188da3b91cfa2e32052fb3a66671d651b5d3fe2c240f30fadf7fe50ceb90431869bd43f3bf4c9bfff680
6
+ metadata.gz: 74ddbf1ad246f5c9b19a50a3e721543ca4b08d20c919e78bd6014fde7d9295afffdec00831327f99bf03aa979bec50bc94af841482a35dfb99c943b3b2885892
7
+ data.tar.gz: 85b8732740ffbe73919cb630f67ace5aeeff435e10d43390244ff20a08c438489e65977c0c2f894796954d8586772ebea2fbbb8f0c26c055ce6f989e7977985c
data/Rakefile CHANGED
@@ -44,6 +44,7 @@ namespace :spec do
44
44
  cmd << " -j spec/integration/recipes/node.json"
45
45
  cmd << " spec/integration/recipes/default.rb"
46
46
 
47
+ puts cmd
47
48
  system cmd
48
49
  abort unless $?.exitstatus == 0
49
50
  end
@@ -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
- if value && value != ''
52
- value.each_line do |line|
53
- # remove control chars
54
- case line.encoding
55
- when Encoding::UTF_8
56
- line = line.tr("\u0000-\u001f\u007f\u2028",'')
57
- end
58
-
59
- Logger.public_send(method, " #{name} | #{line}")
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.debug "Loading node data from #{path} ..."
22
- hash = JSON.load(open(path))
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)
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.0.0.beta6"
2
+ VERSION = "1.0.0.beta7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta6
4
+ version: 1.0.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai