1
0
Files
pve-lab/cloud-init/user-data
2026-08-02 10:40:47 -05:00

68 lines
1.7 KiB
Plaintext

#cloud-config
# Storage VM: serves both NFS and iSCSI to the PVE nodes.
# @@...@@ placeholders are rendered by 05-storage-vm.sh.
hostname: pvestore
fqdn: pvestore.lab.local
manage_etc_hosts: true
# The lab NAT network is IPv4-only; Debian mirrors resolve to IPv6 too, so force
# apt onto IPv4 and refresh the index before installing.
package_update: true
apt:
conf: |
Acquire::ForceIPv4 "true";
users:
- name: root
ssh_authorized_keys:
- "@@SSH_PUBKEY@@"
ssh_pwauth: true
chpasswd:
expire: false
users:
- name: root
password: "@@ROOT_PASSWORD@@"
type: text
# The second disk (vdb) becomes the home for the NFS tree and the iSCSI LUN.
disk_setup:
/dev/vdb:
table_type: gpt
layout: true
overwrite: true
fs_setup:
- device: /dev/vdb1
filesystem: ext4
label: data
overwrite: true
mounts:
- ["/dev/vdb1", "/srv", "ext4", "defaults,nofail", "0", "2"]
packages:
- nfs-kernel-server
- tgt
write_files:
- path: /etc/exports
content: |
/srv/nfs 10.10.10.0/24(rw,sync,no_subtree_check,no_root_squash)
- path: /etc/tgt/conf.d/lab.conf
content: |
<target @@ISCSI_IQN@@>
backing-store /srv/iscsi/lun0.img
initiator-address 10.10.10.11
initiator-address 10.10.10.12
</target>
runcmd:
- [ mkdir, -p, /srv/nfs, /srv/iscsi ]
- [ chmod, "0777", /srv/nfs ]
# sparse backing file for the iSCSI LUN
- [ truncate, -s, "@@ISCSI_LUN_GB@@G", /srv/iscsi/lun0.img ]
- [ exportfs, -ra ]
- [ systemctl, enable, --now, nfs-server ]
- [ systemctl, enable, --now, tgt ]
- [ systemctl, restart, tgt ]
- [ sh, -c, "tgtadm --mode target --op show > /var/log/tgt-targets.log 2>&1 || true" ]