From fbf68c67b9e60c7b383b1ab2204077720de80bb6 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sun, 31 Dec 2023 17:33:21 +0100 Subject: [PATCH] Renaming projects for quick retrieval. --- README.md | 2 +- .../.gitignore | 0 {pve-vm-python => pve-ct-python}/Pulumi.yaml | 0 {pve-vm-python => pve-ct-python}/README.md | 0 pve-ct-python/__main__.py | 70 +++++++++++++++++++ pve-ct-python/input.yaml | 21 ++++++ .../requirements.txt | 0 .../.gitignore | 0 .../Pulumi.yaml | 0 .../README.md | 0 .../__main__.py | 0 .../ansible.cfg | 0 .../deploy.yml | 0 .../input.yaml | 0 .../requirements.txt | 0 {libvirt-python => pvm}/.gitignore | 0 pvm/Pulumi.yaml | 6 ++ pvm/README.md | 7 ++ {pve-vm-python => pvm}/__main__.py | 0 {pve-vm-python => pvm}/input.yaml | 0 pvm/requirements.txt | 5 ++ {pve-vm-python => vm-ansible}/.gitignore | 0 .../Pulumi.yaml | 0 .../README.md | 0 .../__main__.py | 0 .../ansible.cfg | 0 .../cloud-images.yaml | 0 .../cloud-init/meta-data.jinja | 0 .../cloud-init/network-config | 0 .../cloud-init/user-data.jinja | 0 .../deploy.yml | 0 .../input.yaml | 0 .../requirements.txt | 0 vm/.gitignore | 2 + {libvirt-python => vm}/Pulumi.yaml | 0 {libvirt-python => vm}/README.md | 0 {libvirt-python => vm}/__main__.py | 0 {libvirt-python => vm}/cloud-images.yaml | 0 .../cloud-init/meta-data.jinja | 0 .../cloud-init/network-config | 0 .../cloud-init/user-data.jinja | 0 {libvirt-python => vm}/input.yaml | 0 {libvirt-python => vm}/requirements.txt | 0 43 files changed, 112 insertions(+), 1 deletion(-) rename {libvirt-ansible-python => pve-ct-python}/.gitignore (100%) rename {pve-vm-python => pve-ct-python}/Pulumi.yaml (100%) rename {pve-vm-python => pve-ct-python}/README.md (100%) create mode 100644 pve-ct-python/__main__.py create mode 100644 pve-ct-python/input.yaml rename {pve-vm-python => pve-ct-python}/requirements.txt (100%) rename {pve-vm-ansible-python => pvm-ansible}/.gitignore (100%) rename {pve-vm-ansible-python => pvm-ansible}/Pulumi.yaml (100%) rename {pve-vm-ansible-python => pvm-ansible}/README.md (100%) rename {pve-vm-ansible-python => pvm-ansible}/__main__.py (100%) rename {libvirt-ansible-python => pvm-ansible}/ansible.cfg (100%) rename {libvirt-ansible-python => pvm-ansible}/deploy.yml (100%) rename {pve-vm-ansible-python => pvm-ansible}/input.yaml (100%) rename {pve-vm-ansible-python => pvm-ansible}/requirements.txt (100%) rename {libvirt-python => pvm}/.gitignore (100%) create mode 100644 pvm/Pulumi.yaml create mode 100644 pvm/README.md rename {pve-vm-python => pvm}/__main__.py (100%) rename {pve-vm-python => pvm}/input.yaml (100%) create mode 100644 pvm/requirements.txt rename {pve-vm-python => vm-ansible}/.gitignore (100%) rename {libvirt-ansible-python => vm-ansible}/Pulumi.yaml (100%) rename {libvirt-ansible-python => vm-ansible}/README.md (100%) rename {libvirt-ansible-python => vm-ansible}/__main__.py (100%) rename {pve-vm-ansible-python => vm-ansible}/ansible.cfg (100%) rename {libvirt-ansible-python => vm-ansible}/cloud-images.yaml (100%) rename {libvirt-ansible-python => vm-ansible}/cloud-init/meta-data.jinja (100%) rename {libvirt-ansible-python => vm-ansible}/cloud-init/network-config (100%) rename {libvirt-ansible-python => vm-ansible}/cloud-init/user-data.jinja (100%) rename {pve-vm-ansible-python => vm-ansible}/deploy.yml (100%) rename {libvirt-ansible-python => vm-ansible}/input.yaml (100%) rename {libvirt-ansible-python => vm-ansible}/requirements.txt (100%) create mode 100644 vm/.gitignore rename {libvirt-python => vm}/Pulumi.yaml (100%) rename {libvirt-python => vm}/README.md (100%) rename {libvirt-python => vm}/__main__.py (100%) rename {libvirt-python => vm}/cloud-images.yaml (100%) rename {libvirt-python => vm}/cloud-init/meta-data.jinja (100%) rename {libvirt-python => vm}/cloud-init/network-config (100%) rename {libvirt-python => vm}/cloud-init/user-data.jinja (100%) rename {libvirt-python => vm}/input.yaml (100%) rename {libvirt-python => vm}/requirements.txt (100%) diff --git a/README.md b/README.md index a3ab953..7ad4a41 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # pulumi-templates -Templates for new projects for Pulumi \ No newline at end of file +Templates for new projects for Pulumi. diff --git a/libvirt-ansible-python/.gitignore b/pve-ct-python/.gitignore similarity index 100% rename from libvirt-ansible-python/.gitignore rename to pve-ct-python/.gitignore diff --git a/pve-vm-python/Pulumi.yaml b/pve-ct-python/Pulumi.yaml similarity index 100% rename from pve-vm-python/Pulumi.yaml rename to pve-ct-python/Pulumi.yaml diff --git a/pve-vm-python/README.md b/pve-ct-python/README.md similarity index 100% rename from pve-vm-python/README.md rename to pve-ct-python/README.md diff --git a/pve-ct-python/__main__.py b/pve-ct-python/__main__.py new file mode 100644 index 0000000..2be7560 --- /dev/null +++ b/pve-ct-python/__main__.py @@ -0,0 +1,70 @@ +"""A ProxmoxVE VM template with Python""" + +import yaml +from dotmap import DotMap +import pulumi +import pulumi_proxmoxve as proxmox + +conf = DotMap(yaml.safe_load(open("input.yaml").read())) +config = pulumi.Config() + +provider = proxmox.Provider("proxmoxve", + virtual_environment = { + "endpoint": conf.pve.url, + "insecure": conf.pve.insecure, + "username": conf.pve.username, + "password": config.require_secret("password") + } +) + +ct = proxmox.ct.Container(conf.ct.name, + clone = proxmox.ct.ContainerCloneArgs( + vm_id = conf.ct.clone, + full = True + ), + console = proxmox.ct.ConsoleArgs( + type = "serial", + tty_count = 1, + enabled = True + ), + cpu = proxmox.ct.ContainerCpuArgs(cores = conf.ct.cores), + disk = proxmox.ct.ContainerDiskArgs(datastore_id = conf.pve.storage), + initialization = proxmox.ct.ContainerInitializationArgs( + hostname = conf.ct.name, + ip_configs = [ + proxmox.ct.ContainerInitializationIpConfigArgs( + ipv4 = proxmox.ct.ContainerInitializationIpConfigIpv4Args( + address = "dhcp" + ) + ) + ], + user_account = proxmox.ct.ContainerInitializationUserAccountArgs( + password = conf.ct.password, + keys = conf.ct.sshkeys + ), + ), + memory = proxmox.ct.ContainerMemoryArgs( + dedicated = conf.ct.ram, + swap = conf.ct.ram + ), + network_interfaces = [ + proxmox.ct.ContainerNetworkInterfaceArgs("mynic", + bridge = "vmbr0", + enabled = True + ) + ], + node_name = conf.pve.nodename, + operating_system = proxmox.ct.ContainerOperatingSystemArgs( + template_file_id = "debian-11-standard_11.3-1_amd64.tar.zst" + ), + started = True, + opts = pulumi.ResourceOptions( + provider = provider + ) +) + +# Getting local IP +# First item of the ipv4_addresses is of the loopback interface (so the usual 127.0.0.1). Let's get the second and grab only the text. +lanip = ct.initialization["ip_configs"]["ipv4"]["address"][0] + +pulumi.export("ip", lanip) diff --git a/pve-ct-python/input.yaml b/pve-ct-python/input.yaml new file mode 100644 index 0000000..904d2f1 --- /dev/null +++ b/pve-ct-python/input.yaml @@ -0,0 +1,21 @@ +--- +pve: + url: "https://pve.vavassori.lcl:8006" + insecure: true + username: root@pam + nodename: pve + storage: local + +# Basic VM configuration +ct: + name: virtual-machine + clone: 802 + sockets: 1 + cores: 1 + ram: 2048 + disksize: 20 + password: cicciopasticcio + sshkeys: + - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso" + - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps" + - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/hn/0xn6DRS2B0paFzDQRakupgTQQ5hitQhqOfWcqz syntaxerrormmm@microbo" diff --git a/pve-vm-python/requirements.txt b/pve-ct-python/requirements.txt similarity index 100% rename from pve-vm-python/requirements.txt rename to pve-ct-python/requirements.txt diff --git a/pve-vm-ansible-python/.gitignore b/pvm-ansible/.gitignore similarity index 100% rename from pve-vm-ansible-python/.gitignore rename to pvm-ansible/.gitignore diff --git a/pve-vm-ansible-python/Pulumi.yaml b/pvm-ansible/Pulumi.yaml similarity index 100% rename from pve-vm-ansible-python/Pulumi.yaml rename to pvm-ansible/Pulumi.yaml diff --git a/pve-vm-ansible-python/README.md b/pvm-ansible/README.md similarity index 100% rename from pve-vm-ansible-python/README.md rename to pvm-ansible/README.md diff --git a/pve-vm-ansible-python/__main__.py b/pvm-ansible/__main__.py similarity index 100% rename from pve-vm-ansible-python/__main__.py rename to pvm-ansible/__main__.py diff --git a/libvirt-ansible-python/ansible.cfg b/pvm-ansible/ansible.cfg similarity index 100% rename from libvirt-ansible-python/ansible.cfg rename to pvm-ansible/ansible.cfg diff --git a/libvirt-ansible-python/deploy.yml b/pvm-ansible/deploy.yml similarity index 100% rename from libvirt-ansible-python/deploy.yml rename to pvm-ansible/deploy.yml diff --git a/pve-vm-ansible-python/input.yaml b/pvm-ansible/input.yaml similarity index 100% rename from pve-vm-ansible-python/input.yaml rename to pvm-ansible/input.yaml diff --git a/pve-vm-ansible-python/requirements.txt b/pvm-ansible/requirements.txt similarity index 100% rename from pve-vm-ansible-python/requirements.txt rename to pvm-ansible/requirements.txt diff --git a/libvirt-python/.gitignore b/pvm/.gitignore similarity index 100% rename from libvirt-python/.gitignore rename to pvm/.gitignore diff --git a/pvm/Pulumi.yaml b/pvm/Pulumi.yaml new file mode 100644 index 0000000..e38fa0f --- /dev/null +++ b/pvm/Pulumi.yaml @@ -0,0 +1,6 @@ +--- +name: ${PROJECT} +description: ${DESCRIPTION} +runtime: python +template: + description: A ProxmoxVE VM template with Python diff --git a/pvm/README.md b/pvm/README.md new file mode 100644 index 0000000..a8c6fed --- /dev/null +++ b/pvm/README.md @@ -0,0 +1,7 @@ +# Quick configuration # + +Check out the file `input.yml` for a quick setup for a new machine. +Also, don't forget to setup the password for your account on your ProxmoxVE +server configuring `pulumi`: + + $ pulumi config set password --secret yourpvepassword diff --git a/pve-vm-python/__main__.py b/pvm/__main__.py similarity index 100% rename from pve-vm-python/__main__.py rename to pvm/__main__.py diff --git a/pve-vm-python/input.yaml b/pvm/input.yaml similarity index 100% rename from pve-vm-python/input.yaml rename to pvm/input.yaml diff --git a/pvm/requirements.txt b/pvm/requirements.txt new file mode 100644 index 0000000..94544cf --- /dev/null +++ b/pvm/requirements.txt @@ -0,0 +1,5 @@ +pyyaml>=6.0 +protobuf==3.20.1 +pulumi>=3.0.0,<4.0.0 +pulumi-proxmoxve>=2.0.0 +dotmap>=1.3.30 diff --git a/pve-vm-python/.gitignore b/vm-ansible/.gitignore similarity index 100% rename from pve-vm-python/.gitignore rename to vm-ansible/.gitignore diff --git a/libvirt-ansible-python/Pulumi.yaml b/vm-ansible/Pulumi.yaml similarity index 100% rename from libvirt-ansible-python/Pulumi.yaml rename to vm-ansible/Pulumi.yaml diff --git a/libvirt-ansible-python/README.md b/vm-ansible/README.md similarity index 100% rename from libvirt-ansible-python/README.md rename to vm-ansible/README.md diff --git a/libvirt-ansible-python/__main__.py b/vm-ansible/__main__.py similarity index 100% rename from libvirt-ansible-python/__main__.py rename to vm-ansible/__main__.py diff --git a/pve-vm-ansible-python/ansible.cfg b/vm-ansible/ansible.cfg similarity index 100% rename from pve-vm-ansible-python/ansible.cfg rename to vm-ansible/ansible.cfg diff --git a/libvirt-ansible-python/cloud-images.yaml b/vm-ansible/cloud-images.yaml similarity index 100% rename from libvirt-ansible-python/cloud-images.yaml rename to vm-ansible/cloud-images.yaml diff --git a/libvirt-ansible-python/cloud-init/meta-data.jinja b/vm-ansible/cloud-init/meta-data.jinja similarity index 100% rename from libvirt-ansible-python/cloud-init/meta-data.jinja rename to vm-ansible/cloud-init/meta-data.jinja diff --git a/libvirt-ansible-python/cloud-init/network-config b/vm-ansible/cloud-init/network-config similarity index 100% rename from libvirt-ansible-python/cloud-init/network-config rename to vm-ansible/cloud-init/network-config diff --git a/libvirt-ansible-python/cloud-init/user-data.jinja b/vm-ansible/cloud-init/user-data.jinja similarity index 100% rename from libvirt-ansible-python/cloud-init/user-data.jinja rename to vm-ansible/cloud-init/user-data.jinja diff --git a/pve-vm-ansible-python/deploy.yml b/vm-ansible/deploy.yml similarity index 100% rename from pve-vm-ansible-python/deploy.yml rename to vm-ansible/deploy.yml diff --git a/libvirt-ansible-python/input.yaml b/vm-ansible/input.yaml similarity index 100% rename from libvirt-ansible-python/input.yaml rename to vm-ansible/input.yaml diff --git a/libvirt-ansible-python/requirements.txt b/vm-ansible/requirements.txt similarity index 100% rename from libvirt-ansible-python/requirements.txt rename to vm-ansible/requirements.txt diff --git a/vm/.gitignore b/vm/.gitignore new file mode 100644 index 0000000..a3807e5 --- /dev/null +++ b/vm/.gitignore @@ -0,0 +1,2 @@ +*.pyc +venv/ diff --git a/libvirt-python/Pulumi.yaml b/vm/Pulumi.yaml similarity index 100% rename from libvirt-python/Pulumi.yaml rename to vm/Pulumi.yaml diff --git a/libvirt-python/README.md b/vm/README.md similarity index 100% rename from libvirt-python/README.md rename to vm/README.md diff --git a/libvirt-python/__main__.py b/vm/__main__.py similarity index 100% rename from libvirt-python/__main__.py rename to vm/__main__.py diff --git a/libvirt-python/cloud-images.yaml b/vm/cloud-images.yaml similarity index 100% rename from libvirt-python/cloud-images.yaml rename to vm/cloud-images.yaml diff --git a/libvirt-python/cloud-init/meta-data.jinja b/vm/cloud-init/meta-data.jinja similarity index 100% rename from libvirt-python/cloud-init/meta-data.jinja rename to vm/cloud-init/meta-data.jinja diff --git a/libvirt-python/cloud-init/network-config b/vm/cloud-init/network-config similarity index 100% rename from libvirt-python/cloud-init/network-config rename to vm/cloud-init/network-config diff --git a/libvirt-python/cloud-init/user-data.jinja b/vm/cloud-init/user-data.jinja similarity index 100% rename from libvirt-python/cloud-init/user-data.jinja rename to vm/cloud-init/user-data.jinja diff --git a/libvirt-python/input.yaml b/vm/input.yaml similarity index 100% rename from libvirt-python/input.yaml rename to vm/input.yaml diff --git a/libvirt-python/requirements.txt b/vm/requirements.txt similarity index 100% rename from libvirt-python/requirements.txt rename to vm/requirements.txt