diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 8142708d..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,92 +0,0 @@ -License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved. -"Business Source License" is a trademark of MariaDB Corporation Ab. - -Parameters - -Licensor: HashiCorp, Inc. -Licensed Work: Terraform Version 1.6.0 or later. The Licensed Work is (c) 2024 - HashiCorp, Inc. -Additional Use Grant: You may make production use of the Licensed Work, provided - Your use does not include offering the Licensed Work to third - parties on a hosted or embedded basis in order to compete with - HashiCorp's paid version(s) of the Licensed Work. For purposes - of this license: - - A "competitive offering" is a Product that is offered to third - parties on a paid basis, including through paid support - arrangements, that significantly overlaps with the capabilities - of HashiCorp's paid version(s) of the Licensed Work. If Your - Product is not a competitive offering when You first make it - generally available, it will not become a competitive offering - later due to HashiCorp releasing a new version of the Licensed - Work with additional capabilities. In addition, Products that - are not provided on a paid basis are not competitive. - - "Product" means software that is offered to end users to manage - in their own environments or offered as a service on a hosted - basis. - - "Embedded" means including the source code or executable code - from the Licensed Work in a competitive offering. "Embedded" - also means packaging the competitive offering in such a way - that the Licensed Work must be accessed or downloaded for the - competitive offering to operate. - - Hosting or using the Licensed Work(s) for internal purposes - within an organization is not considered a competitive - offering. HashiCorp considers your organization to include all - of your affiliates under common control. - - For binding interpretive guidance on using HashiCorp products - under the Business Source License, please visit our FAQ. - (https://www.hashicorp.com/license-faq) -Change Date: Four years from the date the Licensed Work is published. -Change License: MPL 2.0 - -For information about alternative licensing arrangements for the Licensed Work, -please contact licensing@hashicorp.com. - -Notice - -Business Source License 1.1 - -Terms - -The Licensor hereby grants you the right to copy, modify, create derivative -works, redistribute, and make non-production use of the Licensed Work. The -Licensor may make an Additional Use Grant, above, permitting limited production use. - -Effective on the Change Date, or the fourth anniversary of the first publicly -available distribution of a specific version of the Licensed Work under this -License, whichever comes first, the Licensor hereby grants you rights under -the terms of the Change License, and the rights granted in the paragraph -above terminate. - -If your use of the Licensed Work does not comply with the requirements -currently in effect as described in this License, you must purchase a -commercial license from the Licensor, its affiliated entities, or authorized -resellers, or you must refrain from using the Licensed Work. - -All copies of the original and modified Licensed Work, and derivative works -of the Licensed Work, are subject to this License. This License applies -separately for each version of the Licensed Work and the Change Date may vary -for each version of the Licensed Work released by Licensor. - -You must conspicuously display this License on each original or modified copy -of the Licensed Work. If you receive the Licensed Work in original or -modified form from a third party, the terms and conditions set forth in this -License apply to your use of that work. - -Any use of the Licensed Work in violation of this License will automatically -terminate your rights under this License for the current and all other -versions of the Licensed Work. - -This License does not grant you any right in any trademark or logo of -Licensor or its affiliates (provided that you may use a trademark or logo of -Licensor as expressly required by this License). - -TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON -AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, -EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND -TITLE. diff --git a/modules/create-vm/main.tf b/modules/create-vm/main.tf index a59e97a5..c849c680 100644 --- a/modules/create-vm/main.tf +++ b/modules/create-vm/main.tf @@ -1,153 +1,88 @@ -variable "vsphere_user" { - default = "Administrator@viktorbarzin.lan" -} -variable "vsphere_password" {} -variable "vsphere_server" { - default = "vcenter" -} -variable "vm_name" { - default = "terraform-test" -} +variable "template_name" { type = string } +variable "vm_name" { default = "terraform-test" } variable "vm_cpus" { type = number default = 4 } -variable "vm_mem" { +variable "vm_mem_mb" { type = number - default = 4096 -} - -variable "vm_guest_id" { - default = "ubuntu64Guest" + default = 8192 } variable "vm_disk_size" { - type = number - default = 64 -} - -variable "provisioner_command" { - description = "Additional provisioning commands to run" - default = "#" - type = string -} - -variable "network" { - description = "Network to attach the vm guest to" -} - -variable "ceph_disk_size" { - type = number - default = 0 -} - -variable "cdrom_path" { type = string - default = "" -} - -variable "vsphere_datastore" { - type = string - default = "r730-datastore" -} - -variable "vsphere_resource_pool" { - type = string - default = "R730" + default = "64G" } variable "vm_mac_address" { type = string - default = "" + default = null } +variable "cisnippet_name" { type = string } -provider "vsphere" { - user = var.vsphere_user - password = var.vsphere_password - vsphere_server = var.vsphere_server - # If you have a self-signed cert - allow_unverified_ssl = true -} - -data "vsphere_datacenter" "dc" { - name = "Home" -} - -data "vsphere_datastore" "datastore" { - name = var.vsphere_datastore - datacenter_id = data.vsphere_datacenter.dc.id -} - -data "vsphere_resource_pool" "pool" { - name = var.vsphere_resource_pool - datacenter_id = data.vsphere_datacenter.dc.id -} - -data "vsphere_network" "network" { - name = var.network - datacenter_id = data.vsphere_datacenter.dc.id -} - -resource "vsphere_virtual_machine" "vm" { +resource "proxmox_vm_qemu" "cloudinit-vm" { + vmid = 305 name = var.vm_name - resource_pool_id = data.vsphere_resource_pool.pool.id - datastore_id = data.vsphere_datastore.datastore.id + target_node = "pve" + agent = 0 + memory = var.vm_mem_mb + boot = "order=scsi0" # has to be the same as the OS disk of the template + clone = var.template_name # The name of the template + scsihw = "virtio-scsi-single" + vm_state = "running" + automatic_reboot = true + os_type = "cloud-init" - num_cpus = var.vm_cpus - memory = var.vm_mem - guest_id = var.vm_guest_id + # Cloud-Init configuration + ciupgrade = true + nameserver = "1.1.1.1 8.8.8.8" + ipconfig0 = "ip=dhcp,ip6=dhcp" + skip_ipv6 = true + ciuser = "root" + sshkeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDHLhYDfyx237eJgOGVoJRECpUS95+7rEBS9vacsIxtx vbarzin@gmail.com" + searchdomain = "viktorbarzin.lan" + onboot = true # start on node boot + qemu_os = "l26" + cicustom = "vendor=local:snippets/${var.cisnippet_name}" - # If mac address is set create NIC with that MAC - dynamic "network_interface" { - for_each = var.vm_mac_address != "" ? [1] : [] - content { - network_id = data.vsphere_network.network.id - use_static_mac = true - mac_address = var.vm_mac_address + cpu { + cores = var.vm_cpus + type = "host" # emulate host cpu + } + + + # Most cloud-init images require a serial device for their display + serial { + id = 0 + } + + disks { + scsi { + scsi0 { + # We have to specify the disk from our template, else Terraform will think it's not supposed to be there + disk { + storage = "local-lvm" + # The size of the disk should be at least as big as the disk in the template. If it's smaller, the disk will be recreated + size = var.vm_disk_size + } + } + } + ide { + # Some images require a cloud-init disk on the IDE controller, others on the SCSI or SATA controller + ide1 { + cloudinit { + storage = "local-lvm" + } + } } } - # Else create a NIC with random MAC - dynamic "network_interface" { - for_each = var.vm_mac_address == "" ? [1] : [] - content { - network_id = data.vsphere_network.network.id - } - } - - disk { - label = "disk0" - size = var.vm_disk_size - } - - dynamic "disk" { - for_each = var.ceph_disk_size > 0 ? [1] : [] - content { - label = "ceph-disk0" - size = var.ceph_disk_size - unit_number = 1 - } - } - - dynamic "cdrom" { - for_each = var.cdrom_path != "" ? [1] : [] - content { - datastore_id = data.vsphere_datastore.datastore.id - path = var.cdrom_path - } - } - wait_for_guest_net_timeout = 600 - - provisioner "local-exec" { - # for_each = var.provisioner_command != "" ? [1] : [] - # content { - command = "${var.provisioner_command} -e 'host=${vsphere_virtual_machine.vm.default_ip_address}'" - # } + network { + id = 0 + bridge = "vmbr0" + model = "e1000" + macaddr = var.vm_mac_address } } - -output "guest_ip" { - value = vsphere_virtual_machine.vm.default_ip_address -} diff --git a/modules/create-vm/versions.tf b/modules/create-vm/versions.tf index 0737df62..3943417e 100644 --- a/modules/create-vm/versions.tf +++ b/modules/create-vm/versions.tf @@ -1,9 +1,9 @@ terraform { required_providers { - vsphere = { - source = "hashicorp/vsphere" - version = "2.0.2" + proxmox = { + source = "telmate/proxmox" + version = "3.0.2-rc04" } } } diff --git a/playbook b/playbook deleted file mode 120000 index 9f2f234b..00000000 --- a/playbook +++ /dev/null @@ -1 +0,0 @@ -../playbook \ No newline at end of file diff --git a/kill_ns.sh b/scripts/kill_ns.sh similarity index 100% rename from kill_ns.sh rename to scripts/kill_ns.sh diff --git a/node_registry_manager.sh b/scripts/node_registry_manager.sh similarity index 100% rename from node_registry_manager.sh rename to scripts/node_registry_manager.sh diff --git a/renew_worker_certs.sh b/scripts/renew_worker_certs.sh similarity index 100% rename from renew_worker_certs.sh rename to scripts/renew_worker_certs.sh diff --git a/server_safe_poweroff/deploy_to_nas.sh b/scripts/server_safe_poweroff/deploy_to_nas.sh similarity index 100% rename from server_safe_poweroff/deploy_to_nas.sh rename to scripts/server_safe_poweroff/deploy_to_nas.sh diff --git a/server_safe_poweroff/go.mod b/scripts/server_safe_poweroff/go.mod similarity index 100% rename from server_safe_poweroff/go.mod rename to scripts/server_safe_poweroff/go.mod diff --git a/server_safe_poweroff/go.sum b/scripts/server_safe_poweroff/go.sum similarity index 100% rename from server_safe_poweroff/go.sum rename to scripts/server_safe_poweroff/go.sum diff --git a/server_safe_poweroff/idrac_utils.go b/scripts/server_safe_poweroff/idrac_utils.go similarity index 100% rename from server_safe_poweroff/idrac_utils.go rename to scripts/server_safe_poweroff/idrac_utils.go diff --git a/server_safe_poweroff/main.go b/scripts/server_safe_poweroff/main.go similarity index 100% rename from server_safe_poweroff/main.go rename to scripts/server_safe_poweroff/main.go diff --git a/server_safe_poweroff/synology_main.sh b/scripts/server_safe_poweroff/synology_main.sh similarity index 100% rename from server_safe_poweroff/synology_main.sh rename to scripts/server_safe_poweroff/synology_main.sh diff --git a/server_safe_poweroff/ups_utils.go b/scripts/server_safe_poweroff/ups_utils.go similarity index 100% rename from server_safe_poweroff/ups_utils.go rename to scripts/server_safe_poweroff/ups_utils.go diff --git a/stop_storage_services.sh b/scripts/stop_storage_services.sh similarity index 100% rename from stop_storage_services.sh rename to scripts/stop_storage_services.sh diff --git a/update-istio-injection.sh b/scripts/update-istio-injection.sh similarity index 100% rename from update-istio-injection.sh rename to scripts/update-istio-injection.sh diff --git a/update_k8s.sh b/scripts/update_k8s.sh similarity index 100% rename from update_k8s.sh rename to scripts/update_k8s.sh diff --git a/update_node.sh b/scripts/update_node.sh similarity index 100% rename from update_node.sh rename to scripts/update_node.sh diff --git a/terraform_1.10.3_linux_amd64.zip b/terraform_1.10.3_linux_amd64.zip deleted file mode 100644 index 3b8a8003..00000000 Binary files a/terraform_1.10.3_linux_amd64.zip and /dev/null differ