Re-aligned the base for libvirt.
This commit is contained in:
parent
69ca9a8f6a
commit
888e1247ab
@ -1,8 +1,8 @@
|
|||||||
|
pyyaml>=6.0
|
||||||
|
dotmap>=1.3.30
|
||||||
|
protobuf==3.20.1
|
||||||
pulumi>=3.0.0,<4.0.0
|
pulumi>=3.0.0,<4.0.0
|
||||||
pulumi_libvirt>=0.3.0
|
pulumi_libvirt>=0.3.0
|
||||||
pulumi-command>=0.4.1
|
pulumi-command>=0.4.1
|
||||||
pyyaml>=6.0
|
|
||||||
Jinja2>=3.1.2
|
Jinja2>=3.1.2
|
||||||
dotmap>=1.3.30
|
|
||||||
passlib>=1.7.4
|
passlib>=1.7.4
|
||||||
protobuf==3.20.1
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
name: ${PROJECT}
|
name: ${PROJECT}
|
||||||
description: ${DESCRIPTION}
|
description: ${DESCRIPTION}
|
||||||
runtime: python
|
runtime: python
|
||||||
|
@ -1,31 +1,29 @@
|
|||||||
"""A Pulumi-based infrastructure with libvirt and Python"""
|
"""A Pulumi deployment with libvirt and Python"""
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
from dotmap import DotMap
|
||||||
import pulumi
|
import pulumi
|
||||||
import pulumi_libvirt as lv
|
import pulumi_libvirt as lv
|
||||||
|
from passlib.hash import sha512_crypt
|
||||||
|
from jinja2 import Template
|
||||||
|
|
||||||
|
conf = DotMap(yaml.safe_load(open("input.yaml").read()))
|
||||||
|
conf.password = sha512_crypt.hash(conf.password, rounds=4096)
|
||||||
config = pulumi.Config()
|
config = pulumi.Config()
|
||||||
|
|
||||||
pool = lv.Pool("default",
|
pool = lv.Pool("mypool", type = "dir", path = conf.poolpath)
|
||||||
type = "dir",
|
baseimg = lv.Volume("myimage", pool = pool.name, source = conf.image_url)
|
||||||
path = "/var/tmp/libvirt/pulumi"
|
|
||||||
)
|
|
||||||
|
|
||||||
baseimg = lv.Volume("base-image",
|
volume = lv.Volume("mydisk",
|
||||||
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,
|
base_volume_id = baseimg.id,
|
||||||
pool = pool.name,
|
pool = pool.name,
|
||||||
size = int(config.require("disksize")) * 1024 ** 3
|
size = int(conf.disksize) * 1024 ** 3
|
||||||
)
|
)
|
||||||
|
|
||||||
# Stream configuration files
|
# Stream configuration files
|
||||||
userdata = open("./cloud-init/user-data", "r").read()
|
userdata = Template(open("./cloud-init/user-data.jinja").read()).render(conf)
|
||||||
metadata = open("./cloud-init/meta-data", "r").read()
|
metadata = Template(open("./cloud-init/meta-data.jinja").read()).render(conf)
|
||||||
networkconfig = open("./cloud-init/network-config", "r").read()
|
networkconfig = open("./cloud-init/network-config").read()
|
||||||
|
|
||||||
cloudinit = lv.CloudInitDisk("cloud-init",
|
cloudinit = lv.CloudInitDisk("cloud-init",
|
||||||
meta_data = metadata,
|
meta_data = metadata,
|
||||||
@ -33,13 +31,14 @@ cloudinit = lv.CloudInitDisk("cloud-init",
|
|||||||
network_config = networkconfig
|
network_config = networkconfig
|
||||||
)
|
)
|
||||||
|
|
||||||
vm = lv.Domain("debian11",
|
vm = lv.Domain(conf.name,
|
||||||
boot_devices = [ lv.DomainBootDeviceArgs(
|
boot_devices = [ lv.DomainBootDeviceArgs(
|
||||||
devs = [ "hd", "cdrom" ]
|
devs = [ "hd", "cdrom" ]
|
||||||
) ],
|
) ],
|
||||||
cloudinit = cloudinit.id,
|
cloudinit = cloudinit.id,
|
||||||
|
vcpus = conf.vcpu,
|
||||||
disks = [ lv.DomainDiskArgs(volume_id = volume.id) ],
|
disks = [ lv.DomainDiskArgs(volume_id = volume.id) ],
|
||||||
memory = int(config.require("memory")),
|
memory = int(conf.ram),
|
||||||
network_interfaces = [ lv.DomainNetworkInterfaceArgs(
|
network_interfaces = [ lv.DomainNetworkInterfaceArgs(
|
||||||
network_name = "default",
|
network_name = "default",
|
||||||
wait_for_lease = True
|
wait_for_lease = True
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
instance-id: debian11
|
|
||||||
local-hostname: debian11
|
|
2
libvirt-python/cloud-init/meta-data.jinja
Normal file
2
libvirt-python/cloud-init/meta-data.jinja
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
instance-id: {{ name }}
|
||||||
|
local-hostname: {{ name }}
|
@ -1,24 +0,0 @@
|
|||||||
#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
|
|
24
libvirt-python/cloud-init/user-data.jinja
Normal file
24
libvirt-python/cloud-init/user-data.jinja
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#cloud-config
|
||||||
|
resize_rootfs: true
|
||||||
|
users:
|
||||||
|
- name: {{ username }}
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
|
groups: users, admin
|
||||||
|
shell: /bin/bash
|
||||||
|
ssh_authorized_keys:
|
||||||
|
{% for key in sshkeys %}
|
||||||
|
- "{{ key }}"
|
||||||
|
{% endfor %}
|
||||||
|
hashed_passwd: {{ password }}
|
||||||
|
ssh_pwauth: true
|
||||||
|
disable_root: false
|
||||||
|
chpasswd:
|
||||||
|
expire: false
|
||||||
|
list: |
|
||||||
|
root:{{ password }}
|
||||||
|
syntaxerrormmm:{{ password }}
|
||||||
|
#packages:
|
||||||
|
# - qemu-guest-agent
|
||||||
|
#power_state:
|
||||||
|
# delay: now
|
||||||
|
# mode: reboot
|
15
libvirt-python/input.yaml
Normal file
15
libvirt-python/input.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
# Basic VM configuration
|
||||||
|
name: virtual-machine
|
||||||
|
vcpu: 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"
|
||||||
|
|
||||||
|
image_url: "https://cdimage.debian.org/images/cloud/bullseye-backports/20220711-1073/debian-11-backports-generic-amd64-20220711-1073.qcow2"
|
||||||
|
poolpath: /var/tmp/libvirt/pulumi
|
@ -1,2 +1,7 @@
|
|||||||
|
pyyaml>=6.0
|
||||||
|
dotmap>=1.3.30
|
||||||
|
protobuf==3.20.1
|
||||||
pulumi>=3.0.0,<4.0.0
|
pulumi>=3.0.0,<4.0.0
|
||||||
pulumi_libvirt>=0.3.0
|
pulumi_libvirt>=0.3.0
|
||||||
|
Jinja2>=3.1.2
|
||||||
|
passlib>=1.7.4
|
||||||
|
Loading…
Reference in New Issue
Block a user