/
pipeline-ssh-rolling.yml
157 lines (151 loc) · 6.84 KB
/
pipeline-ssh-rolling.yml
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
pipeline:
name: harness_ssh_pipeline
identifier: harness_ssh_pipeline
projectIdentifier: default_project
orgIdentifier: default
tags: {}
stages:
- stage:
name: deploy-ssh
identifier: deployssh
description: ""
type: Deployment
spec:
deploymentType: Ssh
service:
serviceRef: harness_ssh
serviceInputs:
serviceDefinition:
type: Ssh
spec:
artifacts:
primary:
primaryArtifactRef: <+input>
sources: <+input>
environment:
environmentRef: harnessdevenv
deployToAll: false
infrastructureDefinitions:
- identifier: harness_remoteserver
execution:
steps:
- stepGroup:
name: Phase
identifier: Phase
strategy:
repeat:
items: <+stage.output.hosts>
maxConcurrency: 1
partitionSize: 1
unit: Count
steps:
- stepGroup:
name: Phase Group
identifier: phase_group
strategy:
repeat:
items: <+repeat.partition>
steps:
- step:
name: Deploy
type: Command
identifier: Deploy
timeout: 10m
spec:
onDelegate: false
environmentVariables: []
outputVariables: []
commandUnits:
- identifier: Setup_Runtime_Paths
name: Setup Runtime Paths
type: Script
spec:
shell: Bash
source:
type: Inline
spec:
script: |-
# Execute as root and pass environment variables
# su -p -
# Execute as root via user credentials (with root privileges)
# sudo -E su -p -
# Creating runtime, backup and staging folders:
mkdir -p $HOME/<+service.name>/<+env.name>/runtime
mkdir -p $HOME/<+service.name>/<+env.name>/backup
mkdir -p $HOME/<+service.name>/<+env.name>/staging
- identifier: Copy_Artifact
name: Copy Artifact
type: Copy
spec:
sourceType: Artifact
destinationPath: $HOME/<+service.name>/<+env.name>
- identifier: Copy_Config
name: Copy Config
type: Copy
spec:
sourceType: Artifact
destinationPath: $HOME/<+service.name>/<+env.name>
rollbackSteps:
- stepGroup:
name: Phase
identifier: Phase
strategy:
repeat:
items: <+stage.output.hosts>
maxConcurrency: 1
partitionSize: 1
unit: Count
steps:
- stepGroup:
name: Phase Group Rollback
identifier: phase_group_rollback
strategy:
repeat:
items: <+repeat.partition>
steps:
- step:
name: Rollback
identifier: Rollback
type: Command
timeout: 10m
spec:
onDelegate: false
environmentVariables: []
outputVariables: []
commandUnits:
- identifier: Setup_Runtime_Paths_Rollback
name: Setup Runtime Paths Rollback
type: Script
spec:
shell: Bash
source:
type: Inline
spec:
script: |-
# Execute as root and pass environment variables
# su -p -
# Execute as root via user credentials (with root privileges)
# sudo -E su -p -
# Creating runtime, backup and staging folders:
mkdir -p $HOME/<+service.name>/<+env.name>/runtime
mkdir -p $HOME/<+service.name>/<+env.name>/backup
mkdir -p $HOME/<+service.name>/<+env.name>/staging
- identifier: Copy_Artifact_Rollback
name: Copy Artifact Rollback
type: Copy
spec:
sourceType: Artifact
destinationPath: $HOME/<+service.name>/<+env.name>
- identifier: Copy_Config_Rollback
name: Copy Config Rollback
type: Copy
spec:
sourceType: Artifact
destinationPath: $HOME/<+service.name>/<+env.name>
tags: {}
failureStrategies:
- onFailure:
errors:
- AllErrors
action:
type: StageRollback