class AMIKickstart::Centos
Constants
- INITRD_PATH
- KERNEL_PATH
Public Class Methods
new(vncpassword, ks_url)
click to toggle source
# File lib/ami_kickstart/centos.rb, line 8 def initialize(vncpassword, ks_url) @vncpassword = vncpassword @ks_url = ks_url end
Public Instance Methods
add_kernel_to_grub()
click to toggle source
# File lib/ami_kickstart/centos.rb, line 46 def add_kernel_to_grub args = "vnc vncpassword=#{@vncpassword} ip=dhcp ks=#{@ks_url} method=http://mirror.centos.org/centos/7/os/x86_64/" system! %(grubby --make-default --add-kernel #{KERNEL_PATH} --initrd #{INITRD_PATH} --title="Centos Kickstart" --args="#{args}") end
download(url, outfile)
click to toggle source
# File lib/ami_kickstart/centos.rb, line 26 def download(url, outfile) return if File.exist? outfile system! "curl '#{url}' > /tmp/amif" FileUtils.mv "/tmp/amif", outfile end
download_initrd()
click to toggle source
# File lib/ami_kickstart/centos.rb, line 37 def download_initrd url = "http://mirror.centos.org/centos/7/os/x86_64/isolinux/initrd.img" download url, INITRD_PATH end
download_kernel()
click to toggle source
# File lib/ami_kickstart/centos.rb, line 32 def download_kernel url = "http://mirror.centos.org/centos/7/os/x86_64/isolinux/vmlinuz" download url, KERNEL_PATH end
kickstart()
click to toggle source
# File lib/ami_kickstart/centos.rb, line 13 def kickstart download_kernel download_initrd remove_kernel_from_grub add_kernel_to_grub reboot end
reboot()
click to toggle source
# File lib/ami_kickstart/centos.rb, line 51 def reboot print "Reboot(y/n): " answer = gets.chomp.strip.downcase if answer == "y" system "/sbin/reboot" end end
remove_kernel_from_grub()
click to toggle source
# File lib/ami_kickstart/centos.rb, line 42 def remove_kernel_from_grub system! "grubby --remove-kernel #{KERNEL_PATH}" end
system!(command)
click to toggle source
# File lib/ami_kickstart/centos.rb, line 21 def system!(command) ok = system command raise "Error running command #{command}" if not ok end