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
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
require 'thor'
|
3
|
+
require 'test/unit'
|
4
|
+
include Test::Unit::TestCase
|
5
|
+
|
6
|
+
module TestItamaeMitsurin
|
7
|
+
class TestCLI < Thor
|
8
|
+
|
9
|
+
class_option :log_level, type: :string, aliases: ['-l'], default: 'info'
|
10
|
+
class_option :color, type: :boolean, default: true
|
11
|
+
class_option :config, type: :string, aliases: ['-c']
|
12
|
+
|
13
|
+
def initialize(*)
|
14
|
+
super
|
15
|
+
|
16
|
+
ItamaeMitsurin.logger.level = ::Logger.const_get(options[:log_level].upcase)
|
17
|
+
ItamaeMitsurin.logger.formatter.colored = options[:color]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.define_exec_options
|
21
|
+
option :recipe_graph, type: :string, desc: "[EXPERIMENTAL] Write recipe dependency graph in DOT", banner: "PATH"
|
22
|
+
option :node_json, type: :string, aliases: ['-j']
|
23
|
+
option :node_yaml, type: :string, aliases: ['-y']
|
24
|
+
option :dry_run, type: :boolean, aliases: ['-n']
|
25
|
+
option :shell, type: :string, default: "/bin/sh"
|
26
|
+
option :ohai, type: :boolean, default: false, desc: "This option is DEPRECATED and will be unavailable."
|
27
|
+
option :profile, type: :string, desc: "[EXPERIMENTAL] Save profiling data", banner: "PATH"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "local RECIPE [RECIPE...]", "Run Itamae locally"
|
31
|
+
define_exec_options
|
32
|
+
def local(*recipe_files)
|
33
|
+
if recipe_files.empty?
|
34
|
+
raise "Please specify recipe files."
|
35
|
+
end
|
36
|
+
|
37
|
+
Runner.run(recipe_files, :local, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "ssh RECIPE [RECIPE...]", "Run Itamae via ssh"
|
41
|
+
define_exec_options
|
42
|
+
option :host, type: :string, aliases: ['-h']
|
43
|
+
option :user, type: :string, aliases: ['-u']
|
44
|
+
option :key, type: :string, aliases: ['-i']
|
45
|
+
option :port, type: :numeric, aliases: ['-p']
|
46
|
+
option :vagrant, type: :boolean, default: false
|
47
|
+
option :ask_password, type: :boolean, default: false
|
48
|
+
option :sudo, type: :boolean, default: true
|
49
|
+
def ssh(*recipe_files)
|
50
|
+
if recipe_files.empty?
|
51
|
+
raise "Please specify recipe files."
|
52
|
+
end
|
53
|
+
|
54
|
+
unless options[:host] || options[:vagrant]
|
55
|
+
raise "Please set '-h <hostname>' or '--vagrant'"
|
56
|
+
end
|
57
|
+
|
58
|
+
Runner.run(recipe_files, :ssh, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "docker RECIPE [RECIPE...]", "Create Docker image"
|
62
|
+
define_exec_options
|
63
|
+
option :image, type: :string, desc: "This option or 'container' option is required."
|
64
|
+
option :container, type: :string, desc: "This option or 'image' option is required."
|
65
|
+
option :tls_verify_peer, type: :boolean, default: true
|
66
|
+
def docker(*recipe_files)
|
67
|
+
if recipe_files.empty?
|
68
|
+
raise "Please specify recipe files."
|
69
|
+
end
|
70
|
+
|
71
|
+
Runner.run(recipe_files, :docker, options)
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "version", "Print version"
|
75
|
+
def version
|
76
|
+
puts "itamae-mitsurin v#{ItamaeMitsurin::VERSION}"
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def options
|
81
|
+
@itamae_options ||= super.dup.tap do |options|
|
82
|
+
if config = options[:config]
|
83
|
+
options.merge!(YAML.load_file(config))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
|
3
|
+
module ItamaeMitsurin
|
4
|
+
class Definition < Resource::Base
|
5
|
+
class << self
|
6
|
+
attr_accessor :definition_block
|
7
|
+
attr_accessor :defined_in_recipe
|
8
|
+
|
9
|
+
def create_class(name, params, defined_in_recipe, &block)
|
10
|
+
Class.new(self).tap do |klass|
|
11
|
+
klass.definition_block = block
|
12
|
+
klass.defined_in_recipe = defined_in_recipe
|
13
|
+
|
14
|
+
klass.define_attribute :action, default: :run
|
15
|
+
params.each_pair do |key, value|
|
16
|
+
klass.define_attribute key.to_sym, type: Object, default: value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(*args)
|
23
|
+
super
|
24
|
+
|
25
|
+
r = Recipe::RecipeFromDefinition.new(
|
26
|
+
runner,
|
27
|
+
self.class.defined_in_recipe.path,
|
28
|
+
)
|
29
|
+
recipe.children << r
|
30
|
+
|
31
|
+
r.definition = self
|
32
|
+
r.load(params: @attributes.merge(name: resource_name))
|
33
|
+
end
|
34
|
+
|
35
|
+
def run(*args)
|
36
|
+
# nothing
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'itamae-mitsurin/ext/specinfra'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'itamae-mitsurin/handler/base'
|
2
|
+
|
3
|
+
module ItamaeMitsurin
|
4
|
+
module Handler
|
5
|
+
def self.from_type(type)
|
6
|
+
first_time = true
|
7
|
+
|
8
|
+
class_name = type.split('_').map(&:capitalize).join
|
9
|
+
self.const_get(class_name)
|
10
|
+
rescue NameError
|
11
|
+
require "itamae-mitsurin/handler/#{type}"
|
12
|
+
|
13
|
+
if first_time
|
14
|
+
first_time = false
|
15
|
+
retry
|
16
|
+
else
|
17
|
+
raise
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ItamaeMitsurin
|
2
|
+
class HandlerProxy
|
3
|
+
def initialize
|
4
|
+
@instances = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def register_instance(instance)
|
8
|
+
@instances << instance
|
9
|
+
end
|
10
|
+
|
11
|
+
def event(*args, &block)
|
12
|
+
if block_given?
|
13
|
+
_event_with_block(*args, &block)
|
14
|
+
else
|
15
|
+
_event(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def _event(*args)
|
22
|
+
@instances.each do |i|
|
23
|
+
i.event(*args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def _event_with_block(event_name, *args, &block)
|
28
|
+
event("#{event_name}_started".to_sym, *args)
|
29
|
+
block.call
|
30
|
+
rescue
|
31
|
+
event("#{event_name}_failed".to_sym, *args)
|
32
|
+
raise
|
33
|
+
else
|
34
|
+
event("#{event_name}_completed".to_sym, *args)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
require 'logger'
|
3
|
+
require 'ansi/code'
|
4
|
+
|
5
|
+
module ItamaeMitsurin
|
6
|
+
module Logger
|
7
|
+
module Helper
|
8
|
+
def with_indent
|
9
|
+
indent
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
outdent
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_indent_if(condition, &block)
|
16
|
+
if condition
|
17
|
+
with_indent(&block)
|
18
|
+
else
|
19
|
+
block.call
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def indent
|
24
|
+
self.indent_depth += 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def outdent
|
28
|
+
self.indent_depth -= 1
|
29
|
+
self.indent_depth = 0 if self.indent_depth < 0
|
30
|
+
end
|
31
|
+
|
32
|
+
def indent_depth
|
33
|
+
@indent_depth ||= 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def indent_depth=(val)
|
37
|
+
@indent_depth = val
|
38
|
+
end
|
39
|
+
|
40
|
+
def color(code, &block)
|
41
|
+
if self.formatter.respond_to?(:color)
|
42
|
+
self.formatter.color(code, &block)
|
43
|
+
else
|
44
|
+
block.call
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
%w!debug info warn error fatal unknown!.each do |level|
|
49
|
+
module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
50
|
+
def #{level}(msg)
|
51
|
+
super(" " * indent_depth + msg)
|
52
|
+
end
|
53
|
+
EOC
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Formatter
|
58
|
+
attr_accessor :colored
|
59
|
+
|
60
|
+
def call(severity, datetime, progname, msg)
|
61
|
+
log = "%s : %s\n" % ["%5s" % severity, msg2str(msg)]
|
62
|
+
if colored
|
63
|
+
colorize(log, severity)
|
64
|
+
else
|
65
|
+
log
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def color(code)
|
70
|
+
prev_color = @color
|
71
|
+
@color = code
|
72
|
+
yield
|
73
|
+
ensure
|
74
|
+
@color = prev_color
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def msg2str(msg)
|
80
|
+
case msg
|
81
|
+
when ::String
|
82
|
+
msg
|
83
|
+
when ::Exception
|
84
|
+
"#{ msg.message } (#{ msg.class })\n" <<
|
85
|
+
(msg.backtrace || []).join("\n")
|
86
|
+
else
|
87
|
+
msg.inspect
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def colorize(str, severity)
|
92
|
+
if @color
|
93
|
+
color_code = @color
|
94
|
+
else
|
95
|
+
color_code = case severity
|
96
|
+
when "INFO"
|
97
|
+
:clear
|
98
|
+
when "WARN"
|
99
|
+
:magenta
|
100
|
+
when "ERROR"
|
101
|
+
:red
|
102
|
+
else
|
103
|
+
:clear
|
104
|
+
end
|
105
|
+
end
|
106
|
+
ANSI.public_send(color_code) { str }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
@logger = ::Logger.new($stdout).tap do |l|
|
112
|
+
l.formatter = ItamaeMitsurin::Logger::Formatter.new
|
113
|
+
end.extend(ItamaeMitsurin::Logger::Helper)
|
114
|
+
|
115
|
+
class << self
|
116
|
+
def logger
|
117
|
+
@logger
|
118
|
+
end
|
119
|
+
|
120
|
+
def logger=(l)
|
121
|
+
@logger = l.extend(ItamaeMitsurin::Logger::Helper)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'itamae-mitsurin/version'
|
2
|
+
require 'itamae-mitsurin/mitsurin/cli'
|
3
|
+
require 'itamae-mitsurin/mitsurin/creators'
|
4
|
+
require 'aws-sdk'
|
5
|
+
#require 'itamae-mitsurin/mitsurin/itamae_task'
|
6
|
+
#require 'itamae-mitsurin/mitsurin/serverspec_task'
|
7
|
+
#require 'itamae-mitsurin/mitsurin/itamae_with_git_task'
|
8
|
+
|
9
|
+
|
10
|
+
module ItamaeMitsurin
|
11
|
+
module Mitsurin
|
12
|
+
# TODO
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
require 'hashie'
|
3
|
+
require 'json'
|
4
|
+
require 'schash'
|
5
|
+
|
6
|
+
module ItamaeMitsurin
|
7
|
+
class Node
|
8
|
+
ValidationError = Class.new(StandardError)
|
9
|
+
|
10
|
+
attr_reader :mash
|
11
|
+
|
12
|
+
def initialize(hash, backend)
|
13
|
+
@mash = Hashie::Mash.new(hash)
|
14
|
+
@backend = backend
|
15
|
+
end
|
16
|
+
|
17
|
+
def reverse_merge(other_hash)
|
18
|
+
self.class.new(_reverse_merge(other_hash), @backend)
|
19
|
+
end
|
20
|
+
|
21
|
+
def reverse_merge!(other_hash)
|
22
|
+
@mash.replace(_reverse_merge(other_hash))
|
23
|
+
end
|
24
|
+
|
25
|
+
def [](key)
|
26
|
+
if @mash.has_key?(key)
|
27
|
+
@mash[key]
|
28
|
+
else
|
29
|
+
fetch_inventory_value(key)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!(&block)
|
34
|
+
errors = Schash::Validator.new(&block).validate(@mash)
|
35
|
+
unless errors.empty?
|
36
|
+
errors.each do |error|
|
37
|
+
ItamaeMitsurin.logger.error "'#{error.position.join('->')}' #{error.message}"
|
38
|
+
end
|
39
|
+
raise ValidationError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def _reverse_merge(other_hash)
|
46
|
+
Hashie::Mash.new(other_hash).merge(@mash)
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing(method, *args)
|
50
|
+
if @mash.respond_to?(method)
|
51
|
+
return @mash.public_send(method, *args)
|
52
|
+
elsif args.empty? && value = fetch_inventory_value(method)
|
53
|
+
return value
|
54
|
+
end
|
55
|
+
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def respond_to?(method, priv = false)
|
60
|
+
@mash.respond_to?(method, priv) || super
|
61
|
+
end
|
62
|
+
|
63
|
+
def fetch_inventory_value(key)
|
64
|
+
value = @backend.host_inventory[key]
|
65
|
+
if value.is_a?(Hash)
|
66
|
+
value = Hashie::Mash.new(value)
|
67
|
+
end
|
68
|
+
|
69
|
+
value
|
70
|
+
rescue NotImplementedError, NameError
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'itamae-mitsurin'
|
2
|
+
|
3
|
+
module ItamaeMitsurin
|
4
|
+
class Notification < Struct.new(:defined_in_resource, :action, :target_resource_desc, :timing)
|
5
|
+
def self.create(*args)
|
6
|
+
self.new(*args).tap(&:validate!)
|
7
|
+
end
|
8
|
+
|
9
|
+
def resource
|
10
|
+
runner.children.find_resource_by_description(target_resource_desc)
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
action_resource.run(action)
|
15
|
+
end
|
16
|
+
|
17
|
+
def action_resource
|
18
|
+
resource
|
19
|
+
end
|
20
|
+
|
21
|
+
def runner
|
22
|
+
defined_in_resource.recipe.runner
|
23
|
+
end
|
24
|
+
|
25
|
+
def delayed?
|
26
|
+
[:delay, :delayed].include?(timing)
|
27
|
+
end
|
28
|
+
|
29
|
+
def immediately?
|
30
|
+
timing == :immediately
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate!
|
34
|
+
unless [:delay, :delayed, :immediately].include?(timing)
|
35
|
+
ItamaeMitsurin.logger.error "'#{timing}' is not valid notification timing. (Valid option is delayed or immediately)"
|
36
|
+
abort
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Subscription < Notification
|
42
|
+
def action_resource
|
43
|
+
defined_in_resource
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|