Skip to content

Commit b64d768

Browse files
committed
Fix: cloud-init設定を削除して通常版Ubuntu用のSSH設定に修正
問題: - 通常版UbuntuでSSHポート22が接続できない - cloud-init非対応の通常版Ubuntuでcloud-initを使用していた - disk/config APIでSSH鍵設定済みなのに、cloud-initで二重設定 解決: - _copying_imageメソッドをシンプルに修正 - disk/config APIによるSSH鍵設定のみ使用 - サーバー起動時にcloud-init設定を送信しない これにより通常版UbuntuでSSH接続が正常に動作するようになる
1 parent b2413dc commit b64d768

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

scripts/sakura_server_user_agent.rb

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -336,38 +336,12 @@ def _put_ssh_key(disk_id)
336336
end
337337

338338
def _copying_image
339-
# SSH鍵はdisk/configで設定済み
340-
# スタートアップスクリプトはcloud-initで実行
341-
startup_script_path = './startup-scripts/112900928939'
339+
# 通常版UbuntuではSSH鍵とスタートアップスクリプトIDは
340+
# disk/config APIで既に設定済み(_put_ssh_keyメソッド内)
341+
# ここではサーバーを起動するだけでよい
342342

343-
if File.exist?(startup_script_path)
344-
startup_script_content = File.read(startup_script_path)
345-
346-
# cloud-config(SSH鍵とスクリプト実行)
347-
cloud_config = <<-EOF
348-
#cloud-config
349-
ssh_authorized_keys:
350-
- #{@pubkey}
351-
runcmd:
352-
- |
353-
#{startup_script_content.split("\n").map { |line| line.strip.empty? ? "" : " #{line}" }.join("\n")}
354-
EOF
355-
356-
puts "DEBUG: Starting server with cloud-init for startup script" if @verbose
357-
puts "DEBUG: cloud-config (first 200 chars): #{cloud_config[0..200]}..." if @verbose
358-
359-
body = {
360-
UserBootVariables: {
361-
CloudInit: {
362-
UserData: cloud_config
363-
}
364-
}
365-
}
366-
send_request('put',"server/#{@server_id}/power", body)
367-
else
368-
puts "Warning: Startup script not found at #{startup_script_path}"
369-
send_request('put',"server/#{@server_id}/power", nil)
370-
end
343+
puts "DEBUG: Starting server (SSH key and startup script already configured via disk/config API)" if @verbose
344+
send_request('put',"server/#{@server_id}/power", nil)
371345

372346
rescue => exception
373347
puts exception

0 commit comments

Comments
 (0)