kdeploy 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce9866219dbabbb49ab4ca2d3e8413e329700d245784f4017dd539dfbe17607c
4
- data.tar.gz: 26dee30c428f7e5e41eedb84450589e647b49d42817017e7d69e698aacae1226
3
+ metadata.gz: f3be52250612f3eb627a5044db454c87f7258396f9a0c066be85df9ff8f33b9d
4
+ data.tar.gz: c802622e109e4e5d0620456a732e2b8b870b77ec0e422fe461ff1edf6993cd7e
5
5
  SHA512:
6
- metadata.gz: 75a4b65a35a267710f8f6bbc8f93f8687aef976bd7d2f5212658b966c2bf427fb858f0b8fc40b3752a6575872ff4da587db65096a30a7b8edba955c68015da99
7
- data.tar.gz: 14352a49dbaad173560e910d5c7dd68932b63b6c1c0cff4fcf05f4c6b429939e2ffb9ba40d0828ca4159493c9f0344da07c7dd25cce655ed3c90a4f2e617a1d4
6
+ metadata.gz: cc0fba2a35c4bff14238ef9c4f088d1f2fc52f1625e3c7e38394d5100d57db3556fc634af21afcb4b991b1f24e6339c1649c8cc52a58a20a29eb0b8e24d8e956
7
+ data.tar.gz: 52cb3084e8bf51f50e92556b13e241451dd6c6bfa6df7ed9041a042ea96eb4f1fe5c8d310af9e706a3e2396eea963f0bc552e6c72efb5aa29eead6da014f553b
data/README.md CHANGED
@@ -1,43 +1,17 @@
1
1
  # Kdeploy
2
2
 
3
- ```
4
- _ _
5
- /\ /\__| | ___ _ __ | | ___ _ _
6
- / //_/ _` |/ _ \ '_ \| |/ _ \| | | |
7
- / __ \ (_| | __/ |_) | | (_) | |_| |
8
- \/ \/\__,_|\___| .__/|_|\___/ \__, |
9
- |_| |___/
10
-
11
- ⚡ Lightweight Agentless Deployment Tool
12
- 🚀 Deploy with confidence, scale with ease
13
- ```
3
+ A lightweight agentless deployment automation tool written in Ruby.
14
4
 
15
- [![Gem Version](https://badge.fury.io/rb/kdeploy.svg)](https://rubygems.org/gems/kdeploy)
16
- [![CI](https://github.com/kevin197011/kdeploy/actions/workflows/ci.yml/badge.svg)](https://github.com/kevin197011/kdeploy/actions/workflows/ci.yml)
17
-
18
- Kdeploy is a modern, lightweight agentless deployment tool similar to Chef, Puppet, and Ansible. It uses an elegant Ruby DSL syntax and supports concurrent execution, statistical analysis, and complete deployment lifecycle management.
19
-
20
- [中文文档](README_CN.md)
21
-
22
- ## Features
23
-
24
- - 🚀 **Lightweight**: No agent installation required on target servers, SSH-based connections
25
- - 🎨 **Modern Interface**: Beautiful ASCII art and colored output interface
26
- - 🔧 **DSL Syntax**: Concise and elegant Ruby DSL configuration syntax
27
- - ⚡ **Concurrent Execution**: Support for multi-host parallel operations and intelligent concurrency control
28
- - 🛠️ **Batch Operations**: Efficient batch Shell command execution
29
- - 🔒 **Secure Connection**: SSH-based secure connections with key authentication
30
- - 📝 **Real-time Output**: Command execution results with real-time display and detailed timing statistics
31
- - 🎯 **Role Management**: Flexible role-based host grouping management
32
- - 📋 **Inventory Management**: Powerful YAML format host inventory with group and variable inheritance
33
- - 🧩 **Heredoc Syntax**: Support for multi-line Shell scripts using heredoc syntax
34
- - 🎨 **ERB Templates**: Built-in ERB template engine for dynamic configuration file generation
35
- - 🏷️ **Variable Substitution**: Support for both `{{variable}}` and `${variable}` template syntax
36
- - 🖥️ **Mixed Execution**: Support for local command execution and hybrid deployment scenarios
37
- - 📊 **Statistics Analysis**: Automatic deployment statistics collection with performance analysis and trend monitoring
38
- - 🔄 **Script Library**: Rich pre-made script templates covering the complete deployment lifecycle
39
- - 🧩 **Modular Architecture**: Support for modular script organization with reusable task components
40
- - 🛡️ **Error Recovery**: Intelligent error handling and automatic retry mechanism
5
+ ## 🌟 Features
6
+
7
+ - 🔑 **Agentless Remote Deployment**: Uses SSH for secure remote execution
8
+ - 📝 **Elegant Ruby DSL**: Simple and expressive task definition
9
+ - 🚀 **Concurrent Execution**: Efficient parallel task processing
10
+ - 📤 **File Upload Support**: Easy file and template deployment
11
+ - 📊 **Task Status Tracking**: Real-time execution monitoring
12
+ - 🔄 **ERB Template Support**: Dynamic configuration generation
13
+ - 🎯 **Role-based Deployment**: Target specific server roles
14
+ - 🔍 **Dry Run Mode**: Preview tasks before execution
41
15
 
42
16
  ## 📦 Installation
43
17
 
@@ -47,345 +21,175 @@ Add this line to your application's Gemfile:
47
21
  gem 'kdeploy'
48
22
  ```
49
23
 
50
- Then execute:
24
+ And then execute:
51
25
 
52
26
  ```bash
53
- bundle install
27
+ $ bundle install
54
28
  ```
55
29
 
56
- Or install it directly:
30
+ Or install it yourself as:
57
31
 
58
32
  ```bash
59
- gem install kdeploy
33
+ $ gem install kdeploy
60
34
  ```
61
35
 
62
36
  ## 🚀 Quick Start
63
37
 
64
- ### 1. Initialize Project
38
+ 1. Initialize a new project:
65
39
 
66
40
  ```bash
67
- kdeploy init myapp
68
- cd myapp
41
+ $ kdeploy init my-deployment
69
42
  ```
70
43
 
71
- Kdeploy will automatically create a complete project structure with several useful script examples:
44
+ 2. Edit the deployment configuration:
72
45
 
73
- ```
74
- myapp/
75
- ├── deploy.rb # Main deployment script
76
- ├── inventory.yml # Host inventory configuration
77
- ├── config/ # Configuration directory
78
- │ └── kdeploy.yml # Global configuration file
79
- ├── scripts/ # 🆕 Complete script library
80
- │ ├── common_tasks.rb # 🆕 Common task module (reusable)
81
- │ ├── setup.rb # Server initialization
82
- │ ├── database.rb # Database management
83
- │ ├── backup.rb # Backup operations
84
- │ ├── monitoring.rb # Monitoring and health checks
85
- │ ├── rollback.rb # Rollback operations
86
- │ └── cleanup.rb # Cleanup maintenance
87
- └── templates/ # ERB template files
88
- ├── nginx.conf.erb # Nginx configuration template
89
- ├── app.service.erb # Systemd service template
90
- ├── deploy.sh.erb # Deployment script template
91
- └── backup.sh.erb # Backup script template
92
- ```
93
-
94
- ### 2. Configure Server Inventory
95
-
96
- Edit `inventory.yml` to configure host inventory:
97
-
98
- ```yaml
99
- # Global variables
100
- vars:
101
- application: myapp
102
- version: 1.0.0
103
- deploy_to: /opt/myapp
104
- environment: production
105
-
106
- # Host groups
107
- groups:
108
- webservers:
109
- hosts:
110
- - web1.example.com
111
- - web2.example.com
112
- vars:
113
- nginx_port: 80
114
- app_port: 3000
115
-
116
- databases:
117
- hosts:
118
- - db1.example.com
119
- vars:
120
- postgres_port: 5432
121
- backup_enabled: true
122
-
123
- production:
124
- children:
125
- - webservers
126
- - databases
127
- vars:
128
- environment: production
129
-
130
- # Host configurations
131
- hosts:
132
- web1.example.com:
133
- user: deploy
134
- port: 22
135
- roles: [web, app]
136
- ssh:
137
- key_file: ~/.ssh/id_rsa
138
- verify_host_key: false
139
- vars:
140
- server_id: 1
141
-
142
- web2.example.com:
143
- user: deploy
144
- port: 22
145
- roles: [web, app]
146
- ssh:
147
- key_file: ~/.ssh/id_rsa
148
- verify_host_key: false
149
- vars:
150
- server_id: 2
151
-
152
- db1.example.com:
153
- user: deploy
154
- port: 22
155
- roles: [database]
156
- ssh:
157
- key_file: ~/.ssh/id_rsa
158
- verify_host_key: false
159
- vars:
160
- server_id: 3
161
- master: true
162
- ```
46
+ ```ruby
47
+ # deploy.rb
163
48
 
164
- ### 3. Use Pre-made Scripts
49
+ # Define hosts
50
+ host "web01", user: "ubuntu", ip: "10.0.0.1", key: "~/.ssh/id_rsa"
51
+ host "web02", user: "ubuntu", ip: "10.0.0.2", key: "~/.ssh/id_rsa"
165
52
 
166
- Kdeploy provides a complete script library covering various deployment stages:
53
+ # Define roles
54
+ role :web, %w[web01 web02]
167
55
 
168
- #### 🔧 Server Initialization
169
- ```bash
170
- # Execute before first deployment to install dependencies and configure environment
171
- kdeploy deploy scripts/setup.rb
56
+ # Define tasks
57
+ task :deploy, roles: :web do
58
+ run "sudo systemctl stop nginx"
59
+ upload_template "./config/nginx.conf.erb", "/etc/nginx/nginx.conf",
60
+ domain_name: "example.com",
61
+ port: 3000
62
+ run "sudo systemctl start nginx"
63
+ end
172
64
  ```
173
65
 
174
- #### 💾 Database Management
175
- ```bash
176
- # Database operations
177
- kdeploy deploy scripts/database.rb # Create database, migrate, backup
178
- ```
66
+ 3. Run the deployment:
179
67
 
180
- #### 🚀 Application Deployment
181
68
  ```bash
182
- # Main application deployment
183
- kdeploy deploy deploy.rb
69
+ $ kdeploy execute deploy.rb
184
70
  ```
185
71
 
186
- #### 📊 Health Monitoring
187
- ```bash
188
- # System and application health checks
189
- kdeploy deploy scripts/monitoring.rb
190
- ```
72
+ ## 📖 Usage Guide
191
73
 
192
- #### 💾 Backup Operations
193
- ```bash
194
- # Application and data backup
195
- kdeploy deploy scripts/backup.rb
196
- ```
197
-
198
- #### 🔙 Rollback Operations
199
- ```bash
200
- # Emergency rollback and recovery
201
- kdeploy deploy scripts/rollback.rb
202
- ```
203
-
204
- #### 🧹 Cleanup Maintenance
205
- ```bash
206
- # System cleanup and maintenance
207
- kdeploy deploy scripts/cleanup.rb
208
- ```
74
+ ### Host Definition
209
75
 
210
- #### 🧩 Common Task Module
211
- ```bash
212
- # Use common task module for basic setup
213
- kdeploy deploy scripts/common_tasks.rb --task setup_environment
76
+ ```ruby
77
+ # Single host
78
+ host "web01",
79
+ user: "ubuntu",
80
+ ip: "10.0.0.1",
81
+ key: "~/.ssh/id_rsa"
214
82
 
215
- # Execute security hardening
216
- kdeploy deploy scripts/common_tasks.rb --task security_hardening
83
+ # Multiple hosts
84
+ %w[web01 web02 web03].each do |name|
85
+ host name,
86
+ user: "ubuntu",
87
+ ip: "10.0.0.#{name[-1]}",
88
+ key: "~/.ssh/id_rsa"
89
+ end
217
90
  ```
218
91
 
219
- ### 4. Deployment Workflow Example
220
-
221
- ```bash
222
- # 1. Validate configuration
223
- kdeploy validate deploy.rb
224
-
225
- # 2. First-time server setup
226
- kdeploy deploy scripts/setup.rb
227
-
228
- # 3. Setup database
229
- kdeploy deploy scripts/database.rb
92
+ ### Role Management
230
93
 
231
- # 4. Execute application deployment
232
- kdeploy deploy deploy.rb --verbose
94
+ ```ruby
95
+ # Define roles
96
+ role :web, %w[web01 web02]
97
+ role :db, %w[db01 db02]
98
+ role :all, %w[web01 web02 db01 db02]
233
99
 
234
- # 5. Health check
235
- kdeploy deploy scripts/monitoring.rb
100
+ # Use roles in tasks
101
+ task :deploy_web, roles: :web do
102
+ # Tasks for web servers
103
+ end
236
104
 
237
- # 6. View statistics
238
- kdeploy stats summary
105
+ task :backup_db, roles: :db do
106
+ # Tasks for database servers
107
+ end
239
108
  ```
240
109
 
241
- ## 📊 Statistics and Monitoring
242
-
243
- Kdeploy provides powerful built-in statistics functionality that automatically tracks all deployment activities:
244
-
245
- ### 📈 Automatically Collected Statistics
246
-
247
- - ✅ **Success/Failure Statistics**: Success rates at deployment, task, and command levels
248
- - ⏱️ **Performance Metrics**: Detailed execution time and performance data
249
- - 📅 **Historical Trends**: Performance trend analysis grouped by date
250
- - 🎯 **Failure Analysis**: Identify most common failing tasks and error patterns
251
- - 🌍 **Global Statistics**: Cumulative statistics across sessions
252
-
253
- ### 🔍 Statistics Commands
254
-
255
- ```bash
256
- # View statistics summary
257
- kdeploy stats summary
110
+ ### Task Definition
258
111
 
259
- # View deployment statistics
260
- kdeploy stats deployments
261
-
262
- # View task statistics
263
- kdeploy stats tasks
264
-
265
- # View failure statistics
266
- kdeploy stats failures
112
+ ```ruby
113
+ # Basic task
114
+ task :simple do
115
+ run "echo 'Hello, World!'"
116
+ end
267
117
 
268
- # View performance trends
269
- kdeploy stats trends
118
+ # Role-based task
119
+ task :deploy, roles: :web do
120
+ run "sudo systemctl stop nginx"
121
+ upload "./config/nginx.conf", "/etc/nginx/nginx.conf"
122
+ run "sudo systemctl start nginx"
123
+ end
270
124
 
271
- # View global statistics
272
- kdeploy stats global
125
+ # Host-specific task
126
+ task :maintenance, on: %w[web01] do
127
+ run "sudo apt-get update"
128
+ run "sudo apt-get upgrade -y"
129
+ end
130
+ ```
273
131
 
274
- # Export statistics data
275
- kdeploy stats export --export monthly_report.json
132
+ ### Template Support
276
133
 
277
- # Clear statistics data
278
- kdeploy stats clear
134
+ Create an ERB template (`config/nginx.conf.erb`):
279
135
 
280
- # Specify time range (days)
281
- kdeploy stats summary --days 7
136
+ ```erb
137
+ server {
138
+ listen 80;
139
+ server_name <%= domain_name %>;
282
140
 
283
- # JSON format output
284
- kdeploy stats tasks --format json
141
+ location / {
142
+ proxy_pass http://localhost:<%= port %>;
143
+ proxy_set_header Host $host;
144
+ proxy_set_header X-Real-IP $remote_addr;
145
+ }
146
+ }
285
147
  ```
286
148
 
287
- ### 📊 Statistics Output Example
149
+ Use the template in your task:
288
150
 
289
- ```bash
290
- kdeploy stats summary
291
-
292
- 📊 Kdeploy Statistics Summary (Last 30 days)
293
- =====================================================
294
-
295
- 📦 Deployment Summary:
296
- Total Deployments: 15
297
- Successful: 13 (86.7%)
298
- Failed: 2 (13.3%)
299
- Average Duration: 45.2s
300
-
301
- 🔧 Task Summary:
302
- Total Tasks: 89
303
- Successful: 84 (94.4%)
304
- Failed: 5 (5.6%)
305
- Average Duration: 12.8s
306
-
307
- 🌍 Global Statistics:
308
- Total Deployments: 156
309
- Session Duration: 2h 34m
310
- Most Active Day: 2025-06-28 (8 deployments)
151
+ ```ruby
152
+ task :deploy_config do
153
+ upload_template "./config/nginx.conf.erb", "/etc/nginx/sites-available/myapp.conf",
154
+ domain_name: "example.com",
155
+ port: 3000
156
+ end
311
157
  ```
312
158
 
313
- ## 🔧 Troubleshooting
314
-
315
- ### Common Issues
316
-
317
- 1. **SSH Connection Failed**
318
- ```bash
319
- # Check SSH connection
320
- ssh -vvv user@hostname
321
-
322
- # Verify keys
323
- ssh-add -l
324
- ```
325
-
326
- 2. **Permission Issues**
327
- ```ruby
328
- # Use sudo for commands
329
- run 'sudo systemctl restart nginx'
330
-
331
- # Check file permissions
332
- run 'ls -la {{deploy_to}}'
333
- ```
334
-
335
- 3. **Timeout Issues**
336
- ```ruby
337
- # Increase timeout
338
- run 'long_command', timeout: 300
339
-
340
- # Or set in configuration file
341
- command_timeout: 600
342
- ```
343
-
344
- ### Debugging Tips
159
+ ### Command Line Options
345
160
 
346
161
  ```bash
347
- # Verbose output mode
348
- kdeploy deploy script.rb --verbose
349
-
350
- # Dry run mode
351
- kdeploy deploy script.rb --dry-run
162
+ # Execute with dry run
163
+ kdeploy execute deploy.rb --dry-run
352
164
 
353
- # View configuration
354
- kdeploy config
165
+ # Limit to specific hosts
166
+ kdeploy execute deploy.rb --limit web01,web02
355
167
 
356
- # Validate script
357
- kdeploy validate script.rb
168
+ # Set parallel execution count
169
+ kdeploy execute deploy.rb --parallel 5
358
170
 
359
- # View logs
360
- tail -f kdeploy.log
171
+ # Execute specific task
172
+ kdeploy execute deploy.rb deploy_web
361
173
  ```
362
174
 
363
- ## 🤝 Contributing
364
-
365
- We welcome community contributions! Please follow these guidelines:
366
-
367
- 1. Fork the project
368
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
369
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
370
- 4. Push to the branch (`git push origin feature/amazing-feature`)
371
- 5. Create a Pull Request
175
+ ## 🔧 Development
372
176
 
373
- ## 📄 License
177
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
374
178
 
375
- This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
179
+ To install this gem onto your local machine, run `bundle exec rake install`.
376
180
 
377
- ## 🔗 Links
181
+ ## 🤝 Contributing
378
182
 
379
- - [Project Homepage](https://github.com/kevin197011/kdeploy)
380
- - [Documentation](https://github.com/kevin197011/kdeploy/wiki)
381
- - [Issue Tracker](https://github.com/kevin197011/kdeploy/issues)
382
- - [Release Notes](https://github.com/kevin197011/kdeploy/releases)
183
+ 1. Fork it
184
+ 2. Create your feature branch (`git checkout -b feature/my-new-feature`)
185
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
186
+ 4. Push to the branch (`git push origin feature/my-new-feature`)
187
+ 5. Create a new Pull Request
383
188
 
384
- ## 💬 Community Support
189
+ ## 📝 License
385
190
 
386
- - GitHub Issues: [Report Issues](https://github.com/kevin197011/kdeploy/issues)
387
- - GitHub Discussions: [Community Discussions](https://github.com/kevin197011/kdeploy/discussions)
191
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
388
192
 
389
- ---
193
+ ## 🔍 Code of Conduct
390
194
 
391
- **Kdeploy** - Making deployment simple and powerful 🚀
195
+ Everyone interacting in the Kdeploy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kdeploy/blob/main/CODE_OF_CONDUCT.md).
data/exe/kdeploy ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "kdeploy"
5
+
6
+ Kdeploy::CLI.start(ARGV)
data/k.md ADDED
@@ -0,0 +1,149 @@
1
+ 以下是将 Kdeploy 项目的开发需求整理成的标准 Markdown 格式文档,可保存为 `dev_requirements.md`:
2
+
3
+ ---
4
+
5
+ ```markdown
6
+ # 📦 Kdeploy 开发需求文档
7
+
8
+ > **项目名称**:Kdeploy
9
+ > **项目类型**:Ruby Gem
10
+ > **定位**:轻量级 agentless 运维部署工具
11
+ > **灵感来源**:Ansible、Chef、Puppet
12
+ > **目标用户**:DevOps、SRE、系统运维工程师
13
+
14
+ ---
15
+
16
+ ## 🧭 项目目标
17
+
18
+ - 提供 **无 agent** 的远程部署解决方案
19
+ - 使用 **优雅的 Ruby DSL** 编写部署任务
20
+ - 支持任务的 **并发执行**
21
+ - 能够进行任务 **状态统计与结果输出**
22
+ - 管理 **完整的部署生命周期**(准备、执行、清理、回滚等)
23
+ - 简洁、轻量、便于嵌入其他工具链
24
+ - 可支持 **多主机、多环境配置管理**
25
+
26
+ ---
27
+
28
+ ## 📁 项目结构
29
+
30
+ ```
31
+
32
+ kdeploy/
33
+ ├── bin/
34
+ │ └── kdeploy # 主执行文件
35
+ ├── lib/
36
+ │ ├── kdeploy/
37
+ │ │ ├── dsl.rb # DSL 定义
38
+ │ │ ├── executor.rb # 并发执行器
39
+ │ │ ├── inventory.rb # 主机清单管理
40
+ │ │ ├── lifecycle.rb # 生命周期管理
41
+ │ │ ├── logger.rb # 日志与输出
42
+ │ │ └── version.rb
43
+ │ └── kdeploy.rb # 主入口
44
+ ├── tasks/
45
+ │ └── deploy.rb # 示例任务(用户自定义)
46
+ ├── spec/
47
+ │ └── kdeploy\_spec.rb # RSpec 测试
48
+ ├── kdeploy.gemspec
49
+ └── README.md
50
+
51
+ ````
52
+
53
+ ---
54
+
55
+ ## 🔧 功能模块设计
56
+
57
+ ### 1. DSL 任务定义
58
+
59
+ ```ruby
60
+ host 'web01', user: 'ubuntu', ip: '10.0.0.1'
61
+
62
+ task :deploy_web do
63
+ run 'sudo systemctl stop nginx'
64
+ upload './nginx.conf', '/etc/nginx/nginx.conf'
65
+ run 'sudo systemctl start nginx'
66
+ end
67
+ ````
68
+
69
+ ### 2. 并发执行器
70
+
71
+ * 线程池并发执行远程任务
72
+ * 自动记录成功/失败状态
73
+ * 支持最大并发数限制
74
+
75
+ ### 3. 生命周期管理
76
+
77
+ * `prepare`:初始化(如环境检查)
78
+ * `run`:主要任务执行
79
+ * `cleanup`:清理临时文件或状态
80
+ * `rollback`:失败回滚(可选)
81
+
82
+ ### 4. 主机清单
83
+
84
+ 支持静态或动态清单,如:
85
+
86
+ ```ruby
87
+ inventory do
88
+ host 'web01', user: 'ubuntu', ip: '10.0.0.1'
89
+ host 'db01', user: 'root', ip: '10.0.0.2'
90
+ end
91
+ ```
92
+
93
+ ### 5. 输出日志与状态统计
94
+
95
+ * 控制台美化输出(使用 `pastel`、`tty-table` 等)
96
+ * 最终报告:执行成功/失败主机、任务耗时、回滚信息等
97
+
98
+ ---
99
+
100
+ ## 🖥️ 命令行工具设计
101
+
102
+ 执行文件:`bin/kdeploy`
103
+
104
+ ```bash
105
+ kdeploy run tasks/deploy.rb --limit web01,web02 --parallel 5 --dry-run
106
+ ```
107
+
108
+ | 参数 | 说明 |
109
+ | ------------- | ------------- |
110
+ | `run` | 执行某个 DSL 任务文件 |
111
+ | `--limit` | 限定主机 |
112
+ | `--parallel` | 设置并发线程数 |
113
+ | `--dry-run` | 预览任务,不真正执行 |
114
+ | `--rollback` | 启动回滚 |
115
+ | `--inventory` | 使用特定主机清单文件 |
116
+
117
+ ---
118
+
119
+ ## 🧩 可扩展性设计
120
+
121
+ * 支持插件机制:可注册自定义任务类型
122
+ * 可支持其他协议(如 WinRM、Docker、Kubernetes 等)
123
+ * 日后可支持多环境配置(dev/stage/prod)
124
+ * 支持本地/远程日志聚合
125
+
126
+ ---
127
+
128
+ ## 📦 开发计划建议
129
+
130
+ | 阶段 | 内容 |
131
+ | ---------- | ----------------------------------------- |
132
+ | 1️⃣ 初始化 | 使用 `bundle gem .` 生成项目骨架,添加执行文件 |
133
+ | 2️⃣ DSL 实现 | 定义基本任务语法(`host`, `task`, `run`, `upload`) |
134
+ | 3️⃣ SSH 执行 | 实现基础 SSH 执行器(使用 `net-ssh`) |
135
+ | 4️⃣ 并发执行 | 引入线程池或 `concurrent-ruby` |
136
+ | 5️⃣ 生命周期 | 支持 prepare/run/cleanup/rollback 阶段 |
137
+ | 6️⃣ 状态统计 | 记录执行状态并输出汇总表 |
138
+ | 7️⃣ CLI 工具 | 实现 `bin/kdeploy` 命令入口 |
139
+ | 8️⃣ 测试与发布 | 使用 RSpec 添加测试,推送到 RubyGems |
140
+
141
+ ---
142
+
143
+ ## 📝 初始化命令
144
+
145
+ ```bash
146
+ bundle gem . --test=rspec --mit --coc --no-ext
147
+ ```
148
+
149
+