Created
June 30, 2015 07:44
-
-
Save youyo/8a7eadcadd9e17738bdf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -u | |
| if [ $# -ne 9 ]; then | |
| echo -e "Usage:\t${0} HOSTNAME PASSWORD VCPU MEMORY SWAP DISK IPADDRESS NETMASK GATEWAY" | |
| exit 99 | |
| fi | |
| HOSTNAME=${1?need hostname} | |
| PASSWORD=${2?need password} | |
| VCPU=${3?need vcpu} | |
| MEMORY=${4?need memory} | |
| SWAP=${5?need swap} | |
| DISK=${6?need disk} | |
| IPADDRESS=${7?need ipaddress} | |
| NETMASK=${8?need netmask} | |
| GATEWAY=${9?need gateway} | |
| LOCATION='/var/lib/libvirt/images/CentOS-6.6-x86_64-bin-DVD1.iso' | |
| XMLPATH='/etc/libvirt/qemu' | |
| KS_URL="http://kickstart-sinatra.herokuapp.com/kickstart/${HOSTNAME}/${IPADDRESS}/${NETMASK}/${GATEWAY}/${PASSWORD}/${SWAP}" | |
| virt-install \ | |
| --connect qemu:///system \ | |
| --name ${HOSTNAME} \ | |
| --hvm \ | |
| --virt-type kvm \ | |
| --ram ${MEMORY} \ | |
| --vcpus ${VCPU},maxvcpus=8 \ | |
| --arch x86_64 \ | |
| --os-type linux \ | |
| --os-variant rhel6 \ | |
| --disk path=/var/lib/libvirt/images/${HOSTNAME}.qcow2.img,size=${DISK},format=qcow2 \ | |
| --network bridge=br0 \ | |
| --graphics vnc,listen=127.0.0.1,keymap=ja \ | |
| --serial pty \ | |
| --console pty \ | |
| --noautoconsole --wait -1 \ | |
| --location=${LOCATION} \ | |
| --extra-args "ks=${KS_URL} console=tty0 console=ttyS0,115200n8 edd=off keymap=ja ip=${IPADDRESS} netmask=${NETMASK} gateway=${GATEWAY} dns=8.8.8.8" \ | |
| --noreboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment