kytoon 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,10 @@
1
- * Mon Dec 13 2012 Dan Prince <dprince@redhat.com> - 1.3.0
1
+ * Thu Dec 13 2012 Dan Prince <dprince@redhat.com> - 1.3.1
2
+ -SSH config fixes for libvirt and openstack providers. You can now
3
+ ssh to localhost from the gateway node. (weird but constistent)
4
+ -Add retry_attempts to remote_exec method
5
+ -Update OpenStack provider to retry initial ssh config up to 3 times.
6
+
7
+ * Thu Dec 13 2012 Dan Prince <dprince@redhat.com> - 1.3.0
2
8
  -OpenStack: Switch to Fog.
3
9
  -OpenStack: Add support for automatic floating IP configuration via
4
10
  'assign_floating_ip' in server group json files.
data/README.md CHANGED
@@ -94,6 +94,8 @@ For Openstack:
94
94
 
95
95
  For Libvirt (uses libvirt DHCP server for instance IP configuration):
96
96
 
97
+ NOTE: Kytoon assumes you are using NAT networking for your libvirt instances. If you use bridged networking the IP discovery mechanism will fail.
98
+
97
99
  ```bash
98
100
 
99
101
  cat > config/server_group.json <<-"EOF_CAT"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -174,7 +174,7 @@ class ServerGroup
174
174
  puts "Copying hosts files..."
175
175
 
176
176
  gateway_ssh_config = %{
177
- [ -d .ssh ] || mkdir .ssh
177
+ mkdir -p .ssh
178
178
  cat > .ssh/id_rsa <<-EOF_CAT
179
179
  #{private_ssh_key}
180
180
  EOF_CAT
@@ -182,7 +182,7 @@ chmod 600 .ssh/id_rsa
182
182
  cat > .ssh/id_rsa.pub <<-EOF_CAT
183
183
  #{public_ssh_key}
184
184
  EOF_CAT
185
- chmod 600 .ssh/id_rsa.pub
185
+ chmod 644 .ssh/id_rsa.pub
186
186
  cat > .ssh/config <<-EOF_CAT
187
187
  StrictHostKeyChecking no
188
188
  EOF_CAT
@@ -190,9 +190,9 @@ chmod 600 .ssh/config
190
190
  }
191
191
 
192
192
  node_ssh_config= %{
193
- [ -d .ssh ] || mkdir .ssh
194
- cat > .ssh/authorized_keys <<-EOF_CAT
195
- #{public_ssh_key}
193
+ mkdir -p .ssh
194
+ cat >> .ssh/authorized_keys <<-EOF_CAT
195
+ #{public_ssh_key}\n
196
196
  EOF_CAT
197
197
  chmod 600 .ssh/authorized_keys
198
198
  }
@@ -208,7 +208,8 @@ hostname "#{server['hostname']}"
208
208
  if [ -f /etc/sysconfig/network ]; then
209
209
  sed -e "s|^HOSTNAME.*|HOSTNAME=#{server['hostname']}|" -i /etc/sysconfig/network
210
210
  fi
211
- #{server['gateway'] == 'true' ? gateway_ssh_config : node_ssh_config}
211
+ #{server['gateway'] == 'true' ? gateway_ssh_config : ""}
212
+ #{node_ssh_config}
212
213
  }, server['ip_address']) do |ok, out|
213
214
  if not ok
214
215
  puts out
@@ -343,9 +344,8 @@ if [ -n "$LV_ROOT" ]; then
343
344
  run : \
344
345
  mount $LV_ROOT / : \
345
346
  sh "/bin/mkdir -p /root/.ssh" : \
346
- write-append /root/.ssh/authorized_keys "#{ssh_public_key}" : \
347
- sh "/bin/chmod 700 /root/.ssh" : \
348
- sh "/bin/chmod 600 /root/.ssh/authorized_keys"
347
+ write-append /root/.ssh/authorized_keys "#{ssh_public_key}\n" : \
348
+ sh "/bin/chmod -R 700 /root/.ssh"
349
349
  fi
350
350
 
351
351
  #{sudo} virsh setmaxmem #{domain_name} #{instance_memory}
@@ -188,7 +188,7 @@ class ServerGroup
188
188
  puts "Copying hosts files..."
189
189
 
190
190
  gateway_ssh_config = %{
191
- [ -d .ssh ] || mkdir .ssh
191
+ mkdir -p .ssh
192
192
  cat > .ssh/id_rsa <<-EOF_CAT
193
193
  #{private_ssh_key}
194
194
  EOF_CAT
@@ -196,7 +196,7 @@ chmod 600 .ssh/id_rsa
196
196
  cat > .ssh/id_rsa.pub <<-EOF_CAT
197
197
  #{public_ssh_key}
198
198
  EOF_CAT
199
- chmod 600 .ssh/id_rsa.pub
199
+ chmod 644 .ssh/id_rsa.pub
200
200
  cat > .ssh/config <<-EOF_CAT
201
201
  StrictHostKeyChecking no
202
202
  EOF_CAT
@@ -204,9 +204,9 @@ chmod 600 .ssh/config
204
204
  }
205
205
 
206
206
  node_ssh_config= %{
207
- [ -d .ssh ] || mkdir .ssh
208
- cat > .ssh/authorized_keys <<-EOF_CAT
209
- #{public_ssh_key}
207
+ mkdir -p .ssh
208
+ cat >> .ssh/authorized_keys <<-EOF_CAT
209
+ #{public_ssh_key}\n
210
210
  EOF_CAT
211
211
  chmod 600 .ssh/authorized_keys
212
212
  }
@@ -222,8 +222,9 @@ hostname "#{server['hostname']}"
222
222
  if [ -f /etc/sysconfig/network ]; then
223
223
  sed -e "s|^HOSTNAME.*|HOSTNAME=#{server['hostname']}|" -i /etc/sysconfig/network
224
224
  fi
225
- #{server['gateway'] == 'true' ? gateway_ssh_config : node_ssh_config}
226
- }, server['ip_address']) do |ok, out|
225
+ #{server['gateway'] == 'true' ? gateway_ssh_config : ""}
226
+ #{node_ssh_config}
227
+ }, server['ip_address'], 3) do |ok, out|
227
228
  if not ok
228
229
  puts out
229
230
  raise KytoonException, "Failed to copy host file to instance #{server['hostname']}."
@@ -66,23 +66,30 @@ module Util
66
66
  end
67
67
  end
68
68
 
69
- def self.remote_exec(script_text, gateway_ip)
69
+ def self.remote_exec(script_text, gateway_ip, retry_attempts=0, retry_sleep=5)
70
70
  if gateway_ip.nil?
71
71
  sg=ServerGroup.get
72
72
  gateway_ip=sg.gateway_ip
73
73
  end
74
74
 
75
- out=%x{
75
+ retval=nil
76
+ out=nil
77
+ (retry_attempts+1).times do |count|
78
+ sleep retry_sleep if count > 1
79
+ out=%x{
76
80
  ssh #{SSH_OPTS} root@#{gateway_ip} bash <<-"REMOTE_EXEC_EOF"
77
81
  #{script_text}
78
82
  REMOTE_EXEC_EOF
79
- }
80
- retval=$?
83
+ }
84
+ retval=$?
85
+ break if retval.success?
86
+ end
81
87
  if block_given? then
82
88
  yield retval.success?, out
83
89
  else
84
90
  return [retval.success?, out]
85
91
  end
92
+
86
93
  end
87
94
 
88
95
  def self.remote_multi_exec(hosts, script_text, gateway_ip)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kytoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-13 00:00:00.000000000 Z
12
+ date: 2012-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -289,7 +289,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
289
289
  version: '0'
290
290
  segments:
291
291
  - 0
292
- hash: 3174001929267576694
292
+ hash: -598378511131357418
293
293
  required_rubygems_version: !ruby/object:Gem::Requirement
294
294
  none: false
295
295
  requirements: