Changed inputs from yaml file.
This commit is contained in:
parent
b216e3361e
commit
91d8af9280
@ -1,5 +1,6 @@
|
||||
---
|
||||
name: ${PROJECT}
|
||||
description: ${DESCRIPTION}
|
||||
runtime: python
|
||||
template:
|
||||
description: A minimal Python Pulumi program
|
||||
description: A ProxmoxVE VM template with Python
|
||||
|
7
pve-vm-python/README.md
Normal file
7
pve-vm-python/README.md
Normal file
@ -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
|
@ -1,23 +1,24 @@
|
||||
"""A Pulumi-based infrastructure with Proxmox VE and Python"""
|
||||
"""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()
|
||||
data = config.require_object("pve")
|
||||
|
||||
provider = proxmox.Provider("proxmoxve",
|
||||
virtual_environment = {
|
||||
"endpoint": data.get("endpoint"),
|
||||
"insecure": True,
|
||||
"username": "root@pam",
|
||||
"password": data.get("password")
|
||||
"endpoint": conf.pve.url,
|
||||
"insecure": conf.pve.insecure,
|
||||
"username": conf.pve.username,
|
||||
"password": config.require_secure("password")
|
||||
}
|
||||
)
|
||||
|
||||
vm = proxmox.vm.VirtualMachine("vm",
|
||||
name = "virtual-machine",
|
||||
node_name = data.get("node_name"),
|
||||
vm = proxmox.vm.VirtualMachine(conf.vm.name,
|
||||
node_name = conf.pve.nodename,
|
||||
agent = proxmox.vm.VirtualMachineAgentArgs(
|
||||
enabled = True,
|
||||
trim = True,
|
||||
@ -25,22 +26,22 @@ vm = proxmox.vm.VirtualMachine("vm",
|
||||
),
|
||||
bios = "seabios",
|
||||
cpu = proxmox.vm.VirtualMachineCpuArgs(
|
||||
cores = 1,
|
||||
sockets = 1
|
||||
cores = conf.vm.cores,
|
||||
sockets = conf.vm.sockets
|
||||
),
|
||||
memory = proxmox.vm.VirtualMachineMemoryArgs(
|
||||
dedicated = 2048
|
||||
dedicated = conf.vm.ram
|
||||
),
|
||||
clone = proxmox.vm.VirtualMachineCloneArgs(
|
||||
node_name = data.get("node_name"),
|
||||
vm_id = config.require("clonevm"),
|
||||
node_name = conf.pve.nodename,
|
||||
vm_id = conf.vm.clone,
|
||||
full = True
|
||||
),
|
||||
disks = [
|
||||
proxmox.vm.VirtualMachineDiskArgs(
|
||||
interface = "virtio0",
|
||||
datastore_id = "local-lvm",
|
||||
size = 20,
|
||||
datastore_id = conf.pve.storage,
|
||||
size = conf.vm.disksize,
|
||||
file_format = "qcow2"
|
||||
)
|
||||
],
|
||||
@ -56,15 +57,11 @@ vm = proxmox.vm.VirtualMachine("vm",
|
||||
),
|
||||
initialization = proxmox.vm.VirtualMachineInitializationArgs(
|
||||
type = "nocloud",
|
||||
datastore_id = "local-lvm",
|
||||
datastore_id = conf.pve.storage,
|
||||
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"
|
||||
]
|
||||
username = conf.vm.username,
|
||||
password = conf.vm.password,
|
||||
keys = conf.vm.sshkeys
|
||||
)
|
||||
),
|
||||
opts = pulumi.ResourceOptions(
|
||||
|
22
pve-vm-python/input.yaml
Normal file
22
pve-vm-python/input.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
pve:
|
||||
url: "https://pve.vavassori.lcl:8006"
|
||||
insecure: true
|
||||
username: root@pam
|
||||
nodename: pve
|
||||
storage: local-lvm
|
||||
|
||||
# Basic VM configuration
|
||||
vm:
|
||||
name: virtual-machine
|
||||
clone: 802
|
||||
sockets: 1
|
||||
cores: 1
|
||||
ram: 2048
|
||||
disksize: 20
|
||||
username: syntaxerrormmm
|
||||
password: cicciopasticcio
|
||||
sshkeys:
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/hn/0xn6DRS2B0paFzDQRakupgTQQ5hitQhqOfWcqz syntaxerrormmm@microbo"
|
@ -1,2 +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
|
||||
|
Loading…
Reference in New Issue
Block a user