-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-scenario.toml
99 lines (86 loc) · 2.92 KB
/
example-scenario.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Credentials section
# username - will be added to the variables
# password - if not provided, will use the ssh-agent
# [!] will not be added to the variables
[credentials]
username = "my_username"
password = "my_password"
[server]
host = "localhost"
port = "22"
[execute]
steps = [
{ task = "copy_jar_to_server" },
{ task = "stop_service", rollback = [
"start_service"
] },
{ task = "create_backup", rollback = [
"start_service"
] },
{ task = "remove_current_deploy", rollback = [
"restore_backup",
"start_service"
] },
{ task = "deploy_new_file", rollback = [
"restore_backup",
"start_service"
] },
{ task = "start_service", rollback = [
"restore_backup",
"start_service"
] }
]
# Variables section
[variables]
# will be prompted for input
[variables.required]
"path:local_jar_path" = "Local JAR Path"
some_variable = "Some Variable"
"path:some_other_path" = "Some Other Path"
# generated by the app
[variables.special]
timestamp = "%Y-%m-%dT%H%M%S%:z"
# plain string variables defined in this file
[variables.defined]
service_name = "my_service"
remote_service_script_path = "/usr/local/bin/{service_name}.sh"
remote_deploy_path = "/usr/local/{service_name}/{service_name}.jar"
backup_path = "/u01/backup/{service_name}/{service_name}-{timestamp}.jar"
remote_base_path = "/home/{username}"
# Tasks section
[tasks.copy_jar_to_server]
type = "SftpCopy"
description = "Copying new deploy file to server"
source_path = "{local_jar_path}"
destination_path = "{remote_base_path}/{basename:local_jar_path}"
error_message = "Failed to copy new deploy file to server."
[tasks.stop_service]
type = "RemoteSudo"
description = "Stopping the service on remote server"
command = "sudo {remote_service_script_path} stop"
error_message = "Failed to stop the service on the remote server."
[tasks.create_backup]
type = "RemoteSudo"
description = "Creating backup of current deployment"
command = "sudo cp -a {remote_deploy_path} {backup_path}"
error_message = "Failed to create backup of the current deployment."
[tasks.remove_current_deploy]
type = "RemoteSudo"
description = "Removing current deployment"
command = "sudo rm {remote_deploy_path} -f"
error_message = "Failed to remove the current deployment."
[tasks.deploy_new_file]
type = "RemoteSudo"
description = "Deploying the new file"
command = "sudo mv {remote_base_path}/{basename:local_jar_path} {remote_deploy_path}"
error_message = "Failed to deploy the new file."
[tasks.start_service]
type = "RemoteSudo"
description = "Starting the service on remote server"
command = "sudo {remote_service_script_path} start"
error_message = "Failed to start the service on the remote server."
[tasks.restore_backup]
type = "RemoteSudo"
description = "Restoring backup of current deployment"
command = "sudo cp -a {backup_path} {remote_deploy_path}"
error_message = "Failed to restore backup of the current deployment."