Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
s12v committed Apr 2, 2016
1 parent 14dd2d5 commit 983402c
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output-virtualbox-iso/
packer_cache/
*.box
19 changes: 19 additions & 0 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- hosts: all
become: true
tasks:

- name: Install provisioners
apt: name={{ item }} state=present
with_items:
- puppet
- chef

- name: Vagrant insecure key
authorized_key: user=vagrant key=https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub

- name: Insert "UseDNS no" into sshd_config
blockinfile:
dest: /etc/ssh/sshd_config
block: |
UseDNS no
27 changes: 27 additions & 0 deletions http/preseed.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
d-i time/zone string UTC
d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us

d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

d-i passwd/root-password-again password vagrant
d-i passwd/root-password password vagrant
d-i passwd/user-fullname string vagrant
d-i passwd/username string vagrant
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i user-setup/allow-password-weak boolean true

d-i netcfg/hostname string xenial64

d-i pkgsel/include string openssh-server sudo

d-i preseed/late_command string \
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/vagrant; \
in-target chmod 440 /etc/sudoers.d/vagrant;

d-i finish-install/reboot_in_progress note
12 changes: 12 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt install -y ansible linux-headers-$(uname -r) build-essential dkms

sudo mkdir /media/VBoxGuestAdditions
sudo mount -o loop,ro /home/vagrant/VBoxGuestAdditions.iso /media/VBoxGuestAdditions
sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run
sudo umount /media/VBoxGuestAdditions
sudo rmdir /media/VBoxGuestAdditions
rm /home/vagrant/VBoxGuestAdditions.iso
82 changes: 82 additions & 0 deletions template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"builders": [
{
"type": "virtualbox-iso",
"guest_os_type": "Ubuntu_64",
"iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04-beta2-server-amd64.iso",
"iso_checksum": "0f948fea5a587a62a873d2c001948a6ffbda20b67b05a468006caf9dfd41bcd7",
"iso_checksum_type": "sha256",
"vm_name": "packer-ubuntu-16.04-amd64",
"disk_size": "{{ user `disk_size` }}",
"headless": "{{ user `headless` }}",
"boot_wait": "5s",
"http_directory": "http",
"boot_command": [
"<enter><wait>",
"<f6><esc>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
"<bs><bs><bs>",
"/install/vmlinuz ",
"initrd=/install/initrd.gz ",
"auto=true ",
"priority=critical ",
"url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
"<wait><enter>"
],
"ssh_wait_timeout": "30m",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"shutdown_command": "sudo systemctl poweroff",
"vboxmanage": [
["modifyvm", "{{ .Name }}", "--memory", "{{ user `memory` }}"],
["modifyvm", "{{ .Name }}", "--cpus", "{{ user `cpus` }}"]
]
}
],
"provisioners": [
{
"type": "shell",
"scripts": "scripts/install.sh"
},
{
"type": "ansible-local",
"playbook_file": "ansible/playbook.yml",
"playbook_dir": "ansible"
}
],
"post-processors": [
[
{
"type": "vagrant",
"compression_level": 9,
"output": "ubuntu-16.04-amd64.box",
"keep_input_artifact": false
},
{
"type": "atlas",
"artifact": "s12v/xenial64",
"artifact_type": "vagrant.box",
"metadata": {
"version": "20160401",
"description": "**Ubuntu 16.04 beta 2**. Baked with https://github.com/s12v/xenial\n - Ansible, Puppet, Chef\n - VBoxGuestAdditions 5.0.x\n - 80G disk",
"created_at": "{{timestamp}}",
"provider": "virtualbox"
}
}
]
],
"variables": {
"cpus": "1",
"memory": "512",
"hostname": "xenial",
"headless": "false",
"disk_size": "81920"
}
}

0 comments on commit 983402c

Please sign in to comment.