Advertisement
Guest User

preseed template

a guest
Feb 19th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. <%#
  2. kind: provision
  3. name: Preseed default
  4. oses:
  5. - Debian
  6. - Ubuntu
  7. %>
  8. <%
  9. proxy_string = host_param('http-proxy') ? " http://#{host_param('http-proxy')}:#{host_param('http-proxy-port')}" : ''
  10. salt_enabled = host_param('salt_master') ? true : false
  11. os_major = @host.operatingsystem.major.to_i
  12. squeeze_or_older = (@host.operatingsystem.name == 'Debian' && os_major <= 6)
  13. %>
  14. # Locale
  15. d-i debian-installer/locale string <%= host_param('lang') || 'en_US' %>
  16. # country and keyboard settings are automatic. Keep them ...
  17. # ... for wheezy and newer:
  18. d-i keyboard-configuration/xkb-keymap seen true
  19. <% if squeeze_or_older -%>
  20. # ... for squeeze and older:
  21. d-i console-keymaps-at/keymap seen true
  22. <% end -%>
  23.  
  24. <% subnet = @host.subnet -%>
  25. <% if subnet.respond_to?(:dhcp_boot_mode?) -%>
  26. <% dhcp = subnet.dhcp_boot_mode? && !@static -%>
  27. <% else -%>
  28. <% dhcp = !@static -%>
  29. <% end -%>
  30. <% unless dhcp -%>
  31. # Static network configuration.
  32. d-i preseed/early_command string /bin/killall.sh; /bin/netcfg
  33. d-i netcfg/disable_autoconfig boolean true
  34. d-i netcfg/dhcp_failed note
  35. d-i netcfg/dhcp_options select Configure network manually
  36. d-i netcfg/disable_dhcp boolean true
  37. d-i netcfg/get_ipaddress string <%= @host.ip %>
  38. d-i netcfg/get_netmask string <%= subnet.mask %>
  39. d-i netcfg/get_nameservers string <%= [subnet.dns_primary,subnet.dns_secondary].reject{|n| n.blank?}.join(' ') %>
  40. d-i netcfg/get_gateway string <%= subnet.gateway %>
  41. d-i netcfg/confirm_static boolean true
  42. <% end -%>
  43.  
  44. # Network configuration
  45. d-i netcfg/choose_interface select auto
  46. d-i netcfg/get_hostname string <%= @host %>
  47. d-i netcfg/get_domain string <%= @host.domain %>
  48. d-i netcfg/wireless_wep string
  49.  
  50. d-i hw-detect/load_firmware boolean true
  51.  
  52. <% if host_param_true?('preseed-live-installer') -%>
  53. # Offline live-installer location
  54. d-i live-installer/net-image string http://<%= @preseed_server %><%= @preseed_path %>/install/filesystem.squashfs
  55. <% end -%>
  56.  
  57. # Mirror settings
  58. d-i mirror/country string manual
  59. d-i mirror/http/hostname string <%= @preseed_server %>
  60. d-i mirror/http/directory string <%= @preseed_path %>
  61. d-i mirror/http/proxy string<%= proxy_string %>
  62. d-i mirror/codename string <%= @host.operatingsystem.release_name %>
  63. d-i mirror/suite string <%= @host.operatingsystem.release_name %>
  64. d-i mirror/udeb/suite string <%= @host.operatingsystem.release_name %>
  65.  
  66. # Time settings
  67. d-i clock-setup/utc boolean true
  68. d-i time/zone string <%= host_param('time-zone') || 'UTC' %>
  69.  
  70. # NTP
  71. d-i clock-setup/ntp boolean true
  72. d-i clock-setup/ntp-server string <%= host_param('ntp-server') || '0.debian.pool.ntp.org' %>
  73.  
  74. # Set alignment for automatic partitioning
  75. # Choices: cylinder, minimal, optimal
  76. #d-i partman/alignment select cylinder
  77.  
  78. <%= @host.diskLayout %>
  79.  
  80. <% if host_param('preseed-kernel-image') -%>
  81. # Install different kernel
  82. d-i base-installer/kernel/image string <%= host_param('preseed-kernel-image') %>
  83. <% end %>
  84.  
  85. # User settings
  86. d-i passwd/root-password-crypted password <%= root_pass %>
  87. user-setup-udeb passwd/root-login boolean true
  88. d-i passwd/make-user boolean false
  89. user-setup-udeb passwd/make-user boolean false
  90.  
  91. <% repos = 0 %>
  92.  
  93. <% if salt_enabled -%>
  94. <% salt_package = 'salt-minion' -%>
  95. <% if host_param_true?('enable-saltstack-repo') -%>
  96. <% if @host.operatingsystem.name == 'Debian' -%>
  97. d-i apt-setup/local<%= repos %>/repository string http://debian.saltstack.com/debian <%= @host.operatingsystem.release_name %>-saltstack main
  98. d-i apt-setup/local<%= repos %>/comment string SaltStack Repository
  99. d-i apt-setup/local<%= repos %>/key string http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key
  100. <% repos += 1 -%>
  101. <% end -%>
  102. <% if @host.operatingsystem.name == 'Ubuntu' -%>
  103. d-i apt-setup/local<%= repos %>/repository string http://ppa.launchpad.net/saltstack/salt/ubuntu <%= @host.operatingsystem.release_name %> main
  104. d-i apt-setup/local<%= repos %>/comment string SaltStack Repository
  105. d-i apt-setup/local<%= repos %>/key string http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x4759FA960E27C0A6
  106. <% repos += 1 -%>
  107. <% end -%>
  108. <% end -%>
  109. <% else -%>
  110. <% salt_package = '' -%>
  111. <% end -%>
  112.  
  113. # Install minimal task set (see tasksel --task-packages minimal)
  114. tasksel tasksel/first multiselect minimal, ssh-server, openssh-server
  115.  
  116. # Install some base packages
  117. d-i pkgsel/include string <%= salt_package %> lsb-release
  118. d-i pkgsel/update-policy select <%= host_param('preseed-update-policy') || 'unattended-upgrades' %>
  119. d-i pkgsel/upgrade select <%= host_param('preseed-post-install-upgrade') || 'none' %>
  120.  
  121. popularity-contest popularity-contest/participate boolean false
  122.  
  123. # Boot loader settings
  124. #grub-pc grub-pc/hidden_timeout boolean false
  125. #grub-pc grub-pc/timeout string 10
  126. d-i grub-installer/only_debian boolean true
  127. d-i grub-installer/with_other_os boolean true
  128. <% if host_param('install-disk') -%>
  129. d-i grub-installer/bootdev string <%= host_param('install-disk') %>
  130. <% elsif (@host.operatingsystem.name == 'Debian' and @host.operatingsystem.major.to_i >= 8) or (@host.operatingsystem.name == 'Ubuntu' and @host.operatingsystem.major.to_i >= 16) -%>
  131. d-i grub-installer/bootdev string default
  132. <% end -%>
  133. d-i finish-install/reboot_in_progress note
  134.  
  135. d-i preseed/late_command string wget -Y off <%= @static ? "'#{foreman_url('finish')}&static=true'" : foreman_url('finish') %> -O /target/tmp/finish.sh && in-target chmod +x /tmp/finish.sh && in-target /tmp/finish.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement