Aggiunta template per libvirt e python.
This commit is contained in:
parent
1651a1e269
commit
f54055a65c
2
libvirt-python/.gitignore
vendored
Normal file
2
libvirt-python/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.pyc
|
||||
venv/
|
5
libvirt-python/Pulumi.yaml
Normal file
5
libvirt-python/Pulumi.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
name: ${PROJECT}
|
||||
description: ${DESCRIPTION}
|
||||
runtime: python
|
||||
template:
|
||||
description: A Pulumi deployment with libvirt and Python
|
9
libvirt-python/README.md
Normal file
9
libvirt-python/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Quick configuration #
|
||||
|
||||
To quickly set up your pulumi deployment, configure the following settings:
|
||||
|
||||
$ pulumi config set libvirt:url --plaintext "qemu:///system"
|
||||
$ pulumi config set image_url --plaintext "https://cdimage.debian.org/images/cloud/bullseye-backports/20220711-1073/debian-11-backports-generic-amd64-20220711-1073.qcow2"
|
||||
$ pulumi config set disksize --int 20
|
||||
$ pulumi config set memory --int 2048
|
||||
|
57
libvirt-python/__main__.py
Normal file
57
libvirt-python/__main__.py
Normal file
@ -0,0 +1,57 @@
|
||||
"""A Pulumi-based infrastructure with libvirt and Python"""
|
||||
|
||||
import pulumi
|
||||
import pulumi_libvirt as lv
|
||||
|
||||
config = pulumi.Config()
|
||||
|
||||
pool = lv.Pool("default",
|
||||
type = "dir",
|
||||
path = "/var/tmp/libvirt/pulumi"
|
||||
)
|
||||
|
||||
baseimg = lv.Volume("base-image",
|
||||
pool = pool.name,
|
||||
source = config.require("image_url")
|
||||
#source = "https://cdimage.debian.org/images/cloud/bullseye-backports/20220711-1073/debian-11-backports-generic-amd64-20220711-1073.qcow2"
|
||||
)
|
||||
|
||||
volume = lv.Volume("disk",
|
||||
base_volume_id = baseimg.id,
|
||||
pool = pool.name,
|
||||
size = config.require("disksize") * 1024 ** 3
|
||||
)
|
||||
|
||||
# Stream configuration files
|
||||
userdata = open("./user-data", "r").read()
|
||||
metadata = open("./meta-data", "r").read()
|
||||
networkconfig = open("./network-config", "r").read()
|
||||
|
||||
cloudinit = lv.CloudInitDisk("cloud-init",
|
||||
meta_data = metadata,
|
||||
user_data = userdata,
|
||||
network_config = networkconfig
|
||||
)
|
||||
|
||||
vm = lv.Domain("debian11",
|
||||
boot_devices = [ lv.DomainBootDeviceArgs(
|
||||
devs = [ "hd", "cdrom" ]
|
||||
) ],
|
||||
cloudinit = cloudinit.id,
|
||||
disks = [ lv.DomainDiskArgs(volume_id = volume.id) ],
|
||||
memory = config.require("memory"),
|
||||
network_interfaces = [ lv.DomainNetworkInterfaceArgs(
|
||||
network_name = "default",
|
||||
wait_for_lease = True
|
||||
) ],
|
||||
consoles = [ lv.DomainConsoleArgs(
|
||||
type = "pty",
|
||||
target_port = 0,
|
||||
target_type = "serial"
|
||||
) ],
|
||||
opts = pulumi.ResourceOptions(
|
||||
custom_timeouts = pulumi.CustomTimeouts(create = "3m")
|
||||
)
|
||||
)
|
||||
|
||||
pulumi.export("ip", vm.network_interfaces[0]['addresses'][0])
|
2
libvirt-python/cloud-init/meta-data
Normal file
2
libvirt-python/cloud-init/meta-data
Normal file
@ -0,0 +1,2 @@
|
||||
instance-id: debian11
|
||||
local-hostname: debian11
|
4
libvirt-python/cloud-init/network-config
Normal file
4
libvirt-python/cloud-init/network-config
Normal file
@ -0,0 +1,4 @@
|
||||
version: 2
|
||||
ethernets:
|
||||
interface0:
|
||||
dhcp4: true
|
24
libvirt-python/cloud-init/user-data
Normal file
24
libvirt-python/cloud-init/user-data
Normal file
@ -0,0 +1,24 @@
|
||||
#cloud-config
|
||||
resize_rootfs: true
|
||||
users:
|
||||
- name: syntaxerrormmm
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
groups: users, admin
|
||||
shell: /bin/bash
|
||||
ssh_authorized_keys:
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFioHkaV1NhX6NCqsJakJw8EVBOcDHm1MEbpY499CPtG syntaxerrormmm@fisso
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILu91hBh8pNRt4eE1pug0Y4jCHZDCcMJ+vj3CiF5EQHV syntaxerrormmm@syntaxxps
|
||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP/hn/0xn6DRS2B0paFzDQRakupgTQQ5hitQhqOfWcqz syntaxerrormmm@microbo
|
||||
hashed_passwd: $6$rounds=4096$4ZUeoch.EwyR/TLb$.71i1otUQpw2eMlrjcP3H4XxsnLlVbIQxagFDGviOvCaIz7ONa.tTZPO09YL7hiAh4vLaTcGD43VoAM6tEYjx/
|
||||
ssh_pwauth: true
|
||||
disable_root: false
|
||||
chpasswd:
|
||||
expire: false
|
||||
list: |
|
||||
root:$6$rounds=4096$4ZUeoch.EwyR/TLb$.71i1otUQpw2eMlrjcP3H4XxsnLlVbIQxagFDGviOvCaIz7ONa.tTZPO09YL7hiAh4vLaTcGD43VoAM6tEYjx/
|
||||
syntaxerrormmm:$6$rounds=4096$4ZUeoch.EwyR/TLb$.71i1otUQpw2eMlrjcP3H4XxsnLlVbIQxagFDGviOvCaIz7ONa.tTZPO09YL7hiAh4vLaTcGD43VoAM6tEYjx/
|
||||
#packages:
|
||||
# - qemu-guest-agent
|
||||
#power_state:
|
||||
# delay: now
|
||||
# mode: reboot
|
2
libvirt-python/requirements.txt
Normal file
2
libvirt-python/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
pulumi>=3.0.0,<4.0.0
|
||||
pulumi_libvirt>=0.3.0
|
Loading…
Reference in New Issue
Block a user