├── .gitignore ├── README.md ├── coreos.json ├── files ├── box │ ├── Vagrantfile │ ├── change_host_name.rb │ └── configure_networks.rb ├── cloud-config.yml ├── coreos-setup-environment ├── install.yml └── vagrant ├── makefile └── scripts ├── cleanup.sh └── oem.sh /.gitignore: -------------------------------------------------------------------------------- 1 | builds/ 2 | packer_cache/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | coreos-packer 2 | ============= 3 | 4 | Packer.io templates for CoreOS. These are based on the following: 5 | 6 | - https://github.com/coreos/coreos-overlay/tree/master/coreos-base/oem-vagrant 7 | - https://github.com/YungSang/coreos-packer 8 | 9 | Currently only parallels and virtualbox are supported. 10 | 11 | Requirements 12 | ============ 13 | 14 | Parallels Desktop 10 15 | Parallels SDK 10 16 | PrlUtils from https://github.com/bassamtabbara/prl-utils 17 | 18 | 19 | Building 20 | ======== 21 | 22 | To build run the following: 23 | 24 | ``` 25 | packer build -parallel=false coreos.json 26 | ``` 27 | 28 | This will build coreos from the alpha channel. To build from other channels run: 29 | 30 | ``` 31 | packer build -parallel=false -var 'channel=beta' coreos.json 32 | ``` 33 | 34 | channel can be set to "stable", "beta" or "alpha". Default is "alpha". 35 | 36 | The -parallel=false is used to avoid a bug in packer (see https://github.com/mitchellh/packer/issues/1665) 37 | 38 | -------------------------------------------------------------------------------- /coreos.json: -------------------------------------------------------------------------------- 1 | { 2 | "builders": [ 3 | { 4 | "type": "qemu", 5 | "boot_command": [ 6 | "sudo -i", 7 | "systemctl stop sshd.socket", 8 | "wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.yml", 9 | "coreos-install -d /dev/sda -C {{user `channel`}} -c install.yml", 10 | "reboot" 11 | ], 12 | "accelerator": "kvm", 13 | "iso_checksum": "{{user `checksum`}}", 14 | "iso_checksum_type": "{{user `checksum_type`}}", 15 | "iso_url": "http://{{user `channel`}}.release.core-os.net/amd64-usr/{{user `version`}}/coreos_production_iso_image.iso", 16 | "http_directory": "files", 17 | "ssh_port": 22, 18 | "ssh_username": "core", 19 | "ssh_key_path": "files/vagrant", 20 | "ssh_wait_timeout": "10m", 21 | "disk_size": 4096, 22 | "format": "qcow2", 23 | "headless": true, 24 | "boot_wait": "10s", 25 | "shutdown_command": "sudo -S shutdown -P now", 26 | "output_directory": "builds/packer-coreos-{{user `channel`}}-{{user `version`}}-parallels" 27 | }, 28 | { 29 | "type": "parallels-iso", 30 | "vm_name": "coreos-{{user `channel`}}", 31 | 32 | "iso_checksum": "{{user `checksum`}}", 33 | "iso_checksum_type": "{{user `checksum_type`}}", 34 | "iso_url": "http://{{user `channel`}}.release.core-os.net/amd64-usr/{{user `version`}}/coreos_production_iso_image.iso", 35 | 36 | "http_directory": "files", 37 | 38 | "ssh_port": 22, 39 | "ssh_username": "core", 40 | "ssh_key_path": "files/vagrant", 41 | "ssh_wait_timeout": "10m", 42 | 43 | "guest_os_type": "linux-2.6", 44 | "hard_drive_interface": "sata", 45 | "disk_size": 40960, 46 | "prlctl": [ 47 | [ "set", "{{.Name}}", "--memsize", "1024" ], 48 | [ "set", "{{.Name}}", "--cpus", "1" ] 49 | ], 50 | "parallels_tools_mode": "disable", 51 | 52 | "boot_command": [ 53 | "sudo -i", 54 | "systemctl stop sshd.socket", 55 | "wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.yml", 56 | "coreos-install -d /dev/sda -C {{user `channel`}} -c install.yml", 57 | "reboot" 58 | ], 59 | "boot_wait": "10s", 60 | "shutdown_command": "sudo -S shutdown -P now", 61 | 62 | "output_directory": "builds/packer-coreos-{{user `channel`}}-{{user `version`}}-parallels", 63 | "prlctl_version_file": ".prlctl_version" 64 | }, 65 | { 66 | "type": "virtualbox-iso", 67 | "vm_name": "coreos-{{user `channel`}}", 68 | 69 | "iso_checksum": "{{user `checksum`}}", 70 | "iso_checksum_type": "{{user `checksum_type`}}", 71 | "iso_url": "http://{{user `channel`}}.release.core-os.net/amd64-usr/{{user `version`}}/coreos_production_iso_image.iso", 72 | 73 | "http_directory": "files", 74 | 75 | "ssh_port": 22, 76 | "ssh_username": "core", 77 | "ssh_key_path": "files/vagrant", 78 | "ssh_wait_timeout": "10m", 79 | 80 | "guest_os_type": "Linux26_64", 81 | "hard_drive_interface": "sata", 82 | "disk_size": 40960, 83 | "vboxmanage": [ 84 | [ "modifyvm", "{{.Name}}", "--memory", "1024" ], 85 | [ "modifyvm", "{{.Name}}", "--cpus", "1" ] 86 | ], 87 | "guest_additions_mode": "disable", 88 | 89 | "boot_command": [ 90 | "sudo -i", 91 | "systemctl stop sshd.socket", 92 | "wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.yml", 93 | "coreos-install -d /dev/sda -C {{user `channel`}} -c install.yml", 94 | "reboot" 95 | ], 96 | "boot_wait": "30s", 97 | "shutdown_command": "sudo -S shutdown -P now", 98 | 99 | "output_directory": "builds/packer-coreos-{{user `channel`}}-{{user `version`}}-virtualbox", 100 | "virtualbox_version_file": ".virtualbox_version" 101 | } 102 | ], 103 | "provisioners": [ 104 | { 105 | "type": "file", 106 | "source": "files/coreos-setup-environment", 107 | "destination": "coreos-setup-environment" 108 | }, 109 | { 110 | "type": "file", 111 | "source": "files/cloud-config.yml", 112 | "destination": "cloud-config.yml" 113 | }, 114 | { 115 | "type": "shell", 116 | "environment_vars" : [], 117 | "scripts": [ 118 | "scripts/oem.sh", 119 | "scripts/cleanup.sh" 120 | ] 121 | } 122 | ], 123 | "post-processors": [ 124 | { 125 | "type": "vagrant", 126 | "output": "./builds/{{.Provider}}/coreos-{{user `channel`}}.box", 127 | "vagrantfile_template": "files/box/Vagrantfile", 128 | "include": [ 129 | "files/box/change_host_name.rb", 130 | "files/box/configure_networks.rb" 131 | ] 132 | } 133 | ], 134 | "variables": { 135 | "channel": "alpha", 136 | "version": "current", 137 | "checksum_type": "md5", 138 | "checksum": "771552e66649f94cd7f61edda6b2fa50" 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /files/box/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # # vi: set ft=ruby : 3 | 4 | if Vagrant::VERSION < "1.6.0" 5 | raise "Need at least vagrant version 1.6.0, please update" 6 | end 7 | 8 | require_relative 'change_host_name.rb' 9 | require_relative 'configure_networks.rb' 10 | 11 | Vagrant.configure("2") do |config| 12 | # SSH in as the default 'core' user, it has the vagrant ssh key. 13 | config.ssh.username = "core" 14 | 15 | # Disable the base shared folder, guest additions are unavailable. 16 | config.vm.synced_folder ".", "/vagrant", disabled: true 17 | 18 | config.vm.provider :virtualbox do |vb| 19 | # Guest Additions are unavailable. 20 | vb.check_guest_additions = false 21 | vb.functional_vboxsf = false 22 | vb.gui = false 23 | 24 | # Fix docker not being able to resolve private registry in VirtualBox 25 | vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] 26 | vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] 27 | end 28 | 29 | config.vm.provider :vmware_fusion do |vf| 30 | vf.functional_hgfs = false 31 | end 32 | 33 | config.vm.provider :parallels do |prl| 34 | # Guest Tools are unavailable. 35 | prl.check_guest_tools = false 36 | prl.functional_psf = false 37 | prl.regen_box_uuid = true 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /files/box/change_host_name.rb: -------------------------------------------------------------------------------- 1 | 2 | # -*- mode: ruby -*- 3 | # # vi: set ft=ruby : 4 | 5 | # NOTE: This monkey-patching of the coreos guest plugin is a terrible 6 | # hack that needs to be removed once the upstream plugin works with 7 | # alpha CoreOS images. 8 | 9 | require 'tempfile' 10 | require Vagrant.source_root.join("plugins/guests/coreos/cap/change_host_name.rb") 11 | 12 | CLOUD_CONFIG = <> "$ENV" 40 | echo "COREOS_PRIVATE_IPV4=$2" >> "$ENV" 41 | } 42 | 43 | ifaces=$(get_interfaces) 44 | sleep 1 # just sleep 1s to make sure 45 | ifaces=$(get_interfaces) 46 | ifaces=($ifaces) 47 | 48 | private_ipv4=$(get_ipv4 ${ifaces[0]}) 49 | 50 | if [ -z "${ifaces[1]}" ]; then 51 | echo "No network configuration provided by Vagrant!" >&2 52 | echo "Using ${private_ipv4}, for public and private IPs" >&2 53 | set_coreos_ipv4 "${private_ipv4}" "${private_ipv4}" 54 | exit 55 | fi 56 | 57 | now=$(date +%s) 58 | timeout=$(( now + 60 )) 59 | 60 | # just block until cloudinit updates environment 61 | while ! grep -qs ^COREOS_PUBLIC_IPV4 "$ENV"; do 62 | if [[ $timeout -lt $(date +%s) ]]; then 63 | echo "No network configuration provided by Vagrant!" >&2 64 | echo "Using ${private_ipv4}, for public and private IPs" >&2 65 | set_coreos_ipv4 "${private_ipv4}" "${private_ipv4}" 66 | exit 67 | fi 68 | sleep 0.1 69 | done 70 | -------------------------------------------------------------------------------- /files/install.yml: -------------------------------------------------------------------------------- 1 | #cloud-config 2 | ssh_authorized_keys: 3 | - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key 4 | -------------------------------------------------------------------------------- /files/vagrant: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI 3 | w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP 4 | kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 5 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vU6Fp9w+NOFD/HvxB3Tcz 21 | 6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC 22 | P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF 23 | llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ 24 | kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH 25 | +vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ 26 | NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= 27 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | VERSION_ID := 1.0.0 2 | CHANNEL := alpha 3 | 4 | FILES = \ 5 | files/box/change_host_name.rb \ 6 | files/box/configure_networks.rb \ 7 | files/box/Vagrantfile \ 8 | files/cloud-config.yml \ 9 | files/coreos-setup-environment \ 10 | files/install.yml \ 11 | files/vagrant 12 | 13 | box: coreos.json builds/parallels/coreos-$(CHANNEL).box builds/virtualbox/coreos-$(CHANNEL).box $(FILES) 14 | 15 | builds/parallels/coreos-$(CHANNEL).box: 16 | packer build -only=parallels-iso coreos.json 17 | 18 | builds/virtualbox/coreos-$(CHANNEL).box: 19 | packer build -only=virtualbox-iso coreos.json 20 | 21 | install: builds/parallels/coreos-$(CHANNEL).box builds/virtualbox/coreos-$(CHANNEL).box 22 | vagrant box add --force --provider=parallels --name bassamtabbara/coreos-$(CHANNEL) builds/parallels/coreos-$(CHANNEL).box 23 | vagrant box add --force --provider=virtualbox --name bassamtabbara/coreos-$(CHANNEL) builds/virtualbox/coreos-$(CHANNEL).box 24 | 25 | clean: 26 | rm -fr builds 27 | rm -fr packer_cache 28 | 29 | .PHONY: box clean 30 | -------------------------------------------------------------------------------- /scripts/cleanup.sh: -------------------------------------------------------------------------------- 1 | # remove the machine id. it will be regenerated on first boot. 2 | sudo rm -fr /etc/machine-id 3 | -------------------------------------------------------------------------------- /scripts/oem.sh: -------------------------------------------------------------------------------- 1 | sudo mv ~/coreos-setup-environment /usr/share/oem 2 | sudo chmod +x /usr/share/oem/coreos-setup-environment 3 | sudo mv ~/cloud-config.yml /usr/share/oem --------------------------------------------------------------------------------