-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgce.yml
157 lines (142 loc) · 5.93 KB
/
gce.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
---
variables: # Empty value means it must be passed in on command-line
# GCE Project ID where images will be produced
GCP_PROJECT_ID: "libpod-218412"
# Pre-existing google storage bucket w/ very short lifecycle enabled
XFERBUCKET: "packer-import"
# Required path to service account credentials file
GAC_FILEPATH:
# Required for presenting output from qemu builders
TTYDEV:
# Required for 'make clean' support and not clobbering a memory-backed /tmp
TEMPDIR:
# Naming suffix for images to prevent clashes (default to timestamp)
# N/B: There are length/character limitations in GCE for image names
IMG_SFX: '{{ timestamp }}'
# BIG-FAT-WARNING: When updating the image names and/or URLs below,
# ensure the distro version numbers contained in the `podman/*_release`
# files exactly match. These represent the container base-image tags
# to build from - just as the sources below are the base-images to
# start from building VM images.
# Upstream source for Ubuntu image duplication (prevents expiration)
# Look these up in the console by searching images for
# "Created by: Canonical"
UBUNTU_BASE_IMAGE: 'ubuntu-2104-hirsute-v20210511a'
# Latest Fedora release download URL
FEDORA_IMAGE_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-34-1.2.x86_64.qcow2"
FEDORA_CSUM_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/34/Cloud/x86_64/images/Fedora-Cloud-34-1.2-x86_64-CHECKSUM"
# Prior Fedora release
PRIOR_FEDORA_IMAGE_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2"
PRIOR_FEDORA_CSUM_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-33-1.2-x86_64-CHECKSUM"
# Don't leak sensitive values in error messages / output
sensitive-variables:
- 'GAC_FILEPATH'
builders:
- &qemu_virt
name: 'fedora'
type: 'qemu'
accelerator: "kvm"
qemu_binary: '/usr/libexec/qemu-kvm' # Unique to CentOS, not fedora :(
iso_url: '{{user `FEDORA_IMAGE_URL`}}'
disk_image: true
format: "raw"
disk_size: 10240
iso_checksum: 'file:{{user `FEDORA_CSUM_URL`}}'
vm_name: "disk.raw" # actually qcow2, name required for post-processing
output_directory: '{{ user `TEMPDIR` }}/{{build_name}}' # /<vm_name>.disk.raw
boot_wait: '5s'
shutdown_command: 'shutdown -h now'
headless: true
# qemu_binary: "/usr/libexec/qemu-kvm"
qemuargs: # List-of-list format required to override packer-generated args
- - "-m"
- "1024"
- - "-device"
- "virtio-rng-pci"
- - "-chardev"
- "tty,id=pts,path={{user `TTYDEV`}}"
- - "-device"
- "isa-serial,chardev=pts"
- - "-netdev"
- "user,id=net0,hostfwd=tcp::{{ .SSHHostPort }}-:22"
- - "-device"
- "virtio-net,netdev=net0"
cd_label: "cidata"
cd_files:
- '{{user `TEMPDIR`}}/meta-data'
- '{{user `TEMPDIR`}}/user-data'
communicator: 'ssh'
pause_before_connecting: '10s'
ssh_private_key_file: '{{ user `TEMPDIR` }}/cidata.ssh'
ssh_disable_agent_forwarding: true
ssh_username: 'root'
ssh_timeout: '5m'
vnc_bind_address: 0.0.0.0
- <<: *qemu_virt
name: 'prior-fedora'
iso_url: '{{user `PRIOR_FEDORA_IMAGE_URL`}}'
iso_checksum: 'file:{{user `PRIOR_FEDORA_CSUM_URL`}}'
- &imgcopy
name: 'ubuntu'
type: 'googlecompute'
# Prefix IMG_SFX with "b" so this is never confused with a cache_image name
image_name: 'ubuntu-b{{user `IMG_SFX`}}'
image_family: '{{build_name}}-base'
source_image: '{{user `UBUNTU_BASE_IMAGE`}}'
source_image_project_id: 'ubuntu-os-cloud'
project_id: '{{user `GCP_PROJECT_ID`}}'
# Can't use env. var for this, googlecompute-import only supports filepath
account_file: '{{user `GAC_FILEPATH`}}'
zone: 'us-central1-a'
disk_size: 20
# Identify the instance
labels:
sfx: '{{user `IMG_SFX`}}'
src: '{{user `UBUNTU_BASE_IMAGE`}}'
# Gotcha: https://www.packer.io/docs/builders/googlecompute#gotchas
ssh_username: 'packer'
provisioners: # Ubuntu images come bundled with GCE integrations provisioned
- type: 'shell'
inline:
- 'set -e'
- 'mkdir -p /tmp/automation_images'
- type: 'file'
source: '{{ pwd }}/'
destination: '/tmp/automation_images/'
- only: ['fedora', 'prior-fedora']
type: 'shell'
inline:
- 'set -e'
- '/bin/bash /tmp/automation_images/base_images/fedora_base-setup.sh'
- only: ['ubuntu']
type: 'shell'
inline:
- 'set -e'
- '/bin/bash /tmp/automation_images/base_images/ubuntu_base-setup.sh'
post-processors:
# Must be double-nested to guarantee execution order
- - type: "compress"
only: ['fedora', 'prior-fedora']
output: '{{ user `TEMPDIR` }}/{{build_name}}/disk.raw.tar.gz'
format: '.tar.gz'
compression_level: 9
- &gcp_import
only: ['fedora']
type: "googlecompute-import"
project_id: '{{user `GCP_PROJECT_ID`}}'
account_file: '{{user `GAC_FILEPATH`}}'
bucket: '{{user `XFERBUCKET`}}'
gcs_object_name: '{{build_name}}-{{user `IMG_SFX`}}.tar.gz'
image_name: "fedora-b{{user `IMG_SFX`}}"
image_description: 'Based on {{user `FEDORA_IMAGE_URL`}}'
image_family: '{{build_name}}-base'
- <<: *gcp_import
only: ['prior-fedora']
image_name: "prior-fedora-b{{user `IMG_SFX`}}"
image_description: 'Based on {{user `PRIOR_FEDORA_IMAGE_URL`}}'
image_family: '{{build_name}}-base'
- type: 'manifest'
output: 'base_images/manifest.json' # Collected by Cirrus-CI
strip_path: true
custom_data:
IMG_SFX: '{{ user `IMG_SFX` }}'