Class: Vmit::Kickstart
- Inherits:
-
UnattendedInstall
- Object
- UnattendedInstall
- Vmit::Kickstart
- Defined in:
- lib/vmit/kickstart.rb
Instance Attribute Summary
Attributes inherited from UnattendedInstall
Instance Method Summary collapse
- #execute_autoinstall(vm, args) ⇒ Object
-
#initialize(location) ⇒ Kickstart
constructor
A new instance of Kickstart.
- #to_ks_script ⇒ Object
Constructor Details
#initialize(location) ⇒ Kickstart
Returns a new instance of Kickstart.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vmit/kickstart.rb', line 29 def initialize(location) super(location) media = Vmit::VFS.from(location) case media when Vmit::VFS::URI @install = location when Vmit::VFS::ISO @install = :cdrom vm.config.configure(:cdrom => location.to_s) else raise ArgumentError.new("Unsupported autoinstallation: #{location}") end end |
Instance Method Details
#execute_autoinstall(vm, args) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/vmit/kickstart.rb', line 43 def execute_autoinstall(vm, args) vm.config.push! begin vm.config.configure(args) if @install == :cdrom vm.config.configure(:cdrom => location.to_s) end Dir.mktmpdir do |floppy_dir| FileUtils.chmod_R 0755, floppy_dir vm.config.floppy = floppy_dir vm.config.add_kernel_cmdline!('ks=floppy') vm.config.add_kernel_cmdline!("repo=#{@install}") vm.config.reboot = false File.write(File.join(floppy_dir, 'ks.cfg'), to_ks_script) Vmit.logger.info "Kickstart: 1st stage." vm.up vm.wait_until_shutdown! do vm.vnc end end ensure vm.config.pop! end end |
#to_ks_script ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/vmit/kickstart.rb', line 70 def to_ks_script template = ERB.new "cmdline\nhalt\nrootpw linux\nlang en_US.UTF-8\nkeyboard us\ntimezone --utc America/New_York\nbootloader --location=mbr --driveorder=sda --append=\"rhgb quiet\"\ninstall\n<% if @install.is_a?(String) || @install.is_a?(::URI)%>\nurl --url=<%= @install.to_s.strip %>\n<% else %>\n<%= @install %>\n<% end %>\nnetwork --device eth0 --bootproto dhcp\nzerombr yes\nclearpart --all --initlabel\nautopart\n%packages --nobase\n@core\n@server-policy\nwget\nmc\n\n%end\n" template.result(binding) end |