Compare commits
8 Commits
a7330ce9e7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53a3a86403 | ||
|
|
ba48937b12 | ||
|
|
6603cc9518 | ||
|
|
13433cd7eb | ||
|
|
9c075ea2f3 | ||
|
|
ff22a6dda6 | ||
|
|
ed10ea5bab | ||
|
|
1d64683963 |
@@ -28,7 +28,10 @@ To get started with **skz-opack**, follow these steps:
|
|||||||
- [libvirt](https://libvirt.org/)
|
- [libvirt](https://libvirt.org/)
|
||||||
- [Vagrant](https://developer.hashicorp.com/vagrant/downloads)
|
- [Vagrant](https://developer.hashicorp.com/vagrant/downloads)
|
||||||
- [Vagrant-Libvirt module](https://github.com/vagrant-libvirt/vagrant-libvirt)
|
- [Vagrant-Libvirt module](https://github.com/vagrant-libvirt/vagrant-libvirt)
|
||||||
- [Terraform](https://developer.hashicorp.com/terraform/downloads) (for `opack-cloud`)
|
|
||||||
|
Additionally, for `opack-cloud`:
|
||||||
|
- [Packer googlecompute module](https://developer.hashicorp.com/packer/integrations/hashicorp/googlecompute)
|
||||||
|
- [Terraform](https://developer.hashicorp.com/terraform/downloads)
|
||||||
|
|
||||||
3. Use the project by including `path/to/skz-opack/src/opack.mk` and invoking the `opack` target in your Makefile to create a local OpenBSD virtual machine with Packer and Vagrant. Use the 'opack-cloud' target to run the same virtual machine in GCP with Terraform.
|
3. Use the project by including `path/to/skz-opack/src/opack.mk` and invoking the `opack` target in your Makefile to create a local OpenBSD virtual machine with Packer and Vagrant. Use the 'opack-cloud' target to run the same virtual machine in GCP with Terraform.
|
||||||
|
|
||||||
@@ -68,6 +71,7 @@ Every default option ending with an `?` in "src/options.mk" can be overrided in
|
|||||||
- `OPACK_GCE_PROJECT`: The Google Cloud project name where the VM will be created
|
- `OPACK_GCE_PROJECT`: The Google Cloud project name where the VM will be created
|
||||||
- `OPACK_GCE_JSON_KEY`: The filename of the Google Cloud service account JSON key
|
- `OPACK_GCE_JSON_KEY`: The filename of the Google Cloud service account JSON key
|
||||||
- `OPACK_GCE_BUCKET`: The Google Cloud Storage bucket name to use for the image import
|
- `OPACK_GCE_BUCKET`: The Google Cloud Storage bucket name to use for the image import
|
||||||
|
- `OPACK_VAGRANT_NETWORK`: Define additional custom Vagrant networks
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ endef
|
|||||||
|
|
||||||
define OPACK_INSTALL_CLOUD_CONTENT =
|
define OPACK_INSTALL_CLOUD_CONTENT =
|
||||||
Choose your keyboard layout = fr
|
Choose your keyboard layout = fr
|
||||||
System hostname = $(OPACK_SYS_HOSTNAME)-$(OPACK_TARGET)
|
System hostname = $(OPACK_SYS_HOSTNAME)
|
||||||
Which network interface = vio0
|
Which network interface = vio0
|
||||||
IPv4 address for vio0 = dhcp
|
IPv4 address for vio0 = dhcp
|
||||||
IPv6 address for vio0 = none
|
IPv6 address for vio0 = none
|
||||||
@@ -91,10 +91,10 @@ endef
|
|||||||
|
|
||||||
define OPACK_TERRAFORM_CONTENT =
|
define OPACK_TERRAFORM_CONTENT =
|
||||||
|
|
||||||
variable "credentials" { default = "../$(OPACK_GCE_JSON_KEY)" }
|
variable "credentials" { default = "../$(OPACK_GCE_JSON_KEY)" }
|
||||||
variable "project" { default = "$(OPACK_GCE_PROJECT)" }
|
variable "project" { default = "$(OPACK_GCE_PROJECT)" }
|
||||||
variable "region" { default = "europe-west4" }
|
variable "region" { default = "$(OPACK_GCE_REGION)" }
|
||||||
variable "zone" { default = "europe-west4-b" }
|
variable "zone" { default = "$(OPACK_GCE_ZONE)" }
|
||||||
|
|
||||||
provider "google" {
|
provider "google" {
|
||||||
region = "$${var.region}"
|
region = "$${var.region}"
|
||||||
@@ -125,7 +125,7 @@ resource "google_compute_instance" "$(OPACK_TARGET)" {
|
|||||||
zone = "$${var.gce_zone}"
|
zone = "$${var.gce_zone}"
|
||||||
boot_disk {
|
boot_disk {
|
||||||
initialize_params {
|
initialize_params {
|
||||||
image = "openbsd"
|
image = "openbsd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
network_interface {
|
network_interface {
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ echo -n "$(2) "
|
|||||||
($(1)) & pid=$$!; i=0; while ps -a | awk '{print $$1}' | grep -q "$${pid}"; do c=`expr $${i} % 4`; case $${c} in 0) echo -e "◐\c" ;; 1) echo -e "◓\c" ;; 2) echo -e "◑\c" ;; 3) echo -e "◒\c" ;; esac; i=`expr $${i} + 1`; sleep 0.2; echo -e "\b\c"; done; echo; wait $${pid}; ret=$$?; exit $${ret};
|
($(1)) & pid=$$!; i=0; while ps -a | awk '{print $$1}' | grep -q "$${pid}"; do c=`expr $${i} % 4`; case $${c} in 0) echo -e "◐\c" ;; 1) echo -e "◓\c" ;; 2) echo -e "◑\c" ;; 3) echo -e "◒\c" ;; esac; i=`expr $${i} + 1`; sleep 0.2; echo -e "\b\c"; done; echo; wait $${pid}; ret=$$?; exit $${ret};
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
ifdef OPACK_DEBUG
|
||||||
$(info $(OPACK_BANNER))
|
$(info $(OPACK_BANNER))
|
||||||
|
endif
|
||||||
|
|
||||||
include $(OPACK_DIR)/options.mk
|
include $(OPACK_DIR)/options.mk
|
||||||
include $(OPACK_DIR)/defines.mk
|
include $(OPACK_DIR)/defines.mk
|
||||||
@@ -111,7 +113,7 @@ $(OPACK_VAGRANT_FILE):
|
|||||||
|
|
||||||
opack: $(OPACK_META_FILE) $(OPACK_VAGRANT_FILE)
|
opack: $(OPACK_META_FILE) $(OPACK_VAGRANT_FILE)
|
||||||
ifndef OPACK_DEBUG
|
ifndef OPACK_DEBUG
|
||||||
$(call spinner,vagrant up > /dev/null,█ $(shell date +'%H:%M:%S') Starting $(OPACK_HOSTNAME)-$(OPACK_TARGET) with Vagrant)
|
$(call spinner,vagrant up > /dev/null,█ $(shell date +'%H:%M:%S') Starting $(OPACK_BOX_TAG) with Vagrant)
|
||||||
else
|
else
|
||||||
vagrant up
|
vagrant up
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ OPACK_AUTODISKLABEL_FILE?=$(OPACK_DIR)autodisklabel
|
|||||||
# Define the Vagrantfile
|
# Define the Vagrantfile
|
||||||
OPACK_VAGRANT_FILE=Vagrantfile
|
OPACK_VAGRANT_FILE=Vagrantfile
|
||||||
|
|
||||||
|
# Define custom networks for Vagrant
|
||||||
|
OPACK_VAGRANT_NETWORK?=
|
||||||
|
#OPACK_VAGRANT_NETWORK=config.vm.network "private_network", auto_config: false
|
||||||
|
|
||||||
# Define the runtime provisioning script for Vagrant
|
# Define the runtime provisioning script for Vagrant
|
||||||
OPACK_RUNTIME_PROVISION_FILE?=$(OPACK_DIR)vagrant-provision.sh
|
OPACK_RUNTIME_PROVISION_FILE?=$(OPACK_DIR)vagrant-provision.sh
|
||||||
|
|
||||||
@@ -125,7 +129,13 @@ OPACK_GCE_JSON_KEY?=
|
|||||||
# OPACK_GCE_BUCKET: The Google Cloud Storage bucket name, typically associated with the project, for the image import.
|
# OPACK_GCE_BUCKET: The Google Cloud Storage bucket name, typically associated with the project, for the image import.
|
||||||
OPACK_GCE_BUCKET?=$(OPACK_GCE_PROJECT)
|
OPACK_GCE_BUCKET?=$(OPACK_GCE_PROJECT)
|
||||||
|
|
||||||
# Define the machine type for the VM
|
# OPACK_GCE_REGION: The Google Cloud Compute Engine region.
|
||||||
|
OPACK_GCE_REGION?=europe-west4
|
||||||
|
|
||||||
|
# OPACK_GCE_REGION: The Google Cloud Compute Engine zone.
|
||||||
|
OPACK_GCE_REGION?=europe-west4-b
|
||||||
|
|
||||||
|
# Define the machine type for the VM
|
||||||
OPACK_GCE_MACHINE?=e2-micro
|
OPACK_GCE_MACHINE?=e2-micro
|
||||||
|
|
||||||
# The SSH key to use to connect to the cloud VM
|
# The SSH key to use to connect to the cloud VM
|
||||||
@@ -138,9 +148,9 @@ OPACK_TERRAFORM_DIR?=opack_deploy_$(OPACK_SHORT_REV)
|
|||||||
# Terraform module dir
|
# Terraform module dir
|
||||||
OPACK_TERRAFORM_MODULE_DIR?=$(OPACK_TERRAFORM_DIR)/opack-module
|
OPACK_TERRAFORM_MODULE_DIR?=$(OPACK_TERRAFORM_DIR)/opack-module
|
||||||
|
|
||||||
ifdef OPACK_DEBUG
|
ifndef OPACK_DEBUG
|
||||||
$(info ░ BOX $(OPACK_BOX_FILE))
|
$(info ░ BOX $(OPACK_BOX_FILE))
|
||||||
$(info ▒ HOSTNAME $(OPACK_SYS_HOSTNAME)-$(OPACK_TARGET))
|
$(info ▒ HOSTNAME $(OPACK_SYS_HOSTNAME))
|
||||||
$(info ░ USER $(OPACK_SYS_USER))
|
$(info ░ USER $(OPACK_SYS_USER))
|
||||||
$(info ▒ PASSWORD $(OPACK_SYS_PASSWORD))
|
$(info ▒ PASSWORD $(OPACK_SYS_PASSWORD))
|
||||||
$(info ░ DISK-SIZE $(OPACK_SYS_DISK_SIZE)m)
|
$(info ░ DISK-SIZE $(OPACK_SYS_DISK_SIZE)m)
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ Vagrant.configure("2") do |config|
|
|||||||
config.ssh.shell = "ksh -l"
|
config.ssh.shell = "ksh -l"
|
||||||
config.ssh.username = "$(OPACK_SSH_USER)"
|
config.ssh.username = "$(OPACK_SSH_USER)"
|
||||||
config.ssh.extra_args = "-tt"
|
config.ssh.extra_args = "-tt"
|
||||||
config.ssh.sudo_command = "doas env %c"
|
config.ssh.sudo_command = "doas env %%c"
|
||||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||||
config.vm.provision "shell", path: "$(OPACK_RUNTIME_PROVISION_FILE)"
|
config.vm.provision "shell", path: "$(OPACK_RUNTIME_PROVISION_FILE)"
|
||||||
|
$(OPACK_VAGRANT_NETWORK)
|
||||||
config.vm.provider "libvirt" do |l|
|
config.vm.provider "libvirt" do |l|
|
||||||
l.cpus = $(OPACK_SYS_CPU)
|
l.cpus = $(OPACK_SYS_CPU)
|
||||||
l.memory = $(OPACK_SYS_MEMORY)
|
l.memory = $(OPACK_SYS_MEMORY)
|
||||||
|
l.qemu_use_session = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user