diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d35d190 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +## IDE files +.idea/ +## Packer artifacts +packer_cache/ +output-virtualbox-iso/ +*.box +# Vagrant files +.vagrant/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..b7059a8 --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# RancherOS + +Due to not being able to install VBox Extensions, this box may require setting the following in your Vagrantfile - The base Vagrantfile should already do this for you by default. + +``` +# Disable synced folder due to not being able to install VBox Extensions +config.vm.synced_folder ".", "/vagrant", disabled: true +# For now, until I can get a 'vagrant user' working +config.ssh.username = "rancher" +``` + +The default SSH Key has been set up for `vagrant ssh` to allow hacking via the the shell script provisioner. + +Box versions will match the OS version, with `alpha/beta/pre` reserved for hacking \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..763004b --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,78 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "MatthewHartstonge/RancherOS" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Disable synced folder due to not being able to install VBox Extensions in busybox + config.vm.synced_folder ".", "/vagrant", disabled: true + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies + # such as FTP and Heroku are also available. See the documentation at + # https://docs.vagrantup.com/v2/push/atlas.html for more information. + # config.push.define "atlas" do |push| + # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" + # end + + # Enable provisioning with a shell script. Additional provisioners such as + # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL + + # SSH Configuration + config.ssh.username = "rancher" + config.ssh.keys_only = true +end diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..abc11be --- /dev/null +++ b/build.bat @@ -0,0 +1,4 @@ +@ECHO OFF +SET VM_DESCRIPTION=A simplified Linux distribution built from containers, for containers +SET VM_VERSION=1.0.0 +packer build -force -var "vm_description=%VM_DESCRIPTION%" -var "vm_version=%VM_VERSION%" "packer_rancheros.json" diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..1c546fd --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +vm_description='A simplified Linux distribution built from containers, for containers' +vm_version='1.0.0' +packer build \ + -var "vm_description=${vm_description}" \ + -var "vm_version=${vm_version}" \ + "packer_rancheros.json" diff --git a/conf/cloud-config.yml b/conf/cloud-config.yml new file mode 100644 index 0000000..827209f --- /dev/null +++ b/conf/cloud-config.yml @@ -0,0 +1,20 @@ +#cloud-config +ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key +users: + - name: "vagrant" + # Set a default password of 'vagrant' + passwd: "$6$rounds=4096$TRz4pW9gdPU$wsGte5ncb2c.GFhdvDxghtn6Jep/2gAbrsdlQreJHdJAtLLaZVEwpsoJ1PvE6CpmkWn9QqRJ3SpqlSVaGS2Zr0" + groups: + - "sudo" + - "docker" + ssh-authorized-keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key +#rancher: +# services: +# rancher-server: +# image: rancher/server:stable +# # command: --db-host 127.0.0.1 --db-port 3306 --db-user cattle --db-pass cattle --db-name cattle +# restart: always +# ports: +# - "8080:8080" diff --git a/conf/rancheros-meta.yml b/conf/rancheros-meta.yml new file mode 100644 index 0000000..badccc3 --- /dev/null +++ b/conf/rancheros-meta.yml @@ -0,0 +1,10 @@ +- 1.0.0: + url: https://releases.rancher.com/os/v1.0.0/rancheros.iso + checksums: + md5: b0e3e198a12a2ae8efe89f5167655879 + sha256: 7259e55e4bd249c35a36b3a1c4fe41d6ebb59df5740211ccbf2423e9f7dae855 +- 0.9.1: + url: https://releases.rancher.com/os/v0.9.1/rancheros.iso + checksums: + md5: 02a98f2105ef29ca61b647399bc44f78 + sha256: f541af7c9e6616dcdeb702b194d38af75903ef996e86d91874ffd26ea28bb5e8 diff --git a/keys/README.md b/keys/README.md new file mode 100644 index 0000000..c900682 --- /dev/null +++ b/keys/README.md @@ -0,0 +1,10 @@ +# Insecure Keypair + +These keys are the "insecure" public/private keypair we offer to +[base box creators](https://www.vagrantup.com/docs/boxes/base.html) for use in their base boxes so that +vagrant installations can automatically SSH into the boxes. + +If you're working with a team or company or with a custom box and +you want more secure SSH, you should create your own keypair +and configure the private key in the Vagrantfile with +`config.ssh.private_key_path` diff --git a/keys/vagrant b/keys/vagrant new file mode 100644 index 0000000..7d6a083 --- /dev/null +++ b/keys/vagrant @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI +w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP +kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 +hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO +Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW +yLbIbEgE98O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Qsz+xT2axM0/W/CRknmGaJ +kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH ++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ +NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= +-----END RSA PRIVATE KEY----- diff --git a/keys/vagrant.ppk b/keys/vagrant.ppk new file mode 100644 index 0000000..58b9309 --- /dev/null +++ b/keys/vagrant.ppk @@ -0,0 +1,26 @@ +PuTTY-User-Key-File-2: ssh-rsa +Encryption: none +Comment: vagrant insecure public key +Public-Lines: 6 +AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+k +z4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO +KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4 +O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGj +yiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPK +cF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== +Private-Lines: 14 +AAABAQDiKpY8le3NkDryYp0QuziMmx3KTL57B1l412zm2NycdTnNRgTbkr598kQP +2pRYgJwtkNzzVMZaMfICoPUHDtemBTAWB5QnBSXNC6sC/7/JKfGLC5oYl+EUzUJp +AfN9emGBWaX59lS+clRO/N9MrYuDoR1tQT1NqtSUF//E9+4SExKUgTmR5v9nPf8t +SVGDzIOrPnD5BZUni62cqcqKrBk3SbCnBTthLImGVPhhXUXefhiMuzAznAmzaiqb +SOyxC78FPS3IRc0NgEsQXgCwKVpa5InaSOrsqGuthfNqCqGdJ6L04NgVKEm7xRZV +5zciFvlleXM7q901DUn1ex/ib7bLAAAAgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/ +orApiHmHDsURs5rUKDx0f9iPcXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsM +kE4CUSiJcYrMANtx54cGH7RkEjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTG +yAK+OLD3M2QdCQAAAIEA7cfKTQgMUe8oR2yFk9QB+uvl1jfG16u5d0Tv7pHmnIvf +CX5G5MVEWYbcVfxx7r1IZzy3V908MoDwWGRTaOKc1RIc1qE7ZxLaxbniscnN/i42 +abqPpgZUOjkbX4JK/YAVaYV2RmBM5Ag95VXZfC+HMPQVaSqyQrNXObWhow4HSJ0A +AACANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH+vq/ +5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQNE5O +gEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= +Private-MAC: 7e88d78e4843aa189575dd8214a9607a8dda3b14 diff --git a/keys/vagrant.pub b/keys/vagrant.pub new file mode 100644 index 0000000..18a9c00 --- /dev/null +++ b/keys/vagrant.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key diff --git a/packer_rancheros.json b/packer_rancheros.json new file mode 100644 index 0000000..ba927ee --- /dev/null +++ b/packer_rancheros.json @@ -0,0 +1,77 @@ +{ + "variables": { + "vm_description": "", + "vm_version": "" + }, + "builders": [ + { + "type": "virtualbox-iso", + "guest_os_type": "Linux26_64", + "iso_url": "https://releases.rancher.com/os/v1.0.0/rancheros.iso", + "iso_checksum": "b0e3e198a12a2ae8efe89f5167655879", + "iso_checksum_type": "md5", + "guest_additions_mode": "disable", + "ssh_private_key_file": "./keys/vagrant", + "ssh_username": "rancher", + "ssh_wait_timeout": "360s", + "hard_drive_interface": "sata", + "hard_drive_nonrotational": true, + "iso_interface": "sata", + "vm_name": "rancherOS", + "disk_size": "24000", + "boot_wait": "30s", + "boot_command": [ + "echo \"#cloud-config \" >> cloud-config.yml", + "echo \"ssh_authorized_keys: \" >> cloud-config.yml", + "echo \" - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key \" >> cloud-config.yml", + "sudo ros install -c cloud-config.yml -d /dev/sda", + "y", + "", + "y", + "" + ], + "shutdown_command": "sudo shutdown -h now", + "export_opts": [ + "--manifest", + "--vsys", "0", + "--description", "{{user `vm_description`}}", + "--version", "{{user `vm_version`}}.alpha1" + ], + "vboxmanage": [ + [ + "modifyvm", + "{{.Name}}", + "--memory", + "1024" + ], + [ + "modifyvm", + "{{.Name}}", + "--cpus", + "1" + ] + ] + } + ], + "post-processors": [ + [ + { + "type": "vagrant", + "compression_level": 9, + "keep_input_artifact": false, + "output":"RancherOS_{{user `vm_version`}}.box", + "vagrantfile_template": "./Vagrantfile" + }, + { + "type": "atlas", + "only": ["virtualbox-iso"], + "artifact": "MatthewHartstonge/RancherOS", + "artifact_type": "vagrant.box", + "metadata": { + "provider": "virtualbox", + "version": "{{user `vm_version`}}.alpha1" + } + } + ] + ] +}