itamae-mitsurin 0.32 → 0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e3f1370d112d2e17244121f7844b94d13d35efd
|
|
4
|
+
data.tar.gz: 93da50239d20cb233da87db9974d74b1d50083a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e26ec058020c8bab2607f7c71ea9ecfe9da021ae5062c836653d9541742c386cbca28bc9f2289e4a474a3e583a82678fc6ea6f7e80f541051a51141c41c7a91
|
|
7
|
+
data.tar.gz: 21aa878a2c844a67d7e6475c4c2746f253db1f04c331faf28ed9d78909dd76ec35c27cd4ad51afacf20d1e48faec9b0794b36682110438018663c026515b55fd
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
### The main itamae task
|
|
2
2
|
require 'itamae-mitsurin/mitsurin/itamae_task'
|
|
3
3
|
|
|
4
|
-
### Change the
|
|
4
|
+
### Change the nodes to be load by a branch of the current git
|
|
5
|
+
### In the case of now 'master' the task nodes in the 'nodes/master/'
|
|
5
6
|
# require 'itamae-mitsurin/mitsurin/itamae_with_git_task'
|
|
6
7
|
|
|
8
|
+
### Change the nodes to be read by a target mode
|
|
9
|
+
### `rake -T <target>` to load a 'nodes/<target>'
|
|
10
|
+
# require 'itamae-mitsurin/mitsurin/itamae_with_target_task'
|
|
11
|
+
|
|
7
12
|
### Itamae task for AWS ec2instnce
|
|
8
13
|
require 'itamae-mitsurin/mitsurin/local_task'
|
|
9
14
|
|
data/lib/itamae-mitsurin/mitsurin/{itamae_with_git_task_old.rb → itamae_with_target_task.rb}
RENAMED
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
require 'specinfra'
|
|
2
|
-
require 'json'
|
|
3
|
-
require 'highline'
|
|
4
|
-
require 'specinfra/helper/set'
|
|
5
1
|
require 'itamae-mitsurin/mitsurin/task_base'
|
|
6
|
-
include Specinfra::Helper::Set
|
|
7
2
|
include Rake::DSL if defined? Rake::DSL
|
|
8
3
|
|
|
9
|
-
module
|
|
4
|
+
module ItamaeMitsurin
|
|
10
5
|
module Mitsurin
|
|
11
6
|
class ItamaeTask
|
|
12
7
|
|
|
13
|
-
set :backend, :exec
|
|
14
|
-
|
|
15
8
|
namespace :itamae do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
if (ARGV[0] == '-T' || ARGV[0] == '--tasks') && ARGV[1] != nil
|
|
10
|
+
if File.exists?("nodes/#{ARGV[1]}")
|
|
11
|
+
project_h = {:project => ARGV[1]}
|
|
12
|
+
File.open "Project.json", 'w' do |f|
|
|
13
|
+
f.flock File::LOCK_EX
|
|
14
|
+
f.puts project_h.to_json
|
|
15
|
+
f.flock File::LOCK_UN
|
|
16
|
+
end
|
|
17
|
+
puts TaskBase.hl.color "Changed target mode '#{ARGV[1]}'", :green
|
|
18
|
+
else
|
|
19
|
+
raise "Change mode error '#{ARGV[1]}' is not exists"
|
|
20
|
+
end
|
|
27
21
|
end
|
|
22
|
+
ret = JSON.parse(File.read("Project.json"))
|
|
23
|
+
target = ret["project"] << '/**'
|
|
28
24
|
|
|
29
|
-
Dir.glob("nodes/#{
|
|
30
|
-
|
|
25
|
+
Dir.glob("nodes/#{target}/*.json").each do |node_file|
|
|
31
26
|
bname = File.basename(node_file, '.json')
|
|
32
|
-
|
|
27
|
+
|
|
28
|
+
begin
|
|
29
|
+
node_h = JSON.parse(File.read(node_file), symbolize_names: true)
|
|
30
|
+
rescue JSON::ParserError => e
|
|
31
|
+
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
|
32
|
+
puts "Node error, nodefile:#{node_file}, reason:#{e.message}"
|
|
33
|
+
end
|
|
33
34
|
|
|
34
35
|
desc "Itamae to #{bname}"
|
|
35
36
|
task node_h[:environments][:hostname].split(".")[0] do
|
|
@@ -43,7 +44,7 @@ module Itamae
|
|
|
43
44
|
end
|
|
44
45
|
rescue Exception => e
|
|
45
46
|
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
|
46
|
-
puts "
|
|
47
|
+
puts "Node or role error, nodefile:#{node_file}, reason:#{e.message}"
|
|
47
48
|
else
|
|
48
49
|
recipes.flatten!
|
|
49
50
|
end
|
|
@@ -51,18 +52,19 @@ module Itamae
|
|
|
51
52
|
# get env attr
|
|
52
53
|
begin
|
|
53
54
|
env_set = node_h[:environments][:set]
|
|
55
|
+
raise "No environments set error" if env_set.nil?
|
|
54
56
|
env_h = JSON.parse(File.read("environments/#{env_set}.json"), symbolize_names: true)
|
|
55
57
|
rescue Exception => e
|
|
56
58
|
puts e.class.to_s + ", " + e.backtrace[0].to_s
|
|
57
|
-
puts "
|
|
59
|
+
puts "Node or environment error, nodefile:#{node_file}, reason:#{e.message}"
|
|
58
60
|
end
|
|
59
61
|
|
|
60
|
-
# get
|
|
62
|
+
# get recipes attr
|
|
61
63
|
recipe_attr_file = []
|
|
62
64
|
recipes.each do |recipe_h|
|
|
63
|
-
if recipe_h["#{recipe_h.keys.join}"]
|
|
65
|
+
if recipe_h["#{recipe_h.keys.join}"] == "default"
|
|
64
66
|
recipe_attr_file.insert 0,
|
|
65
|
-
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes
|
|
67
|
+
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/#{recipe_h["#{recipe_h.keys.join}"]}.json")
|
|
66
68
|
else
|
|
67
69
|
recipe_attr_file <<
|
|
68
70
|
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/#{recipe_h["#{recipe_h.keys.join}"]}.json")
|
|
@@ -71,31 +73,31 @@ module Itamae
|
|
|
71
73
|
|
|
72
74
|
recipe_attr_file.flatten!
|
|
73
75
|
|
|
74
|
-
#
|
|
76
|
+
# recipes attr other=env
|
|
75
77
|
recipe_env_h_a = []
|
|
76
78
|
recipe_attr_file.each do |file|
|
|
77
79
|
recipe_h = JSON.parse(File.read(file), symbolize_names: true)
|
|
78
80
|
recipe_env_h_a << recipe_h.deep_merge(env_h)
|
|
79
81
|
end
|
|
80
82
|
|
|
81
|
-
# recipe attr other=
|
|
83
|
+
# recipe attr other=recipes_env
|
|
82
84
|
moto = recipe_env_h_a[0]
|
|
83
85
|
recipe_env_h_a.each {|hash| moto.deep_merge!(hash)}
|
|
84
86
|
recipe_env_h = moto
|
|
85
87
|
|
|
86
88
|
if recipe_env_h.nil?
|
|
87
|
-
#
|
|
89
|
+
# env attr other=node
|
|
88
90
|
node_env_h = env_h.deep_merge(node_h)
|
|
89
91
|
node_env_j = TaskBase.jq node_env_h
|
|
90
92
|
TaskBase.write_json(bname) {|file| file.puts node_env_j}
|
|
91
93
|
else
|
|
92
|
-
#
|
|
94
|
+
# recipe_env attr other=node
|
|
93
95
|
recipe_env_node_h = recipe_env_h.deep_merge(node_h)
|
|
94
96
|
recipe_env_node_j = TaskBase.jq recipe_env_node_h
|
|
95
97
|
TaskBase.write_json(bname) {|file| file.puts recipe_env_node_j}
|
|
96
98
|
end
|
|
97
99
|
|
|
98
|
-
recipes << {'_base' =>
|
|
100
|
+
recipes << {'_base' => 'default'}
|
|
99
101
|
node_property = JSON.parse(File.read("tmp-nodes/#{bname}.json"), symbolize_names: true)
|
|
100
102
|
node = node_property[:environments][:hostname]
|
|
101
103
|
ssh_user = node_property[:environments][:ssh_user]
|
|
@@ -119,24 +121,32 @@ module Itamae
|
|
|
119
121
|
command << " --ask-password" unless ssh_password.nil?
|
|
120
122
|
command << " --dry-run" if ENV['dry-run'] == "true"
|
|
121
123
|
command << " -l debug" if ENV['debug'] == "true"
|
|
124
|
+
command << " -c logs/config/itamae_with_git_task.config"
|
|
122
125
|
|
|
123
|
-
|
|
126
|
+
# recipe load to_command
|
|
124
127
|
command_recipe = []
|
|
125
128
|
recipes.each do |recipe_h|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
command_recipe <<
|
|
131
|
-
" #{Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/recipes/#{recipe_h["#{recipe_h.keys.join}"]}.rb").join}"
|
|
129
|
+
target_recipe = "site-cookbooks/**/#{recipe_h.keys.join}/recipes/#{recipe_h["#{recipe_h.keys.join}"]}.rb"
|
|
130
|
+
unless File.exists?("#{Dir.glob(target_recipe).join}")
|
|
131
|
+
ex_recipe = recipe_h.to_s.gsub('=>', '::').gsub('"', '')
|
|
132
|
+
raise "Recipe load error, nodefile:#{node_file}, reason:Not exist the recipe #{ex_recipe}"
|
|
132
133
|
end
|
|
134
|
+
command_recipe << " #{Dir.glob(target_recipe).join("\s")}"
|
|
133
135
|
end
|
|
136
|
+
|
|
134
137
|
command_recipe.sort_by! {|item| File.dirname(item)}
|
|
135
138
|
command << command_recipe.join
|
|
136
139
|
|
|
137
140
|
puts TaskBase.hl.color(%!Run Itamae to \"#{bname}\"!, :red)
|
|
138
141
|
run_list_noti = []
|
|
139
|
-
command_recipe.each {|c_recipe|
|
|
142
|
+
command_recipe.each { |c_recipe|
|
|
143
|
+
unless c_recipe.split("/")[4].split(".")[0] == 'default'
|
|
144
|
+
run_list_noti << c_recipe.split("/")[2] + "::#{c_recipe.split("/")[4].split(".")[0]}"
|
|
145
|
+
else
|
|
146
|
+
run_list_noti << c_recipe.split("/")[2]
|
|
147
|
+
end
|
|
148
|
+
}
|
|
149
|
+
|
|
140
150
|
puts TaskBase.hl.color(%!Run List to \"#{run_list_noti.uniq.join(", ")}\"!, :green)
|
|
141
151
|
puts TaskBase.hl.color(%!#{command}!, :white)
|
|
142
152
|
st = system command
|
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.33
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: itamae-mitsurin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.33'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Akihiro Kamiyama
|
|
@@ -331,7 +331,7 @@ files:
|
|
|
331
331
|
- lib/itamae-mitsurin/mitsurin/creators/templates/site-cookbooks/spec/default_spec.rb
|
|
332
332
|
- lib/itamae-mitsurin/mitsurin/itamae_task.rb
|
|
333
333
|
- lib/itamae-mitsurin/mitsurin/itamae_with_git_task.rb
|
|
334
|
-
- lib/itamae-mitsurin/mitsurin/
|
|
334
|
+
- lib/itamae-mitsurin/mitsurin/itamae_with_target_task.rb
|
|
335
335
|
- lib/itamae-mitsurin/mitsurin/local_task.rb
|
|
336
336
|
- lib/itamae-mitsurin/mitsurin/serverspec_task.rb
|
|
337
337
|
- lib/itamae-mitsurin/mitsurin/task_base.rb
|