Skip to content

Add files for VirtualBox #1

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 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div align="center">
<img src="https://imagineer.in/assets/img/posts/packer-ubuntu.png" alt="logo" width="350px" style="margin-top: 1em">
<h1>Packer for Ubuntu server</h1>
<h4>Packer config to build VMware virtual machines (VMX) from Ubuntu 20.04 server ISO file as a source.</h4>
<h4>Packer config to build VMware virtual machines (VMX) and VirtualBox machines (OVF) from Ubuntu 20.04 server ISO file as a source.</h4>
</div><br>

## Ubuntu 20.04 Server
## Ubuntu 20.04 Server (VMWare)

Run packer build:

Expand All @@ -13,7 +13,7 @@ $ packer build -on-error=ask -force ubuntu-20.04-live-server-packer.json
```


## Ubuntu 20.04 Legacy Server
## Ubuntu 20.04 Legacy Server (VMWare)

Run packer build:
```bash
Expand All @@ -22,3 +22,31 @@ $ packer build -on-error=ask -force ubuntu-20.04-legacy-server-packer.json
<br>

For more info: [imagineer.in/blog/packer-build-for-ubuntu-20-04](https://imagineer.in/blog/packer-build-for-ubuntu-20-04/)


## Ubuntu 20.04 Server (VirtualBox)
packer version 1.6.5

Run packer build:

```bash
$ packer build -on-error=ask -force ubuntu-20.04-live-server-packer-virtualbox.json
```

## Ubuntu 20.04 Legacy Server (VirtualBox)
packer version 1.6.5

Run packer build:

```bash
$ packer build -on-error=ask -force ubuntu-20.04-legacy-server-packer-virtualbox.json
```

## Ubuntu 20.04 Server with Java and Jenkins (VirtualBox)
packer version 1.6.5

Run packer build:

```bash
$ packer build -on-error=ask -force ubuntu-20.04-live-server-packer-virtualbox-jenkins.json
```
7 changes: 7 additions & 0 deletions virtualbox/scripts/jenkins_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install -y openjdk-8-jdk
sudo apt-get install -y jenkins
File renamed without changes.
27 changes: 27 additions & 0 deletions virtualbox/subiquity/http/user-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#cloud-config
autoinstall:
version: 1
locale: en_US
keyboard:
layout: en
variant: us
network:
network:
version: 2
ethernets:
enp0s3:
dhcp4: true
storage:
layout:
name: lvm
identity:
hostname: ubuntu
username: ubuntu
password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
ssh:
install-server: yes
user-data:
disable_root: false
late-commands:
- 'sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml'
- echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu
45 changes: 45 additions & 0 deletions virtualbox/ubuntu-20.04-legacy-server-packer-virtualbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"builders": [
{
"boot_command": [
"<esc><wait>",
"<esc><wait>",
"<enter><wait>",
"/install/vmlinuz<wait>",
" initrd=/install/initrd.gz",
" auto-install/enable=true",
" debconf/priority=critical",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
" -- <wait>",
"<enter><wait>"
],
"boot_wait": "5s",
"guest_os_type": "ubuntu-64",
"http_directory": "debian-installer/http",
"iso_checksum": "sha256:f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2",
"iso_urls": [
"iso/ubuntu-20.04.1-legacy-server-amd64.iso",
"http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04.1-legacy-server-amd64.iso"
],
"memory": 1024,
"name": "ubuntu-20.04-legacy-server",
"output_directory": "output/live-server",
"shutdown_command": "sudo shutdown -P now",
"ssh_handshake_attempts": "20",
"ssh_password": "ubuntu",
"ssh_pty": true,
"ssh_timeout": "20m",
"ssh_username": "ubuntu",
"type": "virtualbox-iso"
}
],
"provisioners": [
{
"inline": [
"ls /"
],
"type": "shell"
}
]
}

38 changes: 38 additions & 0 deletions virtualbox/ubuntu-20.04-live-server-packer-virtualbox-jenkins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"builders": [
{
"boot_command": [
"<enter><enter><f6><esc><wait> ",
"autoinstall ds=nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"<enter><wait>"
],
"boot_wait": "5s",
"guest_os_type": "ubuntu-64",
"http_directory": "subiquity/http",
"iso_checksum": "sha256:443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93",
"iso_urls": [
"iso/ubuntu-20.04.1-live-server-amd64.iso",
"https://releases.ubuntu.com/focal/ubuntu-20.04.1-live-server-amd64.iso"
],
"memory": 1024,
"name": "ubuntu-20.04-live-server",
"output_directory": "output/live-server-subiquty-jenkins",
"shutdown_command": "sudo shutdown -P now",
"type": "virtualbox-iso",
"ssh_username": "ubuntu",
"ssh_password": "ubuntu",
"ssh_pty": true,
"ssh_timeout": "20m",
"ssh_handshake_attempts": "100"
}
],
"provisioners": [
{
"type": "shell",
"scripts": [
"./scripts/jenkins_install.sh"
]
}
]
}

38 changes: 38 additions & 0 deletions virtualbox/ubuntu-20.04-live-server-packer-virtualbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"builders": [
{
"boot_command": [
"<enter><enter><f6><esc><wait> ",
"autoinstall ds=nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"<enter><wait>"
],
"boot_wait": "5s",
"guest_os_type": "ubuntu-64",
"http_directory": "subiquity/http",
"iso_checksum": "sha256:443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93",
"iso_urls": [
"iso/ubuntu-20.04.1-live-server-amd64.iso",
"https://releases.ubuntu.com/focal/ubuntu-20.04.1-live-server-amd64.iso"
],
"memory": 1024,
"name": "ubuntu-20.04-live-server",
"output_directory": "output/live-server-subiquty",
"shutdown_command": "sudo shutdown -P now",
"type": "virtualbox-iso",
"ssh_username": "ubuntu",
"ssh_password": "ubuntu",
"ssh_pty": true,
"ssh_timeout": "20m",
"ssh_handshake_attempts": "100"
}
],
"provisioners": [
{
"inline": [
"ls /"
],
"type": "shell"
}
]
}

64 changes: 64 additions & 0 deletions vmware/debian-installer/http/preseed.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Localization
d-i debian-installer/locale string en_US.UTF-8

# Clock and time zone setup
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i time/zone string UTC

# Keyboard selection.
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/modelcode string pc105
d-i console-setup/ask_detect boolean false

# Base system installation
d-i base-installer/kernel/override-image string linux-server

# Finishing up the installation
d-i finish-install/reboot_in_progress note

# Boot loader installation
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true

# Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true

# Mirror settings
choose-mirror-bin mirror/http/proxy string
d-i mirror/country string manual
d-i mirror/http/directory string /ubuntu/
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/proxy string

# Package selection
tasksel tasksel/first standard
d-i pkgsel/include string openssh-server build-essential
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select full-upgrade

# Account setup
d-i passwd/user-fullname string ubuntu
d-i passwd/username string ubuntu
d-i passwd/user-password password ubuntu
d-i passwd/user-password-again password ubuntu
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i passwd/user-default-groups ubuntu sudo

# Running custom commands during the installation
d-i preseed/late_command string \
echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/ubuntu ; \
in-target /bin/chmod 440 /etc/sudoers.d/ubuntu
Empty file added vmware/subiquity/http/meta-data
Empty file.
File renamed without changes.