From 17ba66498531c9e154a9e49d8d27a96b7a317cff Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 17 Aug 2022 01:52:53 +0200 Subject: [PATCH] Aggiunta proxmoxve-python --- proxmoxve-python/.gitignore | 2 + proxmoxve-python/Pulumi.yaml | 5 +++ proxmoxve-python/__main__.py | 67 +++++++++++++++++++++++++++++++ proxmoxve-python/requirements.txt | 2 + 4 files changed, 76 insertions(+) create mode 100644 proxmoxve-python/.gitignore create mode 100644 proxmoxve-python/Pulumi.yaml create mode 100644 proxmoxve-python/__main__.py create mode 100644 proxmoxve-python/requirements.txt diff --git a/proxmoxve-python/.gitignore b/proxmoxve-python/.gitignore new file mode 100644 index 0000000..a3807e5 --- /dev/null +++ b/proxmoxve-python/.gitignore @@ -0,0 +1,2 @@ +*.pyc +venv/ diff --git a/proxmoxve-python/Pulumi.yaml b/proxmoxve-python/Pulumi.yaml new file mode 100644 index 0000000..2289d87 --- /dev/null +++ b/proxmoxve-python/Pulumi.yaml @@ -0,0 +1,5 @@ +name: ${PROJECT} +description: ${DESCRIPTION} +runtime: python +template: + description: A minimal Python Pulumi program diff --git a/proxmoxve-python/__main__.py b/proxmoxve-python/__main__.py new file mode 100644 index 0000000..8644e86 --- /dev/null +++ b/proxmoxve-python/__main__.py @@ -0,0 +1,67 @@ +"""A Pulumi-based infrastructure with Proxmox VE and Python""" + +import pulumi +import pulumi_proxmoxve as proxmox + +config = pulumi.Config() + +provider = proxmox.Provider("proxmoxve", + virtual_environment = { + "endpoint": config.endpoint, + "insecure": True, + "username": "root@pam", + "password": config.pvepassword + } +) + +vm = proxmox.vm.VirtualMachine("vm", + name = "virtual-machine", + node_name = config.node_name, + agent = proxmox.vm.VirtualMachineAgentArgs( + enabled = True, + trim = True, + type = "virtio" + ), + bios = "seabios", + cpu = proxmox.vm.VirtualMachineCpuArgs( + cores = 1, + sockets = 1 + ), + memory = proxmox.vm.VirtualMachineMemoryArgs( + dedicated = 2048 + ), + clone = proxmox.vm.VirtualMachineCloneArgs( + node_name = config.node_name, + datastore_id = "local-lvm", + size = 20, + file_format = "qcow2" + ), + network_devices = [ + proxmox.vm.VirtualMachineNetworkDeviceArgs( + bridge = "vmbr0", + model = "virtio" + ) + ], + on_boot = True, + operating_system = proxmox.vm.VirtualMachineOperatingSystemArgs( + type = "l26" + ), + initialization = proxmox.vm.VirtualMachineInitializationArgs( + type = "nocloud", + datastore_id = "local-lvm", + user_account = proxmox.vm.VirtualMachineInitializationUserAccountArgs( + username = "syntaxerrormmm", + password = "cicciopasticcio", + keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso", + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps", + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/hn/0xn6DRS2B0paFzDQRakupgTQQ5hitQhqOfWcqz syntaxerrormmm@microbo" + ] + ) + ), + opts = pulumi.ResourceOptions( + provider = provider + ) +) + +pulumi.export("ip", vm.ipv4_address) diff --git a/proxmoxve-python/requirements.txt b/proxmoxve-python/requirements.txt new file mode 100644 index 0000000..3d56c46 --- /dev/null +++ b/proxmoxve-python/requirements.txt @@ -0,0 +1,2 @@ +pulumi>=3.0.0,<4.0.0 +pulumi-proxmoxve>=2.0.0