itamae-mitsurin 0.4 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -1
- data/Rakefile +17 -15
- data/bin/itamae +2 -3
- data/bin/manaita +5 -0
- data/itamae-mitsurin.gemspec +4 -4
- data/lib/itamae-mitsurin.rb +17 -0
- data/lib/{itamae → itamae-mitsurin}/backend.rb +13 -13
- data/lib/{itamae → itamae-mitsurin}/cli.rb +5 -5
- data/lib/{itamae → itamae-mitsurin}/definition.rb +2 -2
- data/lib/itamae-mitsurin/ext.rb +1 -0
- data/lib/{itamae → itamae-mitsurin}/ext/specinfra.rb +0 -0
- data/lib/{itamae → itamae-mitsurin}/handler.rb +3 -3
- data/lib/{itamae → itamae-mitsurin}/handler/base.rb +1 -1
- data/lib/{itamae → itamae-mitsurin}/handler/debug.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/handler/fluentd.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/handler/json.rb +1 -1
- data/lib/{itamae → itamae-mitsurin}/handler_proxy.rb +1 -1
- data/lib/{itamae → itamae-mitsurin}/logger.rb +5 -5
- data/lib/itamae-mitsurin/mitsurin.rb +14 -0
- data/lib/{itamae → itamae-mitsurin}/mitsurin/cli.rb +5 -5
- data/lib/{itamae → itamae-mitsurin}/mitsurin/creators.rb +3 -3
- data/lib/itamae-mitsurin/mitsurin/creators/cookbook.rb +24 -0
- data/lib/itamae-mitsurin/mitsurin/creators/project.rb +24 -0
- data/lib/{itamae → itamae-mitsurin}/mitsurin/creators/templates/project/.rspec +0 -0
- data/lib/{itamae → itamae-mitsurin}/mitsurin/creators/templates/project/Gemfile +0 -1
- data/lib/itamae-mitsurin/mitsurin/creators/templates/project/Rakefile +2 -0
- data/lib/{itamae/generators/templates/cookbook/files → itamae-mitsurin/mitsurin/creators/templates/project/environments}/.keep +0 -0
- data/lib/{itamae → itamae-mitsurin}/mitsurin/creators/templates/project/environments/sample.json +0 -0
- data/lib/{itamae/generators/templates/cookbook/templates → itamae-mitsurin/mitsurin/creators/templates/project/keys}/.keep +0 -0
- data/lib/{itamae/generators/templates/project/cookbooks → itamae-mitsurin/mitsurin/creators/templates/project/nodes}/.keep +0 -0
- data/lib/itamae-mitsurin/mitsurin/creators/templates/project/nodes/sample01.json +10 -0
- data/lib/{itamae/generators → itamae-mitsurin/mitsurin/creators}/templates/project/roles/.keep +0 -0
- data/lib/{itamae/generators/templates/role/files → itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/attributes}/.keep +0 -0
- data/lib/itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/recipes/default.rb +1 -0
- data/lib/{itamae/generators/templates/role/templates → itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/recipes/directories}/.keep +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/environments → itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/recipes/files}/.keep +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/keys → itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/recipes/templates}/.keep +0 -0
- data/lib/{itamae → itamae-mitsurin}/mitsurin/creators/templates/project/site-cookbooks/_base/_base/spec/default_spec.rb +0 -0
- data/lib/{itamae → itamae-mitsurin}/mitsurin/creators/templates/project/spec/spec_helper.rb +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/nodes → itamae-mitsurin/mitsurin/creators/templates/project/tmp-nodes}/.keep +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/roles → itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/attributes}/.keep +0 -0
- data/lib/{itamae/generators/templates/cookbook → itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/recipes}/default.rb +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/site-cookbooks/_base/_base/attributes → itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/recipes/directories}/.keep +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/site-cookbooks/_base/_base → itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/recipes}/files/.keep +0 -0
- data/lib/{itamae/mitsurin/creators/templates/project/site-cookbooks/_base/_base → itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/recipes}/templates/.keep +0 -0
- data/lib/{itamae/generators/templates/role/default.rb → itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/spec/default_spec.rb} +0 -0
- data/lib/itamae-mitsurin/mitsurin/itamae_task.rb +197 -0
- data/lib/itamae-mitsurin/mitsurin/itamae_with_git_task.rb +213 -0
- data/lib/itamae-mitsurin/mitsurin/serverspec_task.rb +123 -0
- data/lib/{itamae → itamae-mitsurin}/node.rb +3 -3
- data/lib/{itamae → itamae-mitsurin}/notification.rb +3 -3
- data/lib/{itamae → itamae-mitsurin}/recipe.rb +6 -6
- data/lib/{itamae → itamae-mitsurin}/recipe_children.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource.rb +23 -23
- data/lib/{itamae → itamae-mitsurin}/resource/aws_ebs_volume.rb +3 -3
- data/lib/{itamae → itamae-mitsurin}/resource/base.rb +23 -23
- data/lib/{itamae → itamae-mitsurin}/resource/directory.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/execute.rb +2 -2
- data/lib/itamae-mitsurin/resource/file.rb +180 -0
- data/lib/{itamae → itamae-mitsurin}/resource/gem_package.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/git.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/group.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/http_request.rb +3 -3
- data/lib/{itamae → itamae-mitsurin}/resource/link.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/local_ruby_block.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/package.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/remote_directory.rb +5 -5
- data/lib/{itamae → itamae-mitsurin}/resource/remote_file.rb +3 -3
- data/lib/{itamae → itamae-mitsurin}/resource/service.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/template.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/resource/user.rb +2 -2
- data/lib/{itamae → itamae-mitsurin}/runner.rb +8 -8
- data/lib/{itamae/mitsurin → itamae-mitsurin}/version.rb +1 -3
- data/lib/itamae-mitsurin/version.txt +1 -0
- data/test/test_itamae-mitsurin.rb +18 -0
- data/test/test_itamae-mitsurin/ext/test_specinfra.rb +39 -0
- data/test/test_itamae-mitsurin/handler/test_base.rb +40 -0
- data/test/test_itamae-mitsurin/handler/test_debug.rb +10 -0
- data/test/test_itamae-mitsurin/handler/test_fluentd.rb +44 -0
- data/test/test_itamae-mitsurin/handler/test_json.rb +22 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/.rspec +2 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/Gemfile +3 -0
- data/{lib/itamae → test/test_itamae-mitsurin}/mitsurin/creators/templates/project/Rakefile +0 -0
- data/{lib/itamae/mitsurin/creators/templates/project/tmp-nodes → test/test_itamae-mitsurin/mitsurin/creators/templates/project/environments}/.keep +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/environments/sample.json +7 -0
- data/{lib/itamae/mitsurin/creators/templates/site-cookbooks/attributes → test/test_itamae-mitsurin/mitsurin/creators/templates/project/keys}/.keep +0 -0
- data/{lib/itamae/mitsurin/creators/templates/site-cookbooks/files → test/test_itamae-mitsurin/mitsurin/creators/templates/project/nodes}/.keep +0 -0
- data/{lib/itamae → test/test_itamae-mitsurin}/mitsurin/creators/templates/project/nodes/sample01.json +0 -0
- data/{lib/itamae/mitsurin/creators/templates/site-cookbooks/spec → test/test_itamae-mitsurin/mitsurin/creators/templates/project/roles}/.keep +0 -0
- data/{lib/itamae/mitsurin/creators/templates/site-cookbooks/templates → test/test_itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/attributes}/.keep +0 -0
- data/{lib/itamae/mitsurin/creators/templates/site-cookbooks/recipes/default.rb → test/test_itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/files/.keep} +0 -0
- data/{lib/itamae → test/test_itamae-mitsurin}/mitsurin/creators/templates/project/site-cookbooks/_base/_base/recipes/default.rb +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/spec/default_spec.rb +1 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/site-cookbooks/_base/_base/templates/.keep +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/spec/spec_helper.rb +33 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/project/tmp-nodes/.keep +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/attributes/.keep +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/files/.keep +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/recipes/default.rb +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/spec/.keep +0 -0
- data/test/test_itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/templates/.keep +0 -0
- data/{lib/itamae/mitsurin/creators/cookbook.rb → test/test_itamae-mitsurin/mitsurin/creators/test_cookbook.rb} +0 -0
- data/{lib/itamae/mitsurin/creators/project.rb → test/test_itamae-mitsurin/mitsurin/creators/test_project.rb} +0 -0
- data/test/test_itamae-mitsurin/mitsurin/test_cli.rb +56 -0
- data/test/test_itamae-mitsurin/mitsurin/test_creators.rb +19 -0
- data/{lib/itamae/mitsurin/itamae_task.rb → test/test_itamae-mitsurin/mitsurin/test_itamae_task.rb} +0 -1
- data/{lib/itamae/mitsurin/itamae_with_git_task.rb → test/test_itamae-mitsurin/mitsurin/test_itamae_with_git_task.rb} +0 -1
- data/{lib/itamae/mitsurin/serverspec_task.rb → test/test_itamae-mitsurin/mitsurin/test_serverspec_task.rb} +1 -1
- data/test/test_itamae-mitsurin/resource/test_aws_ebs_volume.rb +84 -0
- data/test/test_itamae-mitsurin/resource/test_base.rb +374 -0
- data/test/test_itamae-mitsurin/resource/test_directory.rb +63 -0
- data/test/test_itamae-mitsurin/resource/test_execute.rb +26 -0
- data/{lib/itamae/resource/file.rb → test/test_itamae-mitsurin/resource/test_file.rb} +6 -6
- data/test/test_itamae-mitsurin/resource/test_gem_package.rb +81 -0
- data/test/test_itamae-mitsurin/resource/test_git.rb +94 -0
- data/test/test_itamae-mitsurin/resource/test_group.rb +42 -0
- data/test/test_itamae-mitsurin/resource/test_http_request.rb +71 -0
- data/test/test_itamae-mitsurin/resource/test_link.rb +33 -0
- data/test/test_itamae-mitsurin/resource/test_local_ruby_block.rb +15 -0
- data/test/test_itamae-mitsurin/resource/test_package.rb +44 -0
- data/test/test_itamae-mitsurin/resource/test_remote_directory.rb +84 -0
- data/test/test_itamae-mitsurin/resource/test_remote_file.rb +54 -0
- data/test/test_itamae-mitsurin/resource/test_service.rb +69 -0
- data/test/test_itamae-mitsurin/resource/test_template.rb +53 -0
- data/test/test_itamae-mitsurin/resource/test_user.rb +93 -0
- data/test/test_itamae-mitsurin/test_backend.rb +297 -0
- data/test/test_itamae-mitsurin/test_cli.rb +88 -0
- data/test/test_itamae-mitsurin/test_definition.rb +40 -0
- data/test/test_itamae-mitsurin/test_ext.rb +1 -0
- data/test/test_itamae-mitsurin/test_handler.rb +21 -0
- data/test/test_itamae-mitsurin/test_handler_proxy.rb +38 -0
- data/test/test_itamae-mitsurin/test_logger.rb +124 -0
- data/test/test_itamae-mitsurin/test_mitsurin.rb +14 -0
- data/test/test_itamae-mitsurin/test_node.rb +74 -0
- data/test/test_itamae-mitsurin/test_notification.rb +46 -0
- data/test/test_itamae-mitsurin/test_recipe.rb +171 -0
- data/test/test_itamae-mitsurin/test_recipe_children.rb +86 -0
- data/test/test_itamae-mitsurin/test_resource.rb +73 -0
- data/test/test_itamae-mitsurin/test_runner.rb +124 -0
- data/test/test_itamae-mitsurin/test_version.rb +3 -0
- data/{lib/itamae/mitsurin → test/test_itamae-mitsurin}/version.txt +0 -0
- data/test_project/.rspec +2 -0
- data/test_project/Gemfile +4 -0
- data/test_project/Rakefile +3 -0
- data/test_project/environments/.keep +0 -0
- data/test_project/keys/.keep +0 -0
- data/test_project/nodes/.keep +0 -0
- data/test_project/nodes/test.json +9 -0
- data/test_project/roles/.keep +0 -0
- data/test_project/roles/test.json +14 -0
- data/test_project/site-cookbooks/_base/_base/attributes/.keep +0 -0
- data/test_project/site-cookbooks/_base/_base/files/.keep +0 -0
- data/test_project/site-cookbooks/_base/_base/recipes/default.rb +1 -0
- data/test_project/site-cookbooks/_base/_base/spec/default_spec.rb +1 -0
- data/test_project/site-cookbooks/_base/_base/templates/.keep +0 -0
- data/test_project/site-cookbooks/a_test/directory/attributes/.keep +0 -0
- data/test_project/site-cookbooks/a_test/directory/files/.keep +0 -0
- data/test_project/site-cookbooks/a_test/directory/recipes/default.rb +8 -0
- data/test_project/site-cookbooks/a_test/directory/spec/.keep +0 -0
- data/test_project/site-cookbooks/a_test/directory/spec/default_spec.rb +4 -0
- data/test_project/site-cookbooks/a_test/directory/templates/.keep +0 -0
- data/test_project/site-cookbooks/a_test/package/attributes/.keep +0 -0
- data/test_project/site-cookbooks/a_test/package/files/.keep +0 -0
- data/test_project/site-cookbooks/a_test/package/recipes/default.rb +2 -0
- data/test_project/site-cookbooks/a_test/package/spec/.keep +0 -0
- data/test_project/site-cookbooks/a_test/package/spec/default_spec.rb +4 -0
- data/test_project/site-cookbooks/a_test/package/templates/.keep +0 -0
- data/test_project/site-cookbooks/a_test/service/attributes/.keep +0 -0
- data/test_project/site-cookbooks/a_test/service/files/.keep +0 -0
- data/test_project/site-cookbooks/a_test/service/recipes/default.rb +5 -0
- data/test_project/site-cookbooks/a_test/service/spec/.keep +0 -0
- data/test_project/site-cookbooks/a_test/service/spec/default_spec.rb +6 -0
- data/test_project/site-cookbooks/a_test/service/templates/.keep +0 -0
- data/test_project/site-cookbooks/b_test/git/attributes/.keep +0 -0
- data/test_project/site-cookbooks/b_test/git/files/.keep +0 -0
- data/test_project/site-cookbooks/b_test/git/recipes/default.rb +5 -0
- data/test_project/site-cookbooks/b_test/git/spec/.keep +0 -0
- data/test_project/site-cookbooks/b_test/git/spec/default_spec.rb +5 -0
- data/test_project/site-cookbooks/b_test/git/templates/.keep +0 -0
- data/test_project/site-cookbooks/b_test/link/attributes/.keep +0 -0
- data/test_project/site-cookbooks/b_test/link/files/.keep +0 -0
- data/test_project/site-cookbooks/b_test/link/recipes/default.rb +5 -0
- data/test_project/site-cookbooks/b_test/link/spec/.keep +0 -0
- data/test_project/site-cookbooks/b_test/link/spec/default_spec.rb +5 -0
- data/test_project/site-cookbooks/b_test/link/templates/.keep +0 -0
- data/test_project/site-cookbooks/b_test/remote_file/attributes/.keep +0 -0
- data/test_project/site-cookbooks/b_test/remote_file/files/.keep +0 -0
- data/test_project/site-cookbooks/b_test/remote_file/files/remote_file.sh +1 -0
- data/test_project/site-cookbooks/b_test/remote_file/recipes/default.rb +9 -0
- data/test_project/site-cookbooks/b_test/remote_file/spec/.keep +0 -0
- data/test_project/site-cookbooks/b_test/remote_file/spec/default_spec.rb +7 -0
- data/test_project/site-cookbooks/b_test/remote_file/templates/.keep +0 -0
- data/test_project/site-cookbooks/b_test/template/attributes/.keep +0 -0
- data/test_project/site-cookbooks/b_test/template/files/.keep +0 -0
- data/test_project/site-cookbooks/b_test/template/recipes/default.rb +5 -0
- data/test_project/site-cookbooks/b_test/template/spec/.keep +0 -0
- data/test_project/site-cookbooks/b_test/template/spec/default_spec.rb +7 -0
- data/test_project/site-cookbooks/b_test/template/templates/.keep +0 -0
- data/test_project/site-cookbooks/b_test/template/templates/template.erb +2 -0
- data/test_project/site-cookbooks/c_test/execute/attributes/.keep +0 -0
- data/test_project/site-cookbooks/c_test/execute/files/.keep +0 -0
- data/test_project/site-cookbooks/c_test/execute/recipes/default.rb +6 -0
- data/test_project/site-cookbooks/c_test/execute/spec/.keep +0 -0
- data/test_project/site-cookbooks/c_test/execute/spec/default_spec.rb +6 -0
- data/test_project/site-cookbooks/c_test/execute/templates/.keep +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/attributes/.keep +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/files/.keep +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/recipes/default.rb +10 -0
- data/test_project/site-cookbooks/c_test/remote_directory/spec/.keep +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/spec/default_spec.rb +20 -0
- data/test_project/site-cookbooks/c_test/remote_directory/templates/.keep +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/templates/remote_dir/a.txt +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/templates/remote_dir/b.txt +0 -0
- data/test_project/site-cookbooks/c_test/remote_directory/templates/remote_dir/c.txt +0 -0
- data/test_project/site-cookbooks/d_spec/air/attributes/.keep +0 -0
- data/test_project/site-cookbooks/d_spec/air/files/.keep +0 -0
- data/test_project/site-cookbooks/d_spec/air/recipes/default.rb +0 -0
- data/test_project/site-cookbooks/d_spec/air/spec/.keep +0 -0
- data/test_project/site-cookbooks/d_spec/air/spec/default_spec.rb +0 -0
- data/test_project/site-cookbooks/d_spec/air/templates/.keep +0 -0
- data/test_project/spec/spec_helper.rb +33 -0
- data/test_project/tmp-nodes/.keep +0 -0
- data/test_project/tmp-nodes/test.json +12 -0
- metadata +337 -138
- data/bin/itamae-mitsurin +0 -5
- data/lib/itamae.rb +0 -18
- data/lib/itamae/ext.rb +0 -1
- data/lib/itamae/generators.rb +0 -20
- data/lib/itamae/generators/cookbook.rb +0 -22
- data/lib/itamae/generators/project.rb +0 -22
- data/lib/itamae/generators/role.rb +0 -22
- data/lib/itamae/generators/templates/project/Gemfile +0 -4
- data/lib/itamae/mitsurin.rb +0 -14
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'itamae'
|
1
|
+
require 'itamae-mitsurin'
|
2
2
|
require 'uri'
|
3
3
|
require 'net/https'
|
4
4
|
|
5
|
-
module
|
5
|
+
module ItamaeMitsurin
|
6
6
|
module Resource
|
7
7
|
class HttpRequest < File
|
8
8
|
RedirectLimitExceeded = Class.new(StandardError)
|
@@ -33,7 +33,7 @@ module Itamae
|
|
33
33
|
if redirects_followed < attributes.redirect_limit
|
34
34
|
uri = URI.parse(response["location"])
|
35
35
|
redirects_followed += 1
|
36
|
-
|
36
|
+
ItamaeMitsurin.logger.debug "Following redirect #{redirects_followed}/#{attributes.redirect_limit}"
|
37
37
|
else
|
38
38
|
raise RedirectLimitExceeded
|
39
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'itamae'
|
1
|
+
require 'itamae-mitsurin'
|
2
2
|
|
3
|
-
module
|
3
|
+
module ItamaeMitsurin
|
4
4
|
module Resource
|
5
5
|
class RemoteDirectory < Base
|
6
6
|
define_attribute :action, default: :create
|
@@ -44,11 +44,11 @@ module Itamae
|
|
44
44
|
diff = run_command(["diff", "-u", attributes.path, @temppath], error: false)
|
45
45
|
if diff.exit_status == 0
|
46
46
|
# no change
|
47
|
-
|
47
|
+
ItamaeMitsurin.logger.debug "directory content will not change"
|
48
48
|
else
|
49
|
-
|
49
|
+
ItamaeMitsurin.logger.info "diff:"
|
50
50
|
diff.stdout.each_line do |line|
|
51
|
-
|
51
|
+
ItamaeMitsurin.logger.info "#{line.strip}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'itamae'
|
1
|
+
require 'itamae-mitsurin'
|
2
2
|
|
3
|
-
module
|
3
|
+
module ItamaeMitsurin
|
4
4
|
module Resource
|
5
5
|
class RemoteFile < File
|
6
6
|
SourceNotFoundError = Class.new(StandardError)
|
@@ -27,7 +27,7 @@ module Itamae
|
|
27
27
|
source_file_exts.each do |ext|
|
28
28
|
path = ::File.join(@recipe.dir, source_file_dir, "#{dirs[i..-1].join("/")}#{ext}")
|
29
29
|
if ::File.exist?(path)
|
30
|
-
|
30
|
+
ItamaeMitsurin.logger.debug "#{path} is used as a source file."
|
31
31
|
return path
|
32
32
|
else
|
33
33
|
searched_paths << path
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'itamae'
|
1
|
+
require 'itamae-mitsurin'
|
2
2
|
require 'json'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
module
|
5
|
+
module ItamaeMitsurin
|
6
6
|
class Runner
|
7
7
|
class << self
|
8
8
|
def run(recipe_files, backend_type, options)
|
9
|
-
|
9
|
+
ItamaeMitsurin.logger.info "Starting Itamae..."
|
10
10
|
|
11
11
|
backend = Backend.create(backend_type, options)
|
12
12
|
runner = self.new(backend, options)
|
@@ -68,7 +68,7 @@ module Itamae
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def save_dependency_graph(path)
|
71
|
-
|
71
|
+
ItamaeMitsurin.logger.info "Writing recipe dependency graph to #{path}..."
|
72
72
|
open(path, 'w') do |f|
|
73
73
|
f.write(children.dependency_in_dot)
|
74
74
|
end
|
@@ -87,23 +87,23 @@ module Itamae
|
|
87
87
|
if @options[:ohai]
|
88
88
|
unless @backend.run_command("which ohai", error: false).exit_status == 0
|
89
89
|
# install Ohai
|
90
|
-
|
90
|
+
ItamaeMitsurin.logger.info "Installing Chef package... (to use Ohai)"
|
91
91
|
@backend.run_command("curl -L https://www.opscode.com/chef/install.sh | bash")
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
ItamaeMitsurin.logger.info "Loading node data via ohai..."
|
95
95
|
hash.merge!(JSON.parse(@backend.run_command("ohai").stdout))
|
96
96
|
end
|
97
97
|
|
98
98
|
if @options[:node_json]
|
99
99
|
path = File.expand_path(@options[:node_json])
|
100
|
-
|
100
|
+
ItamaeMitsurin.logger.info "Loading node data from #{path}..."
|
101
101
|
hash.merge!(JSON.load(open(path)))
|
102
102
|
end
|
103
103
|
|
104
104
|
if @options[:node_yaml]
|
105
105
|
path = File.expand_path(@options[:node_yaml])
|
106
|
-
|
106
|
+
ItamaeMitsurin.logger.info "Loading node data from #{path}..."
|
107
107
|
hash.merge!(YAML.load(open(path)) || {})
|
108
108
|
end
|
109
109
|
|
@@ -0,0 +1 @@
|
|
1
|
+
0.7
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require "itamae-mitsurin/runner"
|
3
|
+
require "itamae-mitsurin/cli"
|
4
|
+
require "itamae-mitsurin/recipe"
|
5
|
+
require "itamae-mitsurin/resource"
|
6
|
+
require "itamae-mitsurin/handler"
|
7
|
+
require "itamae-mitsurin/handler_proxy"
|
8
|
+
require "itamae-mitsurin/recipe_children"
|
9
|
+
require "itamae-mitsurin/logger"
|
10
|
+
require "itamae-mitsurin/node"
|
11
|
+
require "itamae-mitsurin/backend"
|
12
|
+
require "itamae-mitsurin/notification"
|
13
|
+
require "itamae-mitsurin/definition"
|
14
|
+
require "itamae-mitsurin/ext"
|
15
|
+
|
16
|
+
module TestItamaeMitsurin
|
17
|
+
# Your code goes here...
|
18
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# TODO: Send patches to Specinfra
|
2
|
+
|
3
|
+
module Specinfra
|
4
|
+
module Backend
|
5
|
+
class Base
|
6
|
+
def receive_file(from, to = nil)
|
7
|
+
raise NotImplementedError
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Exec < Base
|
12
|
+
def receive_file(from, to = nil)
|
13
|
+
if to
|
14
|
+
FileUtils.cp(from, to)
|
15
|
+
else
|
16
|
+
::File.read(from)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Ssh < Exec
|
22
|
+
def receive_file(from, to = nil)
|
23
|
+
scp_download!(from, to)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def scp_download!(from, to, opt={})
|
29
|
+
if get_config(:scp).nil?
|
30
|
+
set_config(:scp, create_scp)
|
31
|
+
end
|
32
|
+
|
33
|
+
scp = get_config(:scp)
|
34
|
+
scp.download!(from, to, opt)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
module ItamaeMitsurin
|
4
|
+
module Handler
|
5
|
+
class Base
|
6
|
+
attr_reader :recipes, :resources, :actions
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
|
11
|
+
@recipes = []
|
12
|
+
@resources = []
|
13
|
+
@actions = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def event(type, payload = {})
|
17
|
+
case type
|
18
|
+
when :recipe_started
|
19
|
+
@recipes << payload
|
20
|
+
when :recipe_completed, :recipe_failed
|
21
|
+
@recipes.pop
|
22
|
+
when :resource_started
|
23
|
+
@resources << payload
|
24
|
+
when :resource_completed, :resource_failed
|
25
|
+
@resources.pop
|
26
|
+
when :action_started
|
27
|
+
@actions << payload
|
28
|
+
when :action_completed, :action_failed
|
29
|
+
@actions.pop
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def hostname
|
36
|
+
@hostname ||= @options['hostname'] || Socket.gethostname
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module ItamaeMitsurin
|
2
|
+
module Handler
|
3
|
+
class Fluentd < Base
|
4
|
+
attr_accessor :fluent_logger # for test
|
5
|
+
|
6
|
+
def initialize(*)
|
7
|
+
super
|
8
|
+
load_fluent_logger
|
9
|
+
end
|
10
|
+
|
11
|
+
def event(type, payload = {})
|
12
|
+
super
|
13
|
+
|
14
|
+
unless @fluent_logger.post(type, payload.merge(hostname: hostname))
|
15
|
+
ItamaeMitsurin.logger.warn "Sending logs to Fluentd failed: #{@fluent_logger.last_error}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def load_fluent_logger
|
22
|
+
begin
|
23
|
+
require 'fluent-logger'
|
24
|
+
rescue LoadError
|
25
|
+
raise "Loading fluent-logger gem failed. Please install 'fluent-logger' gem to use fluentd handler."
|
26
|
+
end
|
27
|
+
|
28
|
+
@fluent_logger = Fluent::Logger::FluentLogger.new(tag_prefix, host: fluentd_host, port: fluentd_port)
|
29
|
+
end
|
30
|
+
|
31
|
+
def tag_prefix
|
32
|
+
@options['tag_prefix'] || 'itamae_server'
|
33
|
+
end
|
34
|
+
|
35
|
+
def fluentd_host
|
36
|
+
@options['host'] || 'localhost'
|
37
|
+
end
|
38
|
+
|
39
|
+
def fluentd_port
|
40
|
+
(@options['port'] || 24224).to_i
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ItamaeMitsurin
|
2
|
+
module Handler
|
3
|
+
class Json < Base
|
4
|
+
def initialize(*)
|
5
|
+
super
|
6
|
+
require 'time'
|
7
|
+
open_file
|
8
|
+
end
|
9
|
+
|
10
|
+
def event(type, payload = {})
|
11
|
+
super
|
12
|
+
@f.puts({'time' => Time.now.iso8601, 'event' => type, 'payload' => payload}.to_json)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def open_file
|
18
|
+
@f = open(@options.fetch('path'), 'a')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|