From 4647fcd2c836342e7319ed4f9cffe9f8ab7fe96f Mon Sep 17 00:00:00 2001 From: Brielle Bruns Date: Sun, 13 May 2018 19:22:33 -0600 Subject: [PATCH] Improve config file method, and begin work on making network configuration less... hackish. --- config | 22 ++++++++++++++++++++++ network/network-config-dhcp-v1 | 10 ++++++++++ network/network-config-v1 | 17 +++++++++++++++++ virt-install-cloud.sh | 31 +++++++++++++++---------------- 4 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 config create mode 100644 network/network-config-dhcp-v1 create mode 100644 network/network-config-v1 diff --git a/config b/config new file mode 100644 index 0000000..96330ce --- /dev/null +++ b/config @@ -0,0 +1,22 @@ +# Config file +# Don't edit this directly unless you really must and don't +# keep this tree under git control. +# To make changes, put overrides in config.local + +# KVM pool paths +POOL=images +POOL_PATH=/data/images +POOL=${DEF_POOL} +POOL_PATH=${DEF_POOL_PATH} + +# vm prefs : specify vm preferences for your guest +BACKUP_ISO_FILES=no # yes or no + +net_interface="bridge=${bridge},model=virtio" + +# guest image format: qcow2 or raw +FORMAT=raw + +# convert image format : yes or no +CONVERT=yes + diff --git a/network/network-config-dhcp-v1 b/network/network-config-dhcp-v1 new file mode 100644 index 0000000..37ffaa4 --- /dev/null +++ b/network/network-config-dhcp-v1 @@ -0,0 +1,10 @@ +## /network-config +--- +version: 1 +config: +- type: physical + name: eth0 + subnets: + - type: dhcp +- type: nameserver + search: [%%DOMAIN%%] \ No newline at end of file diff --git a/network/network-config-v1 b/network/network-config-v1 new file mode 100644 index 0000000..2c650c9 --- /dev/null +++ b/network/network-config-v1 @@ -0,0 +1,17 @@ +## /network-config +--- +version: 1 +config: +- type: physical + name: eth0 + subnets: + - type: static + address: %%IP_ADDRESS%% + netmask: %%NETMASK%% + routes: + - network: 0.0.0.0 + netmask: 0.0.0.0 + gateway: %%GATEWAY%% +- type: nameserver + address: [%%NAME_SERVER%%] + search: [%%DOMAIN%%] \ No newline at end of file diff --git a/virt-install-cloud.sh b/virt-install-cloud.sh index 61ff586..551c976 100755 --- a/virt-install-cloud.sh +++ b/virt-install-cloud.sh @@ -1,12 +1,12 @@ #!/bin/bash # Heavily Modified Script By: Brielle Bruns -# Date: 04/11/2018 +# Date: 05/13/2018 # URL: https://git.sosdg.org/brielle/virt-install-cloud # Version: 1.0 # # Originally based on: # virt-install-cloud.sh : script to start an OpenStack cloud image on kvm -# version : 1.1.2 +# version : 1.2 # # Author : Claude Durocher # License : GPLv3 @@ -24,6 +24,9 @@ if [[ $USER != "root" ]]; then echo "This script must be run as root!" && exit 1 fi + +WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) + usage() { echo "${0} Help" echo -e "\t-h show this help" @@ -33,6 +36,7 @@ usage() { echo -e "\t-r ram size (in megabytes) *" echo -e "\t-c number of vcpus" echo -e "\t-b bridge to attach to *" + echo -e "\t-x network info (ip:netmask:gateway)" echo -e "\t-i distribution to use (see script for supported options) - default is stretch" echo -e "\t-o OS type and variant (default: generic:generic - also set by distro option when available)" } @@ -82,21 +86,16 @@ arch="amd64" source distros +if [[ -f ${WORKING_DIR}/config ]]; then + source ${WORKING_DIR}/config +else + echo "Error: Missing ${WORKING_DIR}/config !" + exit 1 +fi -# kvm defaults pool paths -DEF_POOL=images -DEF_POOL_PATH=/data/images -# vm prefs : specify vm preferences for your guest -BACKUP_ISO_FILES=no # yes or no - -net_interface="bridge=${bridge},model=virtio" -# guest image format: qcow2 or raw -FORMAT=raw -# convert image format : yes or no -CONVERT=yes -# kvm pool -POOL=images -POOL_PATH=/data/images +if [[ -f config.local ]]; then + source config.local +fi sed -e "s/%GUEST_NAME%/${hostname}/" meta-data > output/meta-data sed -e "s/%FQDN%/${hostname}.${domain}/" user-data > output/user-data