-
Notifications
You must be signed in to change notification settings - Fork 54
/
ci-opal.yml
259 lines (259 loc) · 8.14 KB
/
ci-opal.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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
---
description: Travis CI opal build env template
variables:
chef_log_level: info
docker_repository: travisci/ci-opal
docker_tag: packer-{{ timestamp }}-<%= git_desc %>
gce_account_file: "{{ env `GCE_ACCOUNT_FILE` }}"
gce_project_id: "{{ env `GCE_PROJECT_ID` }}"
image_name: travis-ci-opal-xenial-{{ timestamp }}-<%= git_desc %>
openstack_source_image_name: "{{ env `OS_SOURCE_IMAGE_XENIAL` }}"
travis_cookbooks_branch: "{{ env `TRAVIS_COOKBOOKS_BRANCH` }}"
travis_cookbooks_edge_branch: master
travis_cookbooks_sha: "{{ env `TRAVIS_COOKBOOKS_SHA` }}"
travis_uid: "{{ env `TRAVIS_UID` }}"
openstack_zone: "{{ env `OS_ZONE` }}"
openstack_key_path: "{{ env `OS_SSH_KEY_PATH`}}"
openstack_key_name: "{{ env `OS_SSH_KEY` }}"
docker_login_username: "{{ env `DOCKER_LOGIN_USERNAME` }}"
docker_login_password: "{{ env `DOCKER_LOGIN_PASSWORD` }}"
docker_login_server: "{{ env `DOCKER_LOGIN_SERVER` }}"
builders:
- type: googlecompute
name: googlecompute
communicator: ssh
ssh_timeout: 10m
ssh_port: 22
ssh_username: packer
image_description: Travis CI opal
account_file: "{{ user `gce_account_file` }}"
project_id: "{{ user `gce_project_id` }}"
source_image: ubuntu-1604-xenial-v20210928
zone: us-central1-a
image_name: "{{ user `image_name` }}"
machine_type: n1-standard-4
disk_size: 20
tags:
- ci
- opal
- travis-ci-packer-templates
- type: lxd
name: lxd
image: images:ubuntu/xenial
output_image: "{{ user `image_name` }}"
publish_properties:
- description: Travis CI opal build env template!
- type: docker
name: docker
login: true
login_username: "{{ user `docker_login_username` }}"
login_password: "{{ user `docker_login_password` }}"
login_server: "{{ user `docker_login_server` }}"
ssh_pty: true
<% if RUBY_PLATFORM =~ /powerpc64/ %>
image: "travisci/gce-parity:16.04-ppc64le"
<% else %>
image: "travisci/gce-parity:16.04"
<% end %>
run_command:
- -d
- -v
- <%= Dir.pwd %>/tmp/packer-builder-tmp:/tmp
- --privileged=true
#- --storage-opt=size=15G
- "{{ .Image }}"
- /sbin/init
commit: true
# Openstack builds disabled for failing with an error that's not possible to debug
# until a fix for the Packer error reporting is released:
# https://github.com/travis-ci/packer-templates/issues/555
- type: openstack
name: openstack
flavor: m1.large
insecure: true
image_name: "{{ user `image_name` }}"
ssh_username: ubuntu
networks:
<% ENV['OS_NETWORKS'].to_s.split(',').map(&:strip).each do |network| %>
- <%= network %>
<% end %>
source_image_name: "{{ user `openstack_source_image_name` }}"
availability_zone: "{{ user `openstack_zone` }}"
ssh_keypair_name: "{{ user `openstack_key_name` }}"
ssh_private_key_file: "{{ user `openstack_key_path` }}"
provisioners:
- type: shell
inline: sleep 10
only:
- googlecompute
- type: shell
inline: apt-get update -yqq && apt-get install sudo -yqq
# Delay script execution until after /sbin/init has cleared out /tmp,
# otherwise the uploaded script gets deleted before it can be run.
# TODO: Decide if the container startup command should be /bin/bash and the
# /sbin/init call made the first provision step instead of this workaround:
# https://github.com/travis-ci/packer-templates/issues/544#issuecomment-344971947
pause_before: 5s
only:
- docker
- type: file
source: tmp/git-meta
destination: /var/tmp/git-meta
- type: file
source: packer-assets/ubuntu-xenial-normal-purge.txt
destination: /var/tmp/purge.txt
- type: file
source: packer-assets/ubuntu-xenial-ci-opal-packages.txt
destination: /var/tmp/packages.txt
only:
- googlecompute
- openstack
- lxd
- type: file
source: packer-assets/ubuntu-xenial-ci-opal-docker-packages.txt
destination: /var/tmp/packages.txt
only:
- docker
- type: shell
scripts:
- packer-scripts/packer-env-dump
execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'"
- type: shell
scripts:
- packer-scripts/remove-default-users
execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'"
only:
- docker
- googlecompute
- lxd
# Recommendations for lxd images
- type: shell
inline: "systemctl mask sys-kernel-config.mount"
only:
- lxd
- type: shell
inline: "systemctl mask systemd-modules-load.service"
only:
- lxd
- type: shell
inline: "apt install snapd -y && snap install core"
only:
- lxd
- type: shell
inline: "apt-get remove --purge cloud-init --yes"
only:
- lxd
# end Recommendations
- type: shell
scripts:
- packer-scripts/pre-chef-bootstrap
- packer-scripts/clone-travis-cookbooks
environment_vars:
- SKIP_APT_UPGRADE=1
- TRAVIS_COOKBOOKS_BRANCH={{ user `travis_cookbooks_branch` }}
- TRAVIS_COOKBOOKS_SHA={{ user `travis_cookbooks_sha` }}
- TRAVIS_UID={{ user `travis_uid` }}
execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'"
- type: file
source: packer-assets/opal-system-info-commands.yml
destination: /var/tmp/opal-system-info-commands.yml
- type: shell
inline: chmod 0644 /var/tmp/opal-system-info-commands.yml
- type: chef-solo
version: 17.10.3
config_template: chef-solo.rb.tmpl
<% if ENV['CHEF_PROFILING'] %>
execute_command: "{{if .Sudo}}sudo {{end}}CI=yes chef-solo --chef-license accept-silent -F doc --no-color -c {{.ConfigPath}} -j {{.JsonPath}}"
<% else %>
execute_command: "{{if .Sudo}}sudo {{end}}CI=yes chef-solo --chef-license accept-silent --no-color -c {{.ConfigPath}} -j {{.JsonPath}}"
<% end %>
<% if ENV['BUILDER'] == "lxd" %>
# packer lxd builder copy cookbooks to wrong directory
execute_command: "rsync -a --delete-after /tmp/packer-chef-solo/cookbooks-0/cookbooks/ /tmp/packer-chef-solo/cookbooks-0/ && \
{{if .Sudo}}sudo {{end}}chef-solo --chef-license accept-silent --no-color -c {{.ConfigPath}} -j {{.JsonPath}}"
<% end %>
cookbook_paths:
- cookbooks
<% if ENV['COOKBOOKS_LOCAL'] && ENV['TRAVIS_COOKBOOKS_DIR'] %>
- <%= ENV['TRAVIS_COOKBOOKS_DIR'] %>/cookbooks
- <%= ENV['TRAVIS_COOKBOOKS_DIR'] %>/community-cookbooks
<% else %>
remote_cookbook_paths:
- /tmp/chef-stuff/travis-cookbooks/cookbooks
- /tmp/chef-stuff/travis-cookbooks/community-cookbooks
<% end %>
run_list:
- recipe[travis_ci_opal]
<% if ENV['CHEF_PROFILING'] %>
- recipe[poise-profiler]
<% end %>
- type: shell
scripts:
- packer-scripts/ensure-travis-user
- packer-scripts/purge
- packer-scripts/disable-apparmor
- packer-scripts/run-serverspecs
- packer-scripts/perforce-install
- packer-scripts/cosign-install
- packer-scripts/test-system-info-output
- packer-scripts/dump-dpkg-manifest
- packer-scripts/create-bin-lib-checksums
- packer-scripts/cleanup
# - packer-scripts/minimize
environment_vars:
- DISPLAY=:99.0
- SPEC_SUITES=travis_packer_templates
- TRAVIS_OBFUSCATE_PASSWORD=1
- TRAVIS_UID={{ user `travis_uid` }}
execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'"
- type: shell
scripts:
- packer-scripts/create-image-metadata-tarball
environment_vars:
- IMAGE_METADATA_TARBALL=/var/tmp/image-metadata-{{ user `image_name` }}.tar.bz2
execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'"
- type: file
source: /var/tmp/image-metadata-{{ user `image_name` }}.tar.bz2
destination: tmp/image-metadata-{{ user `image_name` }}.tar.bz2
direction: download
post-processors:
-
- type: docker-tag
repository: "{{ user `docker_repository` }}"
tag: "{{ user `docker_tag` }}"
only:
- docker
- type: shell-local
scripts: bin/docker-push
environment_vars:
- DOCKER_DEST={{ user `docker_repository` }}:{{ user `docker_tag` }}
only:
- docker
-
- type: shell-local
script: bin/job-board-register
environment_vars:
- IMAGE_NAME={{ user `image_name` }}
only:
- googlecompute
- lxd
- type: shell-local
script: bin/job-board-register
environment_vars:
- IMAGE_NAME={{ user `docker_repository` }}:{{ user `docker_tag` }}
only:
- docker
-
- type: shell-local
script: bin/write-latest-image-name
- type: shell-local
script: bin/lxc-export.sh
environment_vars:
- IMAGE_NAME={{ user `image_name` }}
only:
- lxd
- type: shell-local
inline:
- echo {{ user `image_name` }} > /tmp/packer-build-image-name
only:
- lxd