aboutsummaryrefslogtreecommitdiff
path: root/contrib/cirrus/packer/libpod_base_images.yml
blob: 560cb321cdae155237bf239a8edb379413b6c0e2 (plain)
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
---

variables:
    # Complete local path to this repository (Required)
    GOSRC:
    # Relative path to this (packer) subdirectory (Required)
    PACKER_BASE:
    # Relative path to cirrus scripts subdirectory (Required)
    SCRIPT_BASE:
    # Unique ID for naming new base-images (required)
    TIMESTAMP:
    # Required for output from qemu builders
    TTYDEV:

    # Latest Fedora release
    FEDORA_IMAGE_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/30/Cloud/x86_64/images/Fedora-Cloud-Base-30-1.2.x86_64.qcow2"
    FEDORA_CSUM_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/30/Cloud/x86_64/images/Fedora-Cloud-30-1.2-x86_64-CHECKSUM"
    FEDORA_BASE_IMAGE_NAME: 'fedora-cloud-base-30-1-2'

    # Prior Fedora release
    PRIOR_FEDORA_IMAGE_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/29/Cloud/x86_64/images/Fedora-Cloud-Base-29-1.2.x86_64.qcow2"
    PRIOR_FEDORA_CSUM_URL: "https://dl.fedoraproject.org/pub/fedora/linux/releases/29/Cloud/x86_64/images/Fedora-Cloud-29-1.2-x86_64-CHECKSUM"
    PRIOR_FEDORA_BASE_IMAGE_NAME: 'fedora-cloud-base-29-1-2'  # Name to use in GCE

    # The name of the image in GCE used for packer build libpod_images.yml
    IBI_BASE_NAME: 'image-builder-image'
    CIDATA_ISO: 'cidata.iso'  # produced by Makefile

    # Path to json file (required, likely ~/.config/gcloud/legacy_credentials/*/adc.json)
    GOOGLE_APPLICATION_CREDENTIALS:
    # The complete project ID (required, not the short name)
    GCP_PROJECT_ID:
    # Pre-existing storage bucket w/ lifecycle-enabled
    XFERBUCKET: "packer-import"  # pre-created, globally unique, lifecycle-enabled

# Don't leak sensitive values in error messages / output
sensitive-variables:
    - 'GOOGLE_APPLICATION_CREDENTIALS'
    - 'GCP_PROJECT_ID'

# What images to produce in which cloud
builders:
    - &nested_virt
      name: 'fedora'
      type: 'qemu'
      accelerator: "kvm"
      iso_url: '{{user `FEDORA_IMAGE_URL`}}'
      disk_image: true
      format: "raw"
      disk_size: 5120
      iso_checksum_url: '{{user `FEDORA_CSUM_URL`}}'
      iso_checksum_type: "sha256"
      output_directory: '/tmp/{{build_name}}'
      vm_name: "disk.raw"  # actually qcow2, name required for post-processing
      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"
        - - "-cpu"
          - "host"
        - - "-device"
          - "virtio-rng-pci"
        - - "-chardev"
          - "tty,id=pts,path={{user `TTYDEV`}}"
        - - "-device"
          - "isa-serial,chardev=pts"
        - - "-cdrom"
          - "{{user `CIDATA_ISO`}}"
        - - "-netdev"
          - "user,id=net0,hostfwd=tcp::{{ .SSHHostPort }}-:22"
        - - "-device"
          - "virtio-net,netdev=net0"
      communicator: 'ssh'
      ssh_private_key_file: 'cidata.ssh'
      ssh_username: 'root'

    - <<: *nested_virt
      name: 'prior-fedora'
      iso_url: '{{user `PRIOR_FEDORA_IMAGE_URL`}}'
      iso_checksum_url: '{{user `PRIOR_FEDORA_CSUM_URL`}}'

provisioners:
    - type: 'shell'
      inline:
        - 'mkdir -p /tmp/libpod/{{user `SCRIPT_BASE`}}'
        - 'mkdir -p /tmp/libpod/{{user `PACKER_BASE`}}'

    - type: 'file'
      source: '{{user `GOSRC`}}/.cirrus.yml'
      destination: '/tmp/libpod/.cirrus.yml'

    - type: 'file'
      source: '{{user `GOSRC`}}/{{user `SCRIPT_BASE`}}/'
      destination: '/tmp/libpod/{{user `SCRIPT_BASE`}}/'

    - type: 'file'
      source: '{{user `GOSRC`}}/{{user `PACKER_BASE`}}/'
      destination: '/tmp/libpod/{{user `PACKER_BASE`}}/'

    - &shell_script
      type: 'shell'
      inline:
        - 'chmod +x /tmp/libpod/{{user `PACKER_BASE`}}/{{build_name}}_base-setup.sh'
        - '/tmp/libpod/{{user `PACKER_BASE`}}/{{build_name}}_base-setup.sh pre'
      expect_disconnect: true  # Allow this to reboot the VM
      environment_vars:
          - 'TIMESTAMP={{user `TIMESTAMP`}}'
          - 'GOSRC=/tmp/libpod'
          - 'SCRIPT_BASE={{user `SCRIPT_BASE`}}'
          - 'PACKER_BASE={{user `PACKER_BASE`}}'

    - <<: *shell_script
      inline: ['{{user `GOSRC`}}/{{user `PACKER_BASE`}}/{{build_name}}_base-setup.sh']
      expect_disconnect: false
      pause_before: '10s'
      inline:
        - '/tmp/libpod/{{user `PACKER_BASE`}}/{{build_name}}_base-setup.sh post'

post-processors:
    - - type: "compress"
        only: ['fedora', 'prior-fedora']
        output: '/tmp/{{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 `GOOGLE_APPLICATION_CREDENTIALS`}}'
        bucket: '{{user `XFERBUCKET`}}'
        gcs_object_name: '{{build_name}}-{{user `TIMESTAMP`}}.tar.gz'
        image_name: "{{user `FEDORA_BASE_IMAGE_NAME`}}-{{user `TIMESTAMP`}}"
        image_description: 'Based on {{user `FEDORA_IMAGE_URL`}}'
        image_family: '{{user `FEDORA_BASE_IMAGE_NAME`}}'
      - <<: *gcp_import
        only: ['prior-fedora']
        image_name: "{{user `PRIOR_FEDORA_BASE_IMAGE_NAME`}}-{{user `TIMESTAMP`}}"
        image_description: 'Based on {{user `PRIOR_FEDORA_IMAGE_URL`}}'
        image_family: '{{user `PRIOR_FEDORA_BASE_IMAGE_NAME`}}'
      - type: 'manifest'