kdeploy 1.1.5 → 1.1.7

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: 9583a9a5362b5bf116325f3e9f930ff19be72c76d82060869284921079f93b19
4
- data.tar.gz: cbfa824d6defd7511a71d985073de549442a34ed4e165093e422543e33c1e321
3
+ metadata.gz: e051952db6e012c47b6a22131df85e29ed5d01cc2c1bf828afc271226c3e1233
4
+ data.tar.gz: b319b2fdfe19eb01494b15706e97b082ea0593b10292ca7795a1c6d497480cc8
5
5
  SHA512:
6
- metadata.gz: b20ac3a10b3de646fe5c23a96cebae09a0fb825fde88b3698a3a7beb2715abf7e05076ca2b4cc04715ee54935053cb23d1b392f8f726af79c15c244c7bed32a7
7
- data.tar.gz: 446eb1df1186929fc9576e55b558c869b01cfa7466f53a09e65836a59b365b5e3cb88bf98616393efd9181d84bc08b45b7e8348f89fa07ee75d5b9a53f9af173
6
+ metadata.gz: baffbef3dcc388b2e4e40868d8e13969c6753d0ef7857958d0302ada9b97b3d2395c09ee325b2e839d393e46eeaad1883245e2bc74439eaf60f92b9ed5e28f08
7
+ data.tar.gz: 55fd7c47ad17322f65c280ad54e6398cc1d1fb79084aebf8d02d209a939d3cf70d6a6f2f90903ac1af9913c27193cc1c5b824f9db8621c48446bd07acdbe10c3
data/README.md CHANGED
@@ -94,12 +94,16 @@ host "web02", user: "ubuntu", ip: "10.0.0.2", key: "~/.ssh/id_rsa"
94
94
  role :web, %w[web01 web02]
95
95
 
96
96
  # Define tasks
97
+ # 推荐多行命令用 heredoc(run <<~SHELL)
97
98
  task :deploy, roles: :web do
98
- run "sudo systemctl stop nginx"
99
+ run <<~SHELL
100
+ sudo systemctl stop nginx
101
+ echo "Deploying..."
102
+ sudo systemctl start nginx
103
+ SHELL
99
104
  upload_template "./config/nginx.conf.erb", "/etc/nginx/nginx.conf",
100
105
  domain_name: "example.com",
101
106
  port: 3000
102
- run "sudo systemctl start nginx"
103
107
  end
104
108
  ```
105
109
 
@@ -108,7 +112,8 @@ end
108
112
  ```bash
109
113
  kdeploy execute deploy.rb
110
114
  ```
111
- 4. demo:
115
+
116
+ 4. Demo:
112
117
 
113
118
  ```bash
114
119
  https://github.com/kevin197011/kdeploy-app
@@ -131,19 +136,10 @@ kdeploy execute deploy.rb --dry-run
131
136
  # Execute on specific hosts
132
137
  kdeploy execute deploy.rb --limit web01,web02
133
138
 
134
- # Execute with custom parallel count
135
- kdeploy execute deploy.rb --parallel 5
139
+ # Execute with custom parallel count (default: 10)
140
+ kdeploy execute deploy.rb --parallel 10
136
141
  ```
137
142
 
138
- When executing without specifying a task name (`kdeploy execute deploy.rb`), Kdeploy will:
139
- 1. Execute all defined tasks in the file
140
- 2. Run tasks in the order they were defined
141
- 3. Show task name before each task execution
142
- 4. Display color-coded output for better readability:
143
- - 🟢 Green: Normal output and success messages
144
- - 🔴 Red: Errors and failure messages
145
- - 🟡 Yellow: Warnings and notices
146
-
147
143
  ### Host Definition
148
144
 
149
145
  ```ruby
@@ -190,15 +186,19 @@ end
190
186
 
191
187
  # Role-based task
192
188
  task :deploy, roles: :web do
193
- run "sudo systemctl stop nginx"
189
+ run <<~SHELL
190
+ sudo systemctl stop nginx
191
+ sudo systemctl start nginx
192
+ SHELL
194
193
  upload "./config/nginx.conf", "/etc/nginx/nginx.conf"
195
- run "sudo systemctl start nginx"
196
194
  end
197
195
 
198
196
  # Host-specific task
199
197
  task :maintenance, on: %w[web01] do
200
- run "sudo apt-get update"
201
- run "sudo apt-get upgrade -y"
198
+ run <<~SHELL
199
+ sudo apt-get update
200
+ sudo apt-get upgrade -y
201
+ SHELL
202
202
  end
203
203
  ```
204
204
 
data/lib/kdeploy/cli.rb CHANGED
@@ -76,7 +76,7 @@ module Kdeploy
76
76
 
77
77
  desc 'execute TASK_FILE [TASK]', 'Execute deployment tasks from file'
78
78
  method_option :limit, type: :string, desc: 'Limit to specific hosts (comma-separated)'
79
- method_option :parallel, type: :numeric, default: 5, desc: 'Number of parallel executions'
79
+ method_option :parallel, type: :numeric, default: 10, desc: 'Number of parallel executions'
80
80
  method_option :dry_run, type: :boolean, desc: 'Show what would be done'
81
81
  def execute(task_file, task_name = nil)
82
82
  # 只在最前面输出一次 banner
@@ -30,55 +30,56 @@ module Kdeploy
30
30
  # Define hosts
31
31
  host 'web01', user: 'ubuntu', ip: '10.0.0.1', key: '~/.ssh/id_rsa'
32
32
  host 'web02', user: 'ubuntu', ip: '10.0.0.2', key: '~/.ssh/id_rsa'
33
+ host 'db01', user: 'root', ip: '10.0.0.3', key: '~/.ssh/id_rsa'
33
34
 
34
35
  # Define roles
35
36
  role :web, %w[web01 web02]
36
37
  role :db, %w[db01]
37
38
 
38
- # Define inventory
39
- inventory do
40
- host 'db01', user: 'root', ip: '10.0.0.3', key: '~/.ssh/id_rsa'
41
- end
42
-
43
39
  # Define deployment task for web servers
44
40
  task :deploy_web, roles: :web do
45
- # Stop service
46
- run 'sudo systemctl stop nginx'
41
+ run <<~SHELL
42
+ sudo systemctl stop nginx
43
+ echo "Deploying..."
44
+ SHELL
47
45
 
48
- # Upload configuration using ERB template
49
46
  upload_template './config/nginx.conf.erb', '/etc/nginx/nginx.conf',
50
47
  domain_name: 'example.com',
51
48
  port: 3000,
52
49
  worker_processes: 4,
53
50
  worker_connections: 2048
54
51
 
55
- # Upload static configuration
56
52
  upload './config/app.conf', '/etc/nginx/conf.d/app.conf'
57
53
 
58
- # Restart service
59
- run 'sudo systemctl start nginx'
60
-
61
- # Check status
62
- run 'sudo systemctl status nginx'
54
+ run <<~SHELL
55
+ sudo systemctl start nginx
56
+ sudo systemctl status nginx
57
+ SHELL
63
58
  end
64
59
 
65
60
  # Define backup task for database servers
66
61
  task :backup_db, roles: :db do
67
- run 'tar -czf /tmp/backup.tar.gz /var/lib/postgresql/data'
68
- run 'aws s3 cp /tmp/backup.tar.gz s3://my-backups/'
69
- run 'rm /tmp/backup.tar.gz'
62
+ run <<~SHELL
63
+ tar -czf /tmp/backup.tar.gz /var/lib/postgresql/data
64
+ aws s3 cp /tmp/backup.tar.gz s3://my-backups/
65
+ rm /tmp/backup.tar.gz
66
+ SHELL
70
67
  end
71
68
 
72
69
  # Define task for specific hosts
73
70
  task :maintenance, on: %w[web01] do
74
- run 'sudo systemctl stop nginx'
75
- run 'sudo apt-get update && sudo apt-get upgrade -y'
76
- run 'sudo systemctl start nginx'
71
+ run <<~SHELL
72
+ sudo systemctl stop nginx
73
+ sudo apt-get update && sudo apt-get upgrade -y
74
+ sudo systemctl start nginx
75
+ SHELL
77
76
  end
78
77
 
79
78
  # Define task for all hosts
80
79
  task :update do
81
- run 'sudo apt-get update && sudo apt-get upgrade -y'
80
+ run <<~SHELL
81
+ sudo apt-get update && sudo apt-get upgrade -y
82
+ SHELL
82
83
  end
83
84
  RUBY
84
85
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kdeploy
4
- VERSION = '1.1.5'
4
+ VERSION = '1.1.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kk