-
-
Notifications
You must be signed in to change notification settings - Fork 89
feat: 個別サーバー作成用のRakeタスクとサーバー状況確認タスクのメッセージ改善 #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
新機能: - rake server:create[サーバー名] で個別にサーバーを作成可能 - rake server:recreate[サーバー名] で再作成をガイド - 既存のdeploy.rbのロジックを最大限再利用(DRY原則) 使用例: rake "server:create[coderdojo-japan]" 目的: - CI/CDを通さずに即座にサーバーをテスト - SSH修正などの機能テストが容易に - 開発効率の向上
- セパレーター行の幅を定数化 - 保守性と可読性の向上 - 既存の50も含めて統一
- server:createタスクで十分なため、recreateタスクは不要 - 削除は手動で server:execute_deletion を使用 - 作成は server:create を使用 - よりシンプルで明確なワークフローに
- さくらのクラウドAPIを使用してリアルタイムステータスを取得 - 各サーバー名の横に状態を表示(✅ up / ⏸️ down / 🧹 cleaning) - API認証情報がない場合や接続エラー時には説明メッセージを表示 - API認証情報がなくても一覧表示は継続
- initialize メソッドに本番環境のデフォルト値を設定 - zone: '31002' (石狩第二) - packet_filter_id: '112900922505' - Rakefileのserver:listタスクからハードコーディングを削除 - DRY原則に従い、デフォルト値の重複を解消
- すべてのutilsスクリプトからハードコーディングされた値を削除 - SakuraServerUserAgentのデフォルト値を活用 - 7ファイルで重複していたパラメータ設定を削除 - scripts/initialize_server.rb - scripts/utils/check_server_status.rb - scripts/utils/check_startup_scripts.rb - scripts/utils/find_resources.rb - scripts/utils/start_server.rb - scripts/utils/test_with_packet_filter.rb - scripts/utils/test_with_startup_script.rb - DRY原則の徹底により保守性が向上
- 二層のファイアウォール構成の説明 - Layer 1: さくらのクラウド パケットフィルター - Layer 2: iptables(サーバー内部) - なぜ両方が必要なのかを詳細に説明 - 時系列での保護 - 障害時の冗長性 - 管理の観点 - 攻撃シナリオへの対策 - パケットフィルター確認ツールも追加 - トラブルシューティングガイド - ベストプラクティス
問題: - cloud-init対応を削除した際、スタートアップスクリプトも実行されなくなっていた - disk/config APIのNotesフィールドは単なるメモで、スクリプト実行のトリガーではなかった - 結果として、iptablesやSSHセキュリティ強化が適用されていなかった 解決: - サーバー起動時(/power API)にNotesパラメータでスタートアップスクリプトIDを指定 - notesパラメータをinitializeメソッドに追加(デフォルト値付き) - これにより、startup-scripts/112900928939 が正しく実行される 改善: - notesもデフォルトパラメータ化(packet_filter_idと同様) - セキュリティ設定(ファイアウォール+スタートアップスクリプト)がデフォルトで有効 - 必要に応じて個別に無効化可能(テスト環境等) 関連: #253 SSH接続問題の根本原因の一つ
🐛 重要なバグ修正を追加cloud-init対応を削除した際に発生したスタートアップスクリプトが実行されない問題を修正しました。 問題の詳細
修正内容
デフォルト値の設計
これにより、セキュリティ設定がデフォルトで確実に適用されるようになりました。 関連: #253 SSH接続問題の根本原因の一つ |
変更内容: - scripts/utils/test_*.rb を test/integration/ に移動 - 統合テスト(実際のAPI呼び出し)を明確に分離 - require_relative パスを修正 - test/README.md を追加してテスト構造を文書化 ディレクトリ構造: - test/ # ユニットテスト - csv_test.rb - ip_validation_test.rb - test/integration/ # 統合テスト(実際のAPI使用) - test_regex_patterns.rb - test_server_with_notes.rb - test_with_packet_filter.rb - test_with_startup_script.rb これにより、テストの種類が明確になり、保守性が向上
📁 テストファイルの整理
変更内容
新しいディレクトリ構造
これによりテストの種類が明確になり、保守性が向上しました。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
概要
個別サーバー作成用のRakeタスクを追加し、CI/CDを待たずに特定のサーバーをテスト作成できるようにしました。
また、セキュリティ設計とコード品質の大幅な改善を実施しました。
主な変更点
1. ✅ 個別サーバー作成タスク (
server:create
)deploy.rb
のロジックを再利用(DRY原則)2. ✅ サーバーリストの改善 (
server:list
)3. 🔒 セキュリティ設計の文書化
check_packet_filter.rb
)を追加4. 🎯 大規模リファクタリング(DRY原則)
SakuraServerUserAgent
クラスにデフォルトパラメータを実装5. ✨ コード品質の向上
SEPARATOR_WIDTH
定数に置き換え使用方法
個別サーバーの作成
サーバーリストの確認(ステータス付き)
パケットフィルター設定の確認
# セキュリティ設定を確認 ruby scripts/utils/check_packet_filter.rb
変更ファイル
追加
docs/security-defense-in-depth.md
- セキュリティ設計文書scripts/utils/check_packet_filter.rb
- パケットフィルター確認ツール修正(リファクタリング)
Rakefile
- server:create, server:list タスクの追加・改善scripts/sakura_server_user_agent.rb
- デフォルトパラメータの実装scripts/initialize_server.rb
- ハードコーディング削除scripts/utils/*.rb
- 全7ファイルでデフォルト値を活用テスト結果
影響範囲
関連Issue