|
| 1 | +--- |
| 2 | +description: Travis CI Ubuntu 24.04 build env template |
| 3 | +variables: |
| 4 | + chef_log_level: info |
| 5 | + docker_repository: travisci/ci-ubuntu-2404 |
| 6 | + docker_tag: packer-minimal-{{ timestamp }}-<%= git_desc %> |
| 7 | + gce_account_file: "{{ env `GCE_ACCOUNT_FILE` }}" |
| 8 | + gce_project_id: "{{ env `GCE_PROJECT_ID` }}" |
| 9 | + image_name: travis-ci-ubuntu-2404-minimal-{{ timestamp }}-<%= git_desc %> |
| 10 | + travis_cookbooks_branch: "{{ env `TRAVIS_COOKBOOKS_BRANCH` }}" |
| 11 | + travis_cookbooks_edge_branch: master |
| 12 | + travis_cookbooks_sha: "{{ env `TRAVIS_COOKBOOKS_SHA` }}" |
| 13 | + travis_uid: "{{ env `TRAVIS_UID` }}" |
| 14 | + docker_login_username: "{{ env `DOCKER_LOGIN_USERNAME` }}" |
| 15 | + docker_login_password: "{{ env `DOCKER_LOGIN_PASSWORD` }}" |
| 16 | + docker_login_server: "{{ env `DOCKER_LOGIN_SERVER` }}" |
| 17 | +builders: |
| 18 | +- type: googlecompute |
| 19 | + name: googlecompute |
| 20 | + communicator: ssh |
| 21 | + ssh_timeout: 10m |
| 22 | + ssh_port: 22 |
| 23 | + ssh_username: packer |
| 24 | + image_description: Travis CI Ubuntu 24.04 |
| 25 | + account_file: "{{ user `gce_account_file` }}" |
| 26 | + project_id: "{{ user `gce_project_id` }}" |
| 27 | + source_image_family: ubuntu-2404-lts-amd64 |
| 28 | + image_licenses: ["projects/vm-options/global/licenses/enable-vmx"] |
| 29 | + zone: us-central1-a |
| 30 | + image_name: "{{ user `image_name` }}" |
| 31 | + machine_type: n2-standard-4 |
| 32 | + disk_size: 50 |
| 33 | + temporary_key_pair_type: ed25519 |
| 34 | + tags: |
| 35 | + - ci |
| 36 | + - ubuntu-2404 |
| 37 | + - travis-ci-packer-templates |
| 38 | +- type: docker |
| 39 | + name: docker |
| 40 | + login: true |
| 41 | + login_username: "{{ user `docker_login_username` }}" |
| 42 | + login_password: "{{ user `docker_login_password` }}" |
| 43 | + login_server: "{{ user `docker_login_server` }}" |
| 44 | + ssh_pty: true |
| 45 | + <% if RUBY_PLATFORM =~ /powerpc64/ %> |
| 46 | + image: "travisci/gce-parity:24.04-ppc64le" |
| 47 | + <% else %> |
| 48 | + image: "travisci/gce-parity:24.04" |
| 49 | + <% end %> |
| 50 | + run_command: |
| 51 | + - -d |
| 52 | + - -v |
| 53 | + - <%= Dir.pwd %>/tmp/packer-builder-tmp:/tmp |
| 54 | + - --privileged=true |
| 55 | + - "{{ .Image }}" |
| 56 | + - /sbin/init |
| 57 | + commit: true |
| 58 | +provisioners: |
| 59 | +- type: shell |
| 60 | + inline: sleep 10 |
| 61 | + only: |
| 62 | + - googlecompute |
| 63 | +- type: shell |
| 64 | + inline: apt-get update -yqq && apt-get install sudo -yqq |
| 65 | + # Delay script execution until after /sbin/init has cleared out /tmp, |
| 66 | + # otherwise the uploaded script gets deleted before it can be run. |
| 67 | + # TODO: Decide if the container startup command should be /bin/bash and the |
| 68 | + # /sbin/init call made the first provision step instead of this workaround: |
| 69 | + # https://github.com/travis-ci/packer-templates/issues/544#issuecomment-344971947 |
| 70 | + pause_before: 5s |
| 71 | + only: |
| 72 | + - docker |
| 73 | +# - type: file |
| 74 | +# source: tmp/travis-cookbooks |
| 75 | +# destination: /var/tmp/travis-cookbooks |
| 76 | +- type: file |
| 77 | + source: tmp/git-meta |
| 78 | + destination: /var/tmp/git-meta |
| 79 | +- type: file |
| 80 | + source: packer-assets/ubuntu-2404-normal-purge.txt |
| 81 | + destination: /var/tmp/purge.txt |
| 82 | +- type: file |
| 83 | + source: packer-assets/ci-ubuntu-2404-packages.txt |
| 84 | + destination: /var/tmp/packages.txt |
| 85 | + only: |
| 86 | + - googlecompute |
| 87 | +- type: file |
| 88 | + source: packer-assets/ci-ubuntu-2404-docker-packages.txt |
| 89 | + destination: /var/tmp/packages.txt |
| 90 | + only: |
| 91 | + - docker |
| 92 | +- type: shell |
| 93 | + scripts: |
| 94 | + - packer-scripts/packer-env-dump |
| 95 | + execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'" |
| 96 | +- type: shell |
| 97 | + scripts: |
| 98 | + - packer-scripts/remove-default-users |
| 99 | + execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'" |
| 100 | + only: |
| 101 | + - docker |
| 102 | + - googlecompute |
| 103 | +- type: shell |
| 104 | + scripts: |
| 105 | + - packer-scripts/pre-chef-bootstrap-noble |
| 106 | + - packer-scripts/clone-travis-cookbooks |
| 107 | + environment_vars: |
| 108 | + - SKIP_APT_UPGRADE=1 |
| 109 | + - TRAVIS_COOKBOOKS_BRANCH={{ user `travis_cookbooks_branch` }} |
| 110 | + - TRAVIS_COOKBOOKS_SHA={{ user `travis_cookbooks_sha` }} |
| 111 | + - TRAVIS_UID={{ user `travis_uid` }} |
| 112 | + execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'" |
| 113 | +- type: file |
| 114 | + source: packer-assets/ubuntu-2404-minimal-system-info-commands.yml |
| 115 | + destination: /var/tmp/ubuntu-2404-minimal-system-info-commands.yml |
| 116 | +- type: shell |
| 117 | + inline: chmod 0644 /var/tmp/ubuntu-2404-minimal-system-info-commands.yml |
| 118 | +- type: chef-solo |
| 119 | + version: 18.4.12 |
| 120 | + config_template: chef-solo.rb.tmpl |
| 121 | + <% if ENV['CHEF_PROFILING'] %> |
| 122 | + execute_command: "{{if .Sudo}}sudo {{end}}CI=yes chef-solo --chef-license accept-silent -F doc --no-color -c {{.ConfigPath}} -j {{.JsonPath}}" |
| 123 | + <% else %> |
| 124 | + execute_command: "{{if .Sudo}}sudo {{end}}CI=yes chef-solo --chef-license accept-silent --no-color -c {{.ConfigPath}} -j {{.JsonPath}}" |
| 125 | + <% end %> |
| 126 | + cookbook_paths: |
| 127 | + - cookbooks |
| 128 | + <% if ENV['COOKBOOKS_LOCAL'] && ENV['TRAVIS_COOKBOOKS_DIR'] %> |
| 129 | + - <%= ENV['TRAVIS_COOKBOOKS_DIR'] %>/cookbooks |
| 130 | + - <%= ENV['TRAVIS_COOKBOOKS_DIR'] %>/community-cookbooks |
| 131 | + <% else %> |
| 132 | + remote_cookbook_paths: |
| 133 | + - /tmp/chef-stuff/travis-cookbooks/cookbooks |
| 134 | + - /tmp/chef-stuff/travis-cookbooks/community-cookbooks |
| 135 | + <% end %> |
| 136 | + run_list: |
| 137 | + - recipe[travis_ci_ubuntu_2404_minimal] |
| 138 | + <% if ENV['CHEF_PROFILING'] %> |
| 139 | + - recipe[poise-profiler] |
| 140 | + <% end %> |
| 141 | +- type: shell |
| 142 | + scripts: |
| 143 | + - packer-scripts/ensure-travis-user |
| 144 | + - packer-scripts/purge |
| 145 | + - packer-scripts/disable-apparmor |
| 146 | + - packer-scripts/run-serverspecs |
| 147 | + - packer-scripts/test-system-info-output |
| 148 | + - packer-scripts/dump-dpkg-manifest |
| 149 | + - packer-scripts/create-bin-lib-checksums |
| 150 | + - packer-scripts/cleanup |
| 151 | + # - packer-scripts/minimize |
| 152 | + environment_vars: |
| 153 | + - DISPLAY=:99.0 |
| 154 | + - SPEC_SUITES=travis_packer_templates |
| 155 | + - TRAVIS_OBFUSCATE_PASSWORD=1 |
| 156 | + - TRAVIS_UID={{ user `travis_uid` }} |
| 157 | + execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'" |
| 158 | +- type: shell |
| 159 | + environment_vars: |
| 160 | + - TRAVIS_OBFUSCATE_PASSWORD=1 |
| 161 | + - TRAVIS_UID={{ user `travis_uid` }} |
| 162 | + execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'" |
| 163 | + inline: |
| 164 | + - "find /etc/systemd -type f -o -type l" |
| 165 | + # - "rm -v /etc/systemd/system/network-online.target.wants/networking.service" |
| 166 | + # - "rm -v /etc/systemd/system/multi-user.target.wants/networking.service" |
| 167 | +- type: shell |
| 168 | + scripts: |
| 169 | + - packer-scripts/create-image-metadata-tarball |
| 170 | + environment_vars: |
| 171 | + - IMAGE_METADATA_TARBALL=/var/tmp/image-metadata-{{ user `image_name` }}.tar.bz2 |
| 172 | + execute_command: "{{ .Vars }} exec sudo -E -S bash '{{ .Path }}'" |
| 173 | +- type: file |
| 174 | + source: /var/tmp/image-metadata-{{ user `image_name` }}.tar.bz2 |
| 175 | + destination: tmp/image-metadata-{{ user `image_name` }}.tar.bz2 |
| 176 | + direction: download |
| 177 | +post-processors: |
| 178 | +- |
| 179 | + - type: docker-tag |
| 180 | + repository: "{{ user `docker_repository` }}" |
| 181 | + tag: "{{ user `docker_tag` }}" |
| 182 | + only: |
| 183 | + - docker |
| 184 | + - type: shell-local |
| 185 | + scripts: bin/docker-push |
| 186 | + environment_vars: |
| 187 | + - DOCKER_DEST={{ user `docker_repository` }}:{{ user `docker_tag` }} |
| 188 | + only: |
| 189 | + - docker |
| 190 | +- |
| 191 | + - type: shell-local |
| 192 | + script: bin/job-board-register |
| 193 | + environment_vars: |
| 194 | + - IMAGE_NAME={{ user `image_name` }} |
| 195 | + only: |
| 196 | + - googlecompute |
| 197 | + - type: shell-local |
| 198 | + script: bin/job-board-register |
| 199 | + environment_vars: |
| 200 | + - IMAGE_NAME={{ user `docker_repository` }}:{{ user `docker_tag` }} |
| 201 | + only: |
| 202 | + - docker |
| 203 | +- |
| 204 | + - type: shell-local |
| 205 | + script: bin/write-latest-image-name |
0 commit comments