forked from orange-cloudfoundry/cf-ops-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
micro-bosh-init-pipeline.yml
204 lines (189 loc) · 7.35 KB
/
micro-bosh-init-pipeline.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
---
resource_types:
- name: slack-notification
type: docker-image
source:
repository: cfcommunity/slack-notification-resource
- name: cron-resource
type: docker-image
source:
repository: cftoolsmiths/cron-resource
resources:
- name: at-noon
type: cron-resource
source:
expression: "0 12 * * 1-5"
location: "Europe/Paris"
fire_immediately: true
#- name: iaas-terraform-specs
# type: git
# source:
# uri: ((secrets-uri))
# branch: master
# skip_ssl_verification: true
# paths: ["micro-depls/terraform-config/"]
- name: secrets
type: git
source:
uri: ((secrets-uri))
branch: ((secrets-branch))
skip_ssl_verification: true
- name: paas-bootstrap
type: git
source:
uri: ((paas-templates-uri))
branch: ((paas-templates-branch))
skip_ssl_verification: true
- name: failure-alert
type: slack-notification
source:
url: ((slack-webhook))
jobs:
- name: create-micro-bosh
plan:
- get: at-noon
trigger: true
- get: secrets
params: { submodules: none }
- get: paas-bootstrap
params: { submodules: [inception/terraform-config/template/bosh-openstack-environment-templates] }
- task: generate-terraform-tfvars
input_mapping: {scripts-resource: paas-bootstrap, credentials-resource: secrets, additional-resource: secrets}
output_mapping: {generated-files: terraform-tfvars}
file: paas-bootstrap/concourse/tasks/generate-manifest.yml
params:
YML_FILES: |
./credentials-resource/inception/micro-bosh/secrets/secrets.yml
./credentials-resource/shared/secrets.yml
YML_TEMPLATE_DIR: scripts-resource/inception/terraform-config/template
CUSTOM_SCRIPT_DIR: scripts-resource/inception/terraform-config/template
SUFFIX: -tpl.tfvars.yml
on_failure:
put: failure-alert
params:
channel: ((slack-channel))
text: Failed cannot push master [[$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME]($ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME)].
icon_url: http://cl.ly/image/3e1h0H3H2s0P/concourse-logo.png
username: Concourse
- task: terraform-apply
input_mapping: {spec-resource: paas-bootstrap}
output_mapping: {generated-files: terraform}
config:
platform: linux
image_resource:
type: docker-image
source: {repository: hashicorp/terraform, tag: 0.8.7}
inputs:
- name: spec-resource
- name: terraform-tfvars
- name: secrets
outputs:
- name: generated-files
run:
path: sh
args:
- -exc
- |
terraform version
CURRENT_DIR=$(pwd)
# Copy tfstate
find secrets/${STATE_FILE_DIR}/ -type f -maxdepth 1 -exec cp {} generated-files/ \;
# Copy micro-bosh secrets
cp -r secrets/inception/micro-bosh/secrets/* generated-files/
cp terraform-tfvars/* generated-files/
cd generated-files
terraform apply ../spec-resource/$SPEC_PATH
params:
SPEC_PATH: "inception/terraform-config/template/bosh-openstack-environment-templates/bosh-init-tf"
STATE_FILE_DIR: "inception/terraform-config/secrets"
ensure:
task: update-terraform-state-file
input_mapping: {reference-resource: secrets, generated-resource: terraform}
output_mapping: {updated-git-resource: updated-terraform-state-secrets}
file: paas-bootstrap/concourse/tasks/git_update_a_file_from_generated.yml
params:
OLD_FILE: "inception/terraform-config/terraform.tfstate"
NEW_FILE: "terraform.tfstate"
COMMIT_MESSAGE: "Terraform micro-depls auto update - [skip ci]"
on_failure:
put: failure-alert
params:
channel: ((slack-channel))
text: Failed cannot push master [[$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME]($ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME)].
icon_url: http://cl.ly/image/3e1h0H3H2s0P/concourse-logo.png
username: Concourse
on_success:
put: secrets
get_params: {submodules: none}
params:
repository: updated-terraform-state-secrets
rebase: true
- task: extract_terraform_outputs
input_mapping: {scripts-resource: paas-bootstrap, state-file-resource: terraform}
output_mapping: {result-dir: terraform-outputs}
config:
platform: linux
image_resource:
type: docker-image
source: {repository: ruby, tag: 2.3.1-slim}
inputs:
- name: scripts-resource
- name: state-file-resource
outputs:
- name: result-dir
run:
path: sh
args:
- -exc
- |
scripts-resource/scripts/terraform/extract_terraform_state_to_yaml.rb <${STATE_FILE} >${OUTPUT_FILE}
cat ${OUTPUT_FILE}
params:
STATE_FILE: "state-file-resource/terraform.tfstate"
OUTPUT_FILE: "result-dir/bosh.terraform-outputs.yml"
- task: generate-micro-bosh-config
input_mapping: {scripts-resource: paas-bootstrap, credentials-resource: secrets, additional-resource: terraform-outputs}
output_mapping: {generated-files: micro-bosh}
file: paas-bootstrap/concourse/tasks/generate-manifest.yml
params:
SPRUCE_FILE_BASE_PATH: credentials-resource/inception/micro-bosh/
YML_FILES: |
./credentials-resource/inception/micro-bosh/secrets/meta.yml
./credentials-resource/inception/micro-bosh/secrets/secrets.yml
./credentials-resource/shared/secrets.yml
./additional-resource/bosh.terraform-outputs.yml
YML_TEMPLATE_DIR: scripts-resource/inception/micro-bosh/template
CUSTOM_SCRIPT_DIR: scripts-resource/inception/micro-bosh/template
on_failure:
put: failure-alert
params:
channel: ((slack-channel))
text: Failed cannot push master [[$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME]($ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME)].
icon_url: http://cl.ly/image/3e1h0H3H2s0P/concourse-logo.png
username: Concourse
- task: diff-micro-bosh-config
input_mapping: {reference-resource: secrets, generated-resource: micro-bosh}
config:
platform: linux
image_resource:
type: docker-image
source: {repository: alpine, tag: "3.5"}
inputs:
- name: reference-resource
- name: generated-resource
run:
path: sh
args:
- -exc
- |
diff -ad $REFERENCE_FILE $OTHER_FILE
params:
REFERENCE_FILE: "reference-resource/inception/micro-bosh/secrets/micro-bosh.yml"
OTHER_FILE: "generated-resource/micro-bosh.yml"
on_failure:
put: failure-alert
params:
channel: ((slack-channel))
text: Failed cannot push master [[$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME]($ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME)].
icon_url: http://cl.ly/image/3e1h0H3H2s0P/concourse-logo.png
username: Concourse