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,7 +1,7 @@
|
|
1
|
-
require "itamae/mitsurin/creators/cookbook"
|
2
|
-
require "itamae/mitsurin/creators/project"
|
1
|
+
require "itamae-mitsurin/mitsurin/creators/cookbook"
|
2
|
+
require "itamae-mitsurin/mitsurin/creators/project"
|
3
3
|
|
4
|
-
module
|
4
|
+
module ItamaeMitsurin
|
5
5
|
module Mitsurin
|
6
6
|
module Creators
|
7
7
|
def self.find(target)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
|
4
|
+
module ItamaeMitsurin
|
5
|
+
module Mitsurin
|
6
|
+
module Creators
|
7
|
+
class Cookbook < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.expand_path('../templates/site-cookbooks', __FILE__)
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_files
|
15
|
+
directory '.'
|
16
|
+
end
|
17
|
+
|
18
|
+
def remove_files
|
19
|
+
remove_file '.'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
|
4
|
+
module ItamaeMitsurin
|
5
|
+
module Mitsurin
|
6
|
+
module Creators
|
7
|
+
class Project < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.dirname(__FILE__) + '/templates/project'
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_files
|
15
|
+
directory '.'
|
16
|
+
end
|
17
|
+
|
18
|
+
def bundle
|
19
|
+
run 'bundle install'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
File without changes
|
File without changes
|
data/lib/{itamae → itamae-mitsurin}/mitsurin/creators/templates/project/environments/sample.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/lib/{itamae/generators → itamae-mitsurin/mitsurin/creators}/templates/project/roles/.keep
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
puts HighLine.new.color %! LOAD : Environment set is "#{node[:environments][:set]}"!, :green
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'highline'
|
3
|
+
include Rake::DSL if defined? Rake::DSL
|
4
|
+
|
5
|
+
module Itamae
|
6
|
+
module Mitsurin
|
7
|
+
class ItamaeTask
|
8
|
+
|
9
|
+
class << self
|
10
|
+
class ::Hash
|
11
|
+
def deep_merge(other)
|
12
|
+
merger = lambda {|key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2}
|
13
|
+
self.merge(other, &merger)
|
14
|
+
end
|
15
|
+
|
16
|
+
def deep_merge!(other)
|
17
|
+
merger = lambda {|key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2}
|
18
|
+
self.merge!(other, &merger)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_roles(node_file)
|
23
|
+
roles = []
|
24
|
+
JSON.parse(File.read(node_file))['run_list'].each do |role|
|
25
|
+
roles << role.gsub(/role\[(.+)\]/, '\1') if /role\[(.+)\]/ === role
|
26
|
+
end
|
27
|
+
roles
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.get_recipes(role)
|
31
|
+
recipes = []
|
32
|
+
JSON.parse(File.read("roles/#{role}.json"))['run_list'].each do |recipe|
|
33
|
+
if /recipe\[(.+)::(.+)\]/ === recipe
|
34
|
+
recipes << {recipe.gsub(/recipe\[(.+)::(.+)\]/, '\1') => recipe.gsub(/recipe\[(.+)::(.+)\]/, '\2')}
|
35
|
+
else
|
36
|
+
recipes << {recipe.gsub(/recipe\[(.+)\]/, '\1') => nil}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
recipes
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.get_node_recipes(node_file)
|
43
|
+
recipes = []
|
44
|
+
JSON.parse(File.read(node_file))['run_list'].each do |recipe|
|
45
|
+
if /recipe\[(.+)::(.+)\]/ === recipe
|
46
|
+
recipes << {recipe.gsub(/recipe\[(.+)::(.+)\]/, '\1') => recipe.gsub(/recipe\[(.+)::(.+)\]/, '\2')}
|
47
|
+
else
|
48
|
+
recipes << {recipe.gsub(/recipe\[(.+)\]/, '\1') => nil} unless /role\[(.+)\]/ === recipe
|
49
|
+
end
|
50
|
+
end
|
51
|
+
recipes
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.jq(*objs)
|
55
|
+
par = nil
|
56
|
+
objs.each {|obj| par = JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)}
|
57
|
+
return par
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.write_json(filename)
|
61
|
+
File.open "tmp-nodes/#{filename}.json", 'w' do |f|
|
62
|
+
f.flock File::LOCK_EX
|
63
|
+
yield f
|
64
|
+
f.flock File::LOCK_UN
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
hl = HighLine.new
|
69
|
+
|
70
|
+
namespace :itamae do
|
71
|
+
Dir.glob("nodes/**/*.json").each do |node_file|
|
72
|
+
|
73
|
+
bname = File.basename(node_file, '.json')
|
74
|
+
node_h = JSON.parse(File.read(node_file), symbolize_names: true)
|
75
|
+
|
76
|
+
desc "Itamae to #{bname}"
|
77
|
+
task node_h[:environments][:hostname].split(".")[0] do
|
78
|
+
begin
|
79
|
+
recipes = []
|
80
|
+
get_roles(node_file).each do |role|
|
81
|
+
recipes << get_recipes(role)
|
82
|
+
end
|
83
|
+
get_node_recipes(node_file).each do |recipe|
|
84
|
+
recipes << recipe
|
85
|
+
end
|
86
|
+
rescue Exception => e
|
87
|
+
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
88
|
+
puts "nodefile or role error, nodefile:#{node_file} reason:#{e.message}"
|
89
|
+
exit 1
|
90
|
+
else
|
91
|
+
recipes.flatten!
|
92
|
+
end
|
93
|
+
|
94
|
+
# get env attr
|
95
|
+
begin
|
96
|
+
env_set = node_h[:environments][:set]
|
97
|
+
env_h = JSON.parse(File.read("environments/#{env_set}.json"), symbolize_names: true)
|
98
|
+
rescue Exception => e
|
99
|
+
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
100
|
+
puts "nodefile or environments error, nodefile:#{node_file} reason:#{e.message}"
|
101
|
+
exit 1
|
102
|
+
end
|
103
|
+
|
104
|
+
# get recipes attr
|
105
|
+
recipe_attr_file = []
|
106
|
+
recipes.each do |recipe_h|
|
107
|
+
if recipe_h["#{recipe_h.keys.join}"].nil?
|
108
|
+
recipe_attr_file.insert 0,
|
109
|
+
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/default.json")
|
110
|
+
else
|
111
|
+
recipe_attr_file <<
|
112
|
+
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/#{recipe_h["#{recipe_h.keys.join}"]}.json")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
recipe_attr_file.flatten!
|
117
|
+
|
118
|
+
# recipes attr other=env
|
119
|
+
recipe_env_h_a = []
|
120
|
+
recipe_attr_file.each do |file|
|
121
|
+
recipe_h = JSON.parse(File.read(file), symbolize_names: true)
|
122
|
+
recipe_env_h_a << recipe_h.deep_merge(env_h)
|
123
|
+
end
|
124
|
+
|
125
|
+
# recipe attr other=recipes_env
|
126
|
+
moto = recipe_env_h_a[0]
|
127
|
+
recipe_env_h_a.each {|hash| moto.deep_merge!(hash)}
|
128
|
+
recipe_env_h = moto
|
129
|
+
|
130
|
+
if recipe_env_h.nil?
|
131
|
+
# env attr other=node
|
132
|
+
node_env_h = env_h.deep_merge(node_h)
|
133
|
+
node_env_j = jq node_env_h
|
134
|
+
write_json(bname) {|file| file.puts node_env_j}
|
135
|
+
else
|
136
|
+
# recipe_env attr other=node
|
137
|
+
recipe_env_node_h = recipe_env_h.deep_merge(node_h)
|
138
|
+
recipe_env_node_j = jq recipe_env_node_h
|
139
|
+
write_json(bname) {|file| file.puts recipe_env_node_j}
|
140
|
+
end
|
141
|
+
|
142
|
+
recipes << {'_base' => nil}
|
143
|
+
node_property = JSON.parse(File.read("tmp-nodes/#{bname}.json"), symbolize_names: true)
|
144
|
+
node = node_property[:environments][:hostname]
|
145
|
+
ssh_user = node_property[:environments][:ssh_user]
|
146
|
+
ssh_password = node_property[:environments][:ssh_password]
|
147
|
+
sudo_password = node_property[:environments][:sudo_password]
|
148
|
+
ssh_port = node_property[:environments][:ssh_port]
|
149
|
+
ssh_key = node_property[:environments][:ssh_key]
|
150
|
+
|
151
|
+
ENV['TARGET_HOST'] = node
|
152
|
+
ENV['NODE_FILE'] = node_file
|
153
|
+
ENV['SSH_PASSWORD'] = ssh_password
|
154
|
+
ENV['SUDO_PASSWORD'] = sudo_password
|
155
|
+
|
156
|
+
command = "bundle exec itamae ssh"
|
157
|
+
command << " -h #{node}"
|
158
|
+
command << " -u #{ssh_user}"
|
159
|
+
command << " -p #{ssh_port}"
|
160
|
+
command << " -i keys/#{ssh_key}" unless ssh_key.nil?
|
161
|
+
command << " -j tmp-nodes/#{bname}.json"
|
162
|
+
command << " --shell=bash"
|
163
|
+
command << " --ask-password" unless ssh_password.nil?
|
164
|
+
command << " --dry-run" if ENV['dry_run'] == "true"
|
165
|
+
command << " -l debug" if ENV['debug'] == "true"
|
166
|
+
|
167
|
+
# recipe load to_command
|
168
|
+
command_recipe = []
|
169
|
+
recipes.each do |recipe_h|
|
170
|
+
if recipe_h["#{recipe_h.keys.join}"].nil?
|
171
|
+
command_recipe <<
|
172
|
+
" #{Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/recipes/default.rb").join}"
|
173
|
+
else
|
174
|
+
command_recipe <<
|
175
|
+
" #{Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/recipes/#{recipe_h["#{recipe_h.keys.join}"]}.rb").join}"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
command_recipe.sort_by! {|item| File.dirname(item)}
|
179
|
+
command << command_recipe.join
|
180
|
+
|
181
|
+
puts hl.color(%!Run Itamae to \"#{bname}\"!, :red)
|
182
|
+
puts hl.color(%!Role List to \"#{get_roles(node_file).join(", ")}\"!, :blue)
|
183
|
+
run_list_noti = []
|
184
|
+
command_recipe.each {|c_recipe| run_list_noti << c_recipe.split("/") [2]}
|
185
|
+
puts hl.color(%!Run List to \"#{run_list_noti.uniq.join(", ")}\"!, :green)
|
186
|
+
puts hl.color(%!#{command}!, :white)
|
187
|
+
st = system command
|
188
|
+
exit 1 unless st
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
require 'specinfra'
|
2
|
+
require 'json'
|
3
|
+
require 'highline'
|
4
|
+
require 'specinfra/helper/set'
|
5
|
+
include Specinfra::Helper::Set
|
6
|
+
include Rake::DSL if defined? Rake::DSL
|
7
|
+
|
8
|
+
module Itamae
|
9
|
+
module Mitsurin
|
10
|
+
class ItamaeTask
|
11
|
+
|
12
|
+
class << self
|
13
|
+
class ::Hash
|
14
|
+
def deep_merge(other)
|
15
|
+
merger = lambda {|key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2}
|
16
|
+
self.merge(other, &merger)
|
17
|
+
end
|
18
|
+
|
19
|
+
def deep_merge!(other)
|
20
|
+
merger = lambda {|key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2}
|
21
|
+
self.merge!(other, &merger)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_roles(node_file)
|
26
|
+
roles = []
|
27
|
+
JSON.parse(File.read(node_file))['run_list'].each do |role|
|
28
|
+
roles << role.gsub(/role\[(.+)\]/, '\1') if /role\[(.+)\]/ === role
|
29
|
+
end
|
30
|
+
roles
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.get_recipes(role)
|
34
|
+
recipes = []
|
35
|
+
JSON.parse(File.read("roles/#{role}.json"))['run_list'].each do |recipe|
|
36
|
+
if /recipe\[(.+)::(.+)\]/ === recipe
|
37
|
+
recipes << {recipe.gsub(/recipe\[(.+)::(.+)\]/, '\1') => recipe.gsub(/recipe\[(.+)::(.+)\]/, '\2')}
|
38
|
+
else
|
39
|
+
recipes << {recipe.gsub(/recipe\[(.+)\]/, '\1') => nil}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
recipes
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.get_node_recipes(node_file)
|
46
|
+
recipes = []
|
47
|
+
JSON.parse(File.read(node_file))['run_list'].each do |recipe|
|
48
|
+
if /recipe\[(.+)::(.+)\]/ === recipe
|
49
|
+
recipes << {recipe.gsub(/recipe\[(.+)::(.+)\]/, '\1') => recipe.gsub(/recipe\[(.+)::(.+)\]/, '\2')}
|
50
|
+
else
|
51
|
+
recipes << {recipe.gsub(/recipe\[(.+)\]/, '\1') => nil} unless /role\[(.+)\]/ === recipe
|
52
|
+
end
|
53
|
+
end
|
54
|
+
recipes
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.jq(*objs)
|
58
|
+
par = nil
|
59
|
+
objs.each {|obj| par = JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)}
|
60
|
+
return par
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.write_json(filename)
|
64
|
+
File.open "tmp-nodes/#{filename}.json", 'w' do |f|
|
65
|
+
f.flock File::LOCK_EX
|
66
|
+
yield f
|
67
|
+
f.flock File::LOCK_UN
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
hl = HighLine.new
|
72
|
+
|
73
|
+
set :backend, :exec
|
74
|
+
|
75
|
+
namespace :itamae do
|
76
|
+
branches = Specinfra.backend.run_command('git branch')
|
77
|
+
branch = branches.stdout.split("\n").select{|a| /\*/ === a }
|
78
|
+
branch = branch.join.gsub(/\* (.+)/, '\1')
|
79
|
+
if branch == 'staging'
|
80
|
+
branch = 'staging/**'
|
81
|
+
elsif branch == 'master'
|
82
|
+
branch = 'production/**'
|
83
|
+
else
|
84
|
+
branch = 'other/**'
|
85
|
+
end
|
86
|
+
|
87
|
+
Dir.glob("nodes/#{branch}/*.json").each do |node_file|
|
88
|
+
|
89
|
+
bname = File.basename(node_file, '.json')
|
90
|
+
node_h = JSON.parse(File.read(node_file), symbolize_names: true)
|
91
|
+
|
92
|
+
desc "Itamae to #{bname}"
|
93
|
+
task node_h[:environments][:hostname].split(".")[0] do
|
94
|
+
begin
|
95
|
+
recipes = []
|
96
|
+
get_roles(node_file).each do |role|
|
97
|
+
recipes << get_recipes(role)
|
98
|
+
end
|
99
|
+
get_node_recipes(node_file).each do |recipe|
|
100
|
+
recipes << recipe
|
101
|
+
end
|
102
|
+
rescue Exception => e
|
103
|
+
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
104
|
+
puts "nodefile or role error, nodefile:#{node_file} reason:#{e.message}"
|
105
|
+
exit 1
|
106
|
+
else
|
107
|
+
recipes.flatten!
|
108
|
+
end
|
109
|
+
|
110
|
+
# get env attr
|
111
|
+
begin
|
112
|
+
env_set = node_h[:environments][:set]
|
113
|
+
env_h = JSON.parse(File.read("environments/#{env_set}.json"), symbolize_names: true)
|
114
|
+
rescue Exception => e
|
115
|
+
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
116
|
+
puts "nodefile or environments error, nodefile:#{node_file} reason:#{e.message}"
|
117
|
+
exit 1
|
118
|
+
end
|
119
|
+
|
120
|
+
# get recipe attr
|
121
|
+
recipe_attr_file = []
|
122
|
+
recipes.each do |recipe_h|
|
123
|
+
if recipe_h["#{recipe_h.keys.join}"].nil?
|
124
|
+
recipe_attr_file.insert 0,
|
125
|
+
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/default.json")
|
126
|
+
else
|
127
|
+
recipe_attr_file <<
|
128
|
+
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/#{recipe_h["#{recipe_h.keys.join}"]}.json")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
recipe_attr_file.flatten!
|
133
|
+
|
134
|
+
# recipe attr other=env
|
135
|
+
recipe_env_h_a = []
|
136
|
+
recipe_attr_file.each do |file|
|
137
|
+
recipe_h = JSON.parse(File.read(file), symbolize_names: true)
|
138
|
+
recipe_env_h_a << recipe_h.deep_merge(env_h)
|
139
|
+
end
|
140
|
+
|
141
|
+
# recipe attr other=recipes
|
142
|
+
moto = recipe_env_h_a[0]
|
143
|
+
recipe_env_h_a.each {|hash| moto.deep_merge!(hash)}
|
144
|
+
recipe_env_h = moto
|
145
|
+
|
146
|
+
if recipe_env_h.nil?
|
147
|
+
# node attr other=env
|
148
|
+
node_env_h = env_h.deep_merge(node_h)
|
149
|
+
node_env_j = jq node_env_h
|
150
|
+
write_json(bname) {|file| file.puts node_env_j}
|
151
|
+
else
|
152
|
+
# node attr other=recipe_env
|
153
|
+
recipe_env_node_h = recipe_env_h.deep_merge(node_h)
|
154
|
+
recipe_env_node_j = jq recipe_env_node_h
|
155
|
+
write_json(bname) {|file| file.puts recipe_env_node_j}
|
156
|
+
end
|
157
|
+
|
158
|
+
recipes << {'_base' => nil}
|
159
|
+
node_property = JSON.parse(File.read("tmp-nodes/#{bname}.json"), symbolize_names: true)
|
160
|
+
node = node_property[:environments][:hostname]
|
161
|
+
ssh_user = node_property[:environments][:ssh_user]
|
162
|
+
ssh_password = node_property[:environments][:ssh_password]
|
163
|
+
sudo_password = node_property[:environments][:sudo_password]
|
164
|
+
ssh_port = node_property[:environments][:ssh_port]
|
165
|
+
ssh_key = node_property[:environments][:ssh_key]
|
166
|
+
|
167
|
+
ENV['TARGET_HOST'] = node
|
168
|
+
ENV['NODE_FILE'] = node_file
|
169
|
+
ENV['SSH_PASSWORD'] = ssh_password
|
170
|
+
ENV['SUDO_PASSWORD'] = sudo_password
|
171
|
+
|
172
|
+
command = "bundle exec itamae ssh"
|
173
|
+
command << " -h #{node}"
|
174
|
+
command << " -u #{ssh_user}"
|
175
|
+
command << " -p #{ssh_port}"
|
176
|
+
command << " -i keys/#{ssh_key}" unless ssh_key.nil?
|
177
|
+
command << " -j tmp-nodes/#{bname}.json"
|
178
|
+
command << " --shell=bash"
|
179
|
+
command << " --ask-password" unless ssh_password.nil?
|
180
|
+
command << " --dry-run" if ENV['dry_run'] == "true"
|
181
|
+
command << " -l debug" if ENV['debug'] == "true"
|
182
|
+
|
183
|
+
# recipe load to_command
|
184
|
+
command_recipe = []
|
185
|
+
recipes.each do |recipe_h|
|
186
|
+
if recipe_h["#{recipe_h.keys.join}"].nil?
|
187
|
+
command_recipe <<
|
188
|
+
" #{Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/recipes/default.rb").join}"
|
189
|
+
else
|
190
|
+
command_recipe <<
|
191
|
+
" #{Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/recipes/#{recipe_h["#{recipe_h.keys.join}"]}.rb").join}"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
command_recipe.sort_by! {|item| File.dirname(item)}
|
195
|
+
command << command_recipe.join
|
196
|
+
|
197
|
+
puts hl.color(%!Run Itamae to \"#{bname}\"!, :red)
|
198
|
+
puts hl.color(%!Role List to \"#{get_roles(node_file).join(", ")}\"!, :blue)
|
199
|
+
run_list_noti = []
|
200
|
+
command_recipe.each {|c_recipe| run_list_noti << c_recipe.split("/") [2]}
|
201
|
+
puts hl.color(%!Run List to \"#{run_list_noti.uniq.join(", ")}\"!, :green)
|
202
|
+
puts hl.color(%!#{command}!, :white)
|
203
|
+
st = system command
|
204
|
+
exit 1 unless st
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|