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 +4 -4
- data/README.md +18 -18
- data/lib/kdeploy/cli.rb +1 -1
- data/lib/kdeploy/initializer.rb +22 -21
- data/lib/kdeploy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e051952db6e012c47b6a22131df85e29ed5d01cc2c1bf828afc271226c3e1233
|
4
|
+
data.tar.gz: b319b2fdfe19eb01494b15706e97b082ea0593b10292ca7795a1c6d497480cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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
|
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
|
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
|
201
|
-
|
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:
|
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
|
data/lib/kdeploy/initializer.rb
CHANGED
@@ -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
|
-
|
46
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
68
|
-
|
69
|
-
|
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
|
75
|
-
|
76
|
-
|
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
|
80
|
+
run <<~SHELL
|
81
|
+
sudo apt-get update && sudo apt-get upgrade -y
|
82
|
+
SHELL
|
82
83
|
end
|
83
84
|
RUBY
|
84
85
|
end
|
data/lib/kdeploy/version.rb
CHANGED