Created
December 29, 2019 06:51
-
-
Save nowa/0b316e51cd0d66b1bce5d970f9cdb3a3 to your computer and use it in GitHub Desktop.
Set custom cloud config to a pve vm which uses coreos with nfs mount settings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
hostname: "coreos1" | |
ssh_authorized_keys: | |
- ssh-rsa xxx | |
write-files: | |
- path: /etc/conf.d/nfs | |
permissions: '0644' | |
content: | | |
OPTS_RPC_MOUNTD="" | |
coreos: | |
units: | |
- name: rpc-statd.service | |
command: start | |
enable: true | |
- name: mnt-foo.mount | |
command: start | |
content: | | |
[Mount] | |
What=192.168.xx.xx:/volume1/foo | |
Where=/mnt/foo | |
Type=nfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERCONFIG_DEFAULT=none | |
SNIPPETSPATH=/var/lib/vz/snippets | |
OSNAME=coreos | |
VMID_DEFAULT=56000 | |
read -p "Enter a VM ID for $OSNAME [$VMID_DEFAULT]: " VMID | |
VMID=${VMID:-$VMID_DEFAULT} | |
printf "\n*** The script can add a cloud-init configuration with users and SSH keys from a file in the current directory.\n" | |
read -p "Supply the name of the cloud-init-config.yml (this will be skipped, if file not found) [$USERCONFIG_DEFAULT]: " USERCONFIG | |
USERCONFIG=${USERCONFIG:-$USERCONFIG_DEFAULT} | |
if [ -f $PWD/$USERCONFIG ] | |
then | |
# The cloud-init user config file overrides the user settings done elsewhere | |
printf "\n** Adding user configuration\n" | |
cp -v $PWD/$USERCONFIG $SNIPPETSPATH/$VMID-$OSNAME-$USERCONFIG | |
qm set $VMID --cicustom "user=local:snippets/$VMID-$OSNAME-$USERCONFIG" | |
printf "#* cloud-config: $VMID-$OSNAME-$USERCONFIG\n" >> /etc/pve/qemu-server/$VMID.conf | |
fi | |
printf "\n*** The following cloud-init configuration for User and Network will be used ***\n\n" | |
qm cloudinit dump $VMID user | |
printf "\n------------------------------\n" | |
qm cloudinit dump $VMID network | |
printf "Done.\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment