Skip to content

Simplify image naming and packaging #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 211 additions & 0 deletions ci-ubuntu-1604.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
---
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: what about naming this file travis-ci-ubuntu-1604.yml to go with the name of the sub directory in the cookbooks i.e. cookbooks/travis_ci_ubuntu_1604 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mostly following the previous naming conventions, I can look into this renaming.

description: Travis CI Ubuntu 16.04 build environment template
variables:
docker_repository: travisci/ci-ubuntu-1604
docker_tag: packer-{{ timestamp }}-<%= git_desc %>
gce_account_file: "{{ env `GCE_ACCOUNT_FILE` }}"
gce_project_id: "{{ env `GCE_PROJECT_ID` }}"
image_name: travis-ci-ubuntu-1604-{{ timestamp }}-<%= git_desc %>
image_family: travis-ci-ubuntu-1604-edge
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` }}"
github_token: "{{ env `GITHUB_NOSCOPE_TOKEN` }}"
openstack_zone: "{{ env `OS_ZONE` }}"
openstack_key_path: "{{ env `OS_SSH_KEY_PATH`}}"
openstack_key_name: "{{ env `OS_SSH_KEY` }}"
builders:
- type: googlecompute
name: googlecompute
communicator: ssh
ssh_timeout: 10m
ssh_port: 22
ssh_username: packer
image_description: Travis CI Ubuntu 16.04
account_file: "{{ user `gce_account_file` }}"
project_id: "{{ user `gce_project_id` }}"
source_image_family: ubuntu-1604-lts
image_licenses: ["projects/vm-options/global/licenses/enable-vmx"]
zone: us-central1-a
image_name: "{{ user `image_name` }}"
image_family: "{{ user `image_family` }}"
machine_type: n1-standard-4
disk_size: 20
tags:
- ci
- ubuntu-1604
- travis-ci-packer-templates
- type: docker
name: docker
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-1604-normal-purge.txt
destination: /var/tmp/purge.txt
- type: file
source: packer-assets/ubuntu-1604-ci-packages.txt
destination: /var/tmp/packages.txt
only:
- googlecompute
- openstack
- type: file
source: packer-assets/ubuntu-xenial-ci-sardonyx-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
- 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/ubuntu-1604-system-info-commands.yml
destination: /var/tmp/ubuntu-1604-system-info-commands.yml
- type: shell
inline: chmod 0644 /var/tmp/ubuntu-1604-system-info-commands.yml
- type: chef-solo
version: 13.8.5
config_template: chef-solo.rb.tmpl
<% if ENV['CHEF_PROFILING'] %>
execute_command: "{{if .Sudo}}sudo {{end}}CI=yes chef-solo -F doc --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 %>
json:
travis_packer_build:
github_token: "{{ user `github_token` }}"
run_list:
- recipe[travis_ci_ubuntu_1604]
<% 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/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
- 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
4 changes: 4 additions & 0 deletions cookbooks/travis_ci_ubuntu_1604/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--color
--format documentation
--require support
--order rand
4 changes: 4 additions & 0 deletions cookbooks/travis_ci_ubuntu_1604/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
travis_ci_ubuntu_1604 Cookbook
=========================

A wrapper cookbook for the "ubuntu_1604" CI image.
Loading