-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
freebsd13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
variable "base_image" { | ||
type = string | ||
} | ||
|
||
variable "output_dir" { | ||
type = string | ||
} | ||
|
||
variable "appliance_name" { | ||
type = string | ||
default = "freebsd" | ||
} | ||
|
||
variable "password" { | ||
type = string | ||
default = "opennebula" | ||
} | ||
|
||
variable "http_dir" { | ||
type = string | ||
} | ||
|
||
variable "qemu_binary" { | ||
type = string | ||
} | ||
|
||
|
||
source "qemu" "freebsd" { | ||
boot_command = [ | ||
"I<wait>", # Welcome: Install | ||
"<enter><wait>", # Keymap Selection: Continue with default | ||
|
||
"localhost", # Set hostname | ||
"<enter><wait>", | ||
|
||
"<enter><wait>", # Distribution Select, OK | ||
|
||
"<enter><wait>", # Partitioning Auto (UFS) | ||
"E<wait>", # Entire Disk | ||
"G<enter><wait>", # GPT | ||
"<down><down><down>D<wait>", # Delete swap partition | ||
"M<wait>", # Modify second partition | ||
"<tab><tab><down><down>rootfs<enter><wait>", # Set rootfs label on root partition | ||
"F<wait>", # Finish | ||
"C<wait>", # Commit | ||
|
||
"<wait2m30s>", | ||
|
||
"opennebula<enter><wait>", # Root password | ||
"opennebula<enter><wait>", | ||
|
||
"<enter><wait>", # Network Configuration vtnet0 | ||
"Y<wait>", # IPv4 yes | ||
"Y<wait10>", # DHCP yes | ||
"N<wait>", # IPv6 no | ||
"<enter><wait>", # Resolver configuration | ||
|
||
"0<enter><wait>", # Time Zone Selector: UTC + Time&Date | ||
"Y<wait>", # Confirm | ||
"S<wait>", # Skip date | ||
"S<wait>", # Skip time | ||
|
||
"<enter><wait>", # System Configuration, OK | ||
|
||
"<enter><wait>", # System Hardening, OK | ||
|
||
"N<wait>", # Add User Accounts, no | ||
|
||
"E<enter><wait10>", # Final Configuration, Exit | ||
|
||
"Y<wait>", # Manual configuration, Yes | ||
"sed -i '' -e 's/^#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config<enter><wait>", | ||
"sed -i '' -e 's/^#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config<enter><wait>", | ||
"sed -i '' -e 's/^.*\\([[:space:]]\\/[[:space:]]\\)/\\/dev\\/gpt\\/rootfs\\1/' /etc/fstab<enter><wait>", | ||
"sync<enter>exit<enter><wait>", | ||
"R<wait10>" # Complete: Reboot | ||
] | ||
|
||
boot_wait = "45s" | ||
disk_cache = "unsafe" | ||
disk_compression = true | ||
disk_interface = "virtio" | ||
disk_size = 4096 | ||
format = "qcow2" | ||
headless = false | ||
|
||
http_directory = "${var.http_dir}" | ||
|
||
iso_checksum = "none" | ||
iso_url = "${var.base_image}" | ||
|
||
net_device = "virtio-net" | ||
qemu_binary = "${var.qemu_binary}" | ||
qemuargs = [ | ||
["-cpu", "host"], | ||
["-serial", "stdio"], | ||
] | ||
ssh_password = "${var.password}" | ||
ssh_port = 22 | ||
ssh_username = "root" | ||
ssh_wait_timeout = "10000s" | ||
|
||
shutdown_command = "poweroff" | ||
|
||
output_directory = "${var.output_dir}" | ||
vm_name = "${var.appliance_name}" | ||
} | ||
|
||
build { | ||
sources = ["source.qemu.freebsd"] | ||
|
||
# Be carefull with shell inline provisioners, FreeBSD csh is tricky | ||
|
||
provisioner "shell" { | ||
execute_command = "chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}" | ||
scripts = ["${var.http_dir}/mkdir.sh"] | ||
} | ||
|
||
provisioner "file" { | ||
destination = "/tmp/context" | ||
source = "context-linux/out/" | ||
} | ||
|
||
provisioner "shell" { | ||
execute_command = "chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}" | ||
scripts = ["${var.http_dir}/freebsd.sh"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters