Bootstrap Packer template for libvirt and Vbox
Signed-off-by: Gianluca Arbezzano <gianarb92@gmail.com>
This commit is contained in:
		
							
								
								
									
										1
									
								
								deploy/vagrant/basebox/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								deploy/vagrant/basebox/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| output* | ||||
							
								
								
									
										30
									
								
								deploy/vagrant/basebox/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								deploy/vagrant/basebox/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| This directory contains a provisioning mechanism for the Vagrant boxes we ship | ||||
| as part of Sandbox. | ||||
|  | ||||
| In order to self contain and distribute the required dependencies for Tinkerbell | ||||
| and Sandbox without having to download all of them runtime we decided to use | ||||
| [Packer.io](https://packer.io) to build boxes that you can use when provisioning | ||||
| Tinkerbell on Vagrant. | ||||
|  | ||||
| Currently the generated boxes are available via [Vagrant | ||||
| Cloud](https://app.vagrantup.com/tinkerbelloss). | ||||
|  | ||||
| --- | ||||
|  | ||||
| ## Build | ||||
|  | ||||
| To build the boxes checkout the right directory and run | ||||
|  | ||||
| ```terminal | ||||
| $ packer build --parallel-builds=1 ./template.json | ||||
| ``` | ||||
|  | ||||
| `-parallel-builds=1` is required because the template builds images for multiple | ||||
| providers using the [Vagrant | ||||
| builder](https://www.packer.io/docs/builders/vagrant) and I didn't manage to get | ||||
| it to work in parallel yet. | ||||
|  | ||||
| ## Deploy to Vagrant Cloud | ||||
|  | ||||
| I didn't find a way to make the Vagrant Cloud post processor to work. But I use | ||||
| the vagrant cli `vagrant cloud publish` command. | ||||
							
								
								
									
										47
									
								
								deploy/vagrant/basebox/ubuntu1804/provision.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								deploy/vagrant/basebox/ubuntu1804/provision.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| #!/bin/bash | ||||
| # abort this script on errors | ||||
| set -euxo pipefail | ||||
|  | ||||
| setup_docker() ( | ||||
| 	# steps from https://docs.docker.com/engine/install/ubuntu/ | ||||
| 	sudo apt-get install -y \ | ||||
| 		apt-transport-https \ | ||||
| 		ca-certificates \ | ||||
| 		curl \ | ||||
| 		gnupg-agent \ | ||||
| 		software-properties-common | ||||
|  | ||||
| 	curl -fsSL https://download.docker.com/linux/ubuntu/gpg | | ||||
| 		sudo apt-key add - | ||||
|  | ||||
| 	local repo | ||||
| 	repo=$( | ||||
| 		printf "deb [arch=amd64] https://download.docker.com/linux/ubuntu %s stable" \ | ||||
| 			"$(lsb_release -cs)" | ||||
| 	) | ||||
| 	sudo add-apt-repository "$repo" | ||||
|  | ||||
| 	sudo apt-get update | ||||
| 	sudo apt-get install -y docker-ce docker-ce-cli containerd.io | ||||
| ) | ||||
|  | ||||
| setup_docker_compose() ( | ||||
| 	# from https://docs.docker.com/compose/install/ | ||||
| 	sudo curl -L \ | ||||
| 		"https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" \ | ||||
| 		-o /usr/local/bin/docker-compose | ||||
|  | ||||
| 	sudo chmod +x /usr/local/bin/docker-compose | ||||
| ) | ||||
|  | ||||
| main() ( | ||||
| 	export DEBIAN_FRONTEND=noninteractive | ||||
|  | ||||
| 	sudo apt-get update | ||||
| 	setup_docker | ||||
| 	setup_docker_compose | ||||
| 	sudo apt-get install -y jq | ||||
| 	sudo usermod -aG docker vagrant | ||||
| ) | ||||
|  | ||||
| main | ||||
							
								
								
									
										27
									
								
								deploy/vagrant/basebox/ubuntu1804/template.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								deploy/vagrant/basebox/ubuntu1804/template.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| { | ||||
|   "builders": [ | ||||
|     { | ||||
|       "communicator": "ssh", | ||||
|       "name": "vagrant-virtualbox", | ||||
|       "provider": "virtualbox", | ||||
|       "source_path": "generic/ubuntu1804", | ||||
|       "type": "vagrant" | ||||
|     }, | ||||
|     { | ||||
|       "communicator": "ssh", | ||||
|       "name": "vagrant-libvirt", | ||||
|       "provider": "libvirt", | ||||
|       "source_path": "generic/ubuntu1804", | ||||
|       "type": "vagrant" | ||||
|     } | ||||
|   ], | ||||
|   "provisioners": [ | ||||
|     { | ||||
|       "script": "provision.sh", | ||||
|       "type": "shell" | ||||
|     } | ||||
|   ], | ||||
|   "variables": { | ||||
|     "cloud_token": "{{ env `VAGRANT_CLOUD_TOKEN` }}" | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Gianluca Arbezzano
					Gianluca Arbezzano