Skip to content

Commit 8592ec5

Browse files
authored
Merge pull request #259 from coderdojo-japan/fix-ssh-connection-issue
Fix: SSH接続問題を修正 - cloud-init設定を削除して通常版Ubuntu対応
2 parents b2413dc + 4f3598f commit 8592ec5

File tree

1 file changed

+6
-33
lines changed

1 file changed

+6
-33
lines changed

scripts/sakura_server_user_agent.rb

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ def create_server_instance()
169169
},
170170
Name: @name,
171171
Description: @description,
172-
Tags: @tags,
173-
# Icon: { ID: 112900928939 } # スタートアップスクリプトIDは一時的に無効化(cloud-initで実行)
172+
Tags: @tags
174173
}
175174
}
176175
puts "DEBUG: Server creation request: #{query.inspect}" if @verbose
@@ -336,38 +335,12 @@ def _put_ssh_key(disk_id)
336335
end
337336

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

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
342+
puts "DEBUG: Starting server (SSH key and startup script already configured via disk/config API)" if @verbose
343+
send_request('put',"server/#{@server_id}/power", nil)
371344

372345
rescue => exception
373346
puts exception

0 commit comments

Comments
 (0)