itamae-mitsurin 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 501496a4a667232eeeb4020024fb96d25dac514a
4
- data.tar.gz: bfb410645c364d84f975ecc1e4aae10934920355
3
+ metadata.gz: eb10fdaf74906a17da6f88364c2fd758f20d35ab
4
+ data.tar.gz: e0a64acfc4099cc9a7bc4f35ab612abefe7d4cb4
5
5
  SHA512:
6
- metadata.gz: af73678cf92dbc16f8353fe3635921ded6fa3ce1b622535983032a77e71b343285208a34636aa02080c59f8e3b30a812739835c72bbe505366d7db23889a3a78
7
- data.tar.gz: 07f48d7d5393560061191d51dd7d079372c46a7a35344cf14671d81e904b57d76d01a0faec01a934affba32aaab9c9c70fd786f00486b1805984ada978837675
6
+ metadata.gz: 1aa4b406d867b1fc844bcdba2f096eb2decb1065f7c257f9da8522652ac39e37ef4c1fae1966a0536308ee3721a1b8cbc72614b2f1d0565e0ff952d0058790f4
7
+ data.tar.gz: 4454340317f8a0e1a905c7b3e3778a17909b06f1a60df20cc1dff3eadd4036d6f3f5d3464168098c5ae67636c9a7d365a6b3f2ea4cc07fcd7526dda4fd78acf9
@@ -251,8 +251,12 @@ module Itamae
251
251
 
252
252
  if @options[:ask_password]
253
253
  print "password: "
254
- password = STDIN.noecho(&:gets).strip
255
- print "#{ENV['SSH_PASSWORD']}\n"
254
+ unless ENV['SSH_PASSWORD'].nil?
255
+ password = ENV['SSH_PASSWORD']
256
+ else
257
+ password = STDIN.noecho(&:gets).strip
258
+ end
259
+ print "\n"
256
260
  opts.merge!(password: password)
257
261
  end
258
262
 
@@ -1,3 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'itamae-mitsurin'
4
+ gem 'highline'
@@ -0,0 +1 @@
1
+ puts " LOAD : Environment set is " << node[:environments][:set]
@@ -23,9 +23,10 @@ attributes = JSON.parse(File.read(node_file), symbolize_names: true)
23
23
  set_property attributes
24
24
 
25
25
  options = Net::SSH::Config.for(host)
26
- options[:user] ||= Etc.getlogin
26
+ options[:user] = ENV['SSH_USER']
27
27
  options[:password] = ENV['SSH_PASSWORD']
28
28
  options[:keys] = ENV['SSH_KEY']
29
+ options[:port] = ENV['SSH_PORT']
29
30
 
30
31
  set :host, options[:host_name] || host
31
32
  set :shell, '/bin/bash'
@@ -102,7 +102,7 @@ module Itamae
102
102
  exit 1
103
103
  end
104
104
 
105
- # get recipe attr
105
+ # get recipes attr
106
106
  recipe_attr_file = []
107
107
  recipes.each do |recipe_h|
108
108
  if recipe_h["#{recipe_h.keys.join}"].nil?
@@ -116,25 +116,25 @@ module Itamae
116
116
 
117
117
  recipe_attr_file.flatten!
118
118
 
119
- # recipe attr other=env
119
+ # recipes attr other=env
120
120
  recipe_env_h_a = []
121
121
  recipe_attr_file.each do |file|
122
122
  recipe_h = JSON.parse(File.read(file), symbolize_names: true)
123
123
  recipe_env_h_a << recipe_h.deep_merge(env_h)
124
124
  end
125
125
 
126
- # recipe attr other=recipes
126
+ # recipe attr other=recipes_env
127
127
  moto = recipe_env_h_a[0]
128
128
  recipe_env_h_a.each {|hash| moto.deep_merge!(hash)}
129
129
  recipe_env_h = moto
130
130
 
131
131
  if recipe_env_h.nil?
132
- # node attr other=env
132
+ # env attr other=node
133
133
  node_env_h = env_h.deep_merge(node_h)
134
134
  node_env_j = jq node_env_h
135
135
  write_json(bname) {|file| file.puts node_env_j}
136
136
  else
137
- # node attr other=recipe_env
137
+ # recipe_env attr other=node
138
138
  recipe_env_node_h = recipe_env_h.deep_merge(node_h)
139
139
  recipe_env_node_j = jq recipe_env_node_h
140
140
  write_json(bname) {|file| file.puts recipe_env_node_j}
@@ -145,12 +145,14 @@ module Itamae
145
145
  node = node_property[:environments][:hostname]
146
146
  ssh_user = node_property[:environments][:ssh_user]
147
147
  ssh_password = node_property[:environments][:ssh_password]
148
+ sudo_password = node_property[:environments][:sudo_password]
148
149
  ssh_port = node_property[:environments][:ssh_port]
149
150
  ssh_key = node_property[:environments][:ssh_key]
150
151
 
151
152
  ENV['TARGET_HOST'] = node
152
153
  ENV['NODE_FILE'] = node_file
153
154
  ENV['SSH_PASSWORD'] = ssh_password
155
+ ENV['SUDO_PASSWORD'] = sudo_password
154
156
 
155
157
  command = "bundle exec itamae ssh"
156
158
  command << " -h #{node}"
@@ -178,7 +180,7 @@ module Itamae
178
180
  command << command_recipe.join
179
181
 
180
182
  color.echos(:red ,%!Run Itamae to \"#{bname}\"!)
181
- color.echos(:blue, %!Set Roles to \"#{get_roles(node_file).join(", ")}\"!)
183
+ color.echos(:blue, %!Role List to \"#{get_roles(node_file).join(", ")}\"!)
182
184
  run_list_noti = []
183
185
  command_recipe.each {|c_recipe| run_list_noti << c_recipe.split("/") [2]}
184
186
  color.echos(:green, %!Run List to \"#{run_list_noti.uniq.join(", ")}\"!)
@@ -76,7 +76,7 @@ module Itamae
76
76
  namespace :itamae do
77
77
  branches = Specinfra.backend.run_command('git branch')
78
78
  branch = branches.stdout.split("\n").select{|a| /\*/ === a }
79
- branch = branch.pop.gsub(/\* (.+)/, '\1')
79
+ branch = branch.join.gsub(/\* (.+)/, '\1')
80
80
  if branch == 'staging'
81
81
  branch = 'staging/**'
82
82
  elsif branch == 'master'
@@ -84,7 +84,6 @@ module Itamae
84
84
  else
85
85
  branch = 'other/**'
86
86
  end
87
- end
88
87
 
89
88
  Dir.glob("nodes/#{branch}/*.json").each do |node_file|
90
89
 
@@ -162,12 +161,14 @@ module Itamae
162
161
  node = node_property[:environments][:hostname]
163
162
  ssh_user = node_property[:environments][:ssh_user]
164
163
  ssh_password = node_property[:environments][:ssh_password]
164
+ sudo_password = node_property[:environments][:sudo_password]
165
165
  ssh_port = node_property[:environments][:ssh_port]
166
166
  ssh_key = node_property[:environments][:ssh_key]
167
167
 
168
168
  ENV['TARGET_HOST'] = node
169
169
  ENV['NODE_FILE'] = node_file
170
170
  ENV['SSH_PASSWORD'] = ssh_password
171
+ ENV['SUDO_PASSWORD'] = sudo_password
171
172
 
172
173
  command = "bundle exec itamae ssh"
173
174
  command << " -h #{node}"
@@ -195,7 +196,7 @@ module Itamae
195
196
  command << command_recipe.join
196
197
 
197
198
  color.echos(:red ,%!Run Itamae to \"#{bname}\"!)
198
- color.echos(:blue, %!Set Roles to \"#{get_roles(node_file).join(", ")}\"!)
199
+ color.echos(:blue, %!Role List to \"#{get_roles(node_file).join(", ")}\"!)
199
200
  run_list_noti = []
200
201
  command_recipe.each {|c_recipe| run_list_noti << c_recipe.split("/") [2]}
201
202
  color.echos(:green, %!Run List to \"#{run_list_noti.uniq.join(", ")}\"!)
@@ -44,6 +44,8 @@ module Itamae
44
44
  recipes
45
45
  end
46
46
 
47
+ color = SimpleColor.new
48
+
47
49
  namespace :spec do
48
50
  all = []
49
51
  Dir.glob("tmp-nodes/**/*.json").each do |node_file|
@@ -74,6 +76,7 @@ module Itamae
74
76
  node_name = node_attr[:environments][:hostname]
75
77
  ssh_user = node_attr[:environments][:ssh_user]
76
78
  ssh_password = node_attr[:environments][:ssh_password]
79
+ sudo_password = node_attr[:environments][:sudo_password]
77
80
  ssh_port = node_attr[:environments][:ssh_port]
78
81
  ssh_key = node_attr[:environments][:ssh_key]
79
82
 
@@ -84,7 +87,9 @@ module Itamae
84
87
  ENV['TARGET_HOST'] = node_name
85
88
  ENV['NODE_FILE'] = node_file
86
89
  ENV['SSH_PASSWORD'] = ssh_password
90
+ ENV['SUDO_PASSWORD'] = sudo_password
87
91
  ENV['SSH_KEY'] = "keys/#{ssh_key}"
92
+ ENV['SSH_PORT'] = ssh_port
88
93
 
89
94
  specs = "bundle exec rspec"
90
95
 
@@ -105,7 +110,6 @@ module Itamae
105
110
  spec_pattern.each {|c_spec| run_list_noti << c_spec.split("/") [2]}
106
111
  color.echos(:red ,%!Run Serverspec to \"#{node_name}\"!)
107
112
  color.echos(:green, %!Run List to \"#{run_list_noti.uniq.join(", ")}\"!)
108
- puts color.echos(:white, %!#{specs}!)
109
113
  st = system specs
110
114
  exit 1 unless st
111
115
  end
@@ -1 +1 @@
1
- 0.3
1
+ 0.4
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.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akihiro Kamiyama