Advertisement
Linkz

Seed

Dec 24th, 2020
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. <%#
  2. kind: provision
  3. name: Preseed default
  4. model: ProvisioningTemplate
  5. oses:
  6. - Debian
  7. - Ubuntu
  8. %>
  9. <%
  10. proxy_string = host_param('http-proxy') ? " http://#{host_param('http-proxy')}:#{host_param('http-proxy-port')}" : ''
  11. ansible_enabled = plugin_present?('foreman_ansible')
  12. salt_enabled = host_param('salt_master') ? true : false
  13. os_major = @host.operatingsystem.major.to_i
  14. squeeze_or_older = (@host.operatingsystem.name == 'Debian' && os_major <= 6)
  15. python_package = (@host.operatingsystem.name == 'Ubuntu' && os_major >= 20) ? 'python3' : 'python'
  16.  
  17. additional_packages = ['lsb-release', 'wget']
  18. additional_packages << host_param('additional-packages')
  19. additional_packages << python_package if ansible_enabled
  20. additional_packages << 'salt-minion' if salt_enabled
  21. additional_packages = additional_packages.join(" ").split().uniq().join(" ")
  22. %>
  23. # Locale
  24. d-i debian-installer/locale string <%= host_param('lang') || 'en_US' %>
  25. # country and keyboard settings are automatic. Keep them ...
  26. # ... for wheezy and newer:
  27. d-i console-setup/ask_detect boolean false
  28. d-i keyboard-configuration/xkb-keymap select us
  29. d-i console-setup/layoutcode string US
  30. d-i console-setup/variantcode string
  31. <% if squeeze_or_older -%>
  32. # ... for squeeze and older:
  33. d-i console-keymaps-at/keymap seen true
  34. <% end -%>
  35.  
  36. <% subnet = @host.subnet -%>
  37. <% if @static -%>
  38. <%- dhcp = false -%>
  39. <% elsif subnet.nil? -%>
  40. <%- dhcp = true -%>
  41. <% else -%>
  42. <%- dhcp = subnet.dhcp_boot_mode? -%>
  43. <% end -%>
  44. <% unless dhcp -%>
  45. # Static network configuration.
  46. d-i preseed/early_command string /bin/killall.sh; /bin/netcfg
  47. d-i netcfg/disable_autoconfig boolean true
  48. d-i netcfg/dhcp_failed note
  49. d-i netcfg/dhcp_options select Configure network manually
  50. d-i netcfg/disable_dhcp boolean true
  51. d-i netcfg/get_ipaddress string <%= @host.ip %>
  52. d-i netcfg/get_netmask string <%= subnet.mask %>
  53. d-i netcfg/get_nameservers string <%= subnet.dns_servers.join(' ') %>
  54. d-i netcfg/get_gateway string <%= subnet.gateway %>
  55. d-i netcfg/confirm_static boolean true
  56. <% end -%>
  57.  
  58. # Network configuration
  59. d-i netcfg/choose_interface select auto
  60. d-i netcfg/hostname string changeme
  61. d-i netcfg/wireless_wep string
  62.  
  63. d-i hw-detect/load_firmware boolean true
  64.  
  65. <% if host_param_true?('preseed-live-installer') -%>
  66. # Offline live-installer location
  67. d-i live-installer/net-image string http://<%= @preseed_server %><%= @preseed_path %>/install/filesystem.squashfs
  68. <% end -%>
  69.  
  70. # Mirror settings
  71. d-i mirror/country string us
  72. d-i mirror/http/hostname string <%= @preseed_server %>
  73. d-i mirror/http/directory string <%= @preseed_path %>
  74. d-i mirror/http/proxy string<%= proxy_string %>
  75. d-i mirror/codename string <%= @host.operatingsystem.release_name %>
  76. d-i mirror/suite string <%= @host.operatingsystem.release_name %>
  77. d-i mirror/udeb/suite string <%= @host.operatingsystem.release_name %>
  78.  
  79. # Time settings
  80. d-i clock-setup/utc boolean true
  81. d-i time/zone string <%= host_param('time-zone') || 'UTC' %>
  82.  
  83. # NTP
  84. d-i clock-setup/ntp boolean true
  85. d-i clock-setup/ntp-server string ntp.ubuntu.com
  86.  
  87. # Set alignment for automatic partitioning
  88. # Choices: cylinder, minimal, optimal
  89. #d-i partman/alignment select cylinder
  90.  
  91. <%= @host.diskLayout %>
  92.  
  93. <% if host_param('preseed-kernel-image') -%>
  94. # Install different kernel
  95. d-i base-installer/kernel/image string <%= host_param('preseed-kernel-image') %>
  96. <% end %>
  97.  
  98. # User settings
  99. d-i passwd/root-password-crypted password <%= root_pass %>
  100. user-setup-udeb passwd/root-login boolean false
  101. d-i passwd/user-fullname string user
  102. d-i passwd/username string user
  103. d-i passwd/user-password-crypted password $1$CHp7HkQW$Z2ZTY5cZMurbwbqU1zaS.1
  104. d-i user-setup/encrypt-home boolean false
  105.  
  106. <% repos = 0 %>
  107.  
  108. <% @additional_media.each do |medium| -%>
  109. d-i apt-setup/local<%= repos %>/repository string <%= medium[:url] %> <%= @host.operatingsystem.release_name %>-<%= medium[:name] %> main
  110. <%= "d-i apt-setup/local#{repos}/comment string #{medium[:comment]}" if medium[:comment] %>
  111. <%= "d-i apt-setup/local#{repos}/key string #{medium[:gpgkey]}" if medium[:gpgkey] %>
  112. <% repos +=1 -%>
  113. <% end -%>
  114.  
  115. <% if salt_enabled -%>
  116. <% if host_param_true?('enable-saltstack-repo') -%>
  117. <% if @host.operatingsystem.name == 'Debian' -%>
  118. d-i apt-setup/local<%= repos %>/repository string http://debian.saltstack.com/debian <%= @host.operatingsystem.release_name %>-saltstack main
  119. d-i apt-setup/local<%= repos %>/comment string SaltStack Repository
  120. d-i apt-setup/local<%= repos %>/key string http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key
  121. <% repos += 1 -%>
  122. <% end -%>
  123. <% if @host.operatingsystem.name == 'Ubuntu' -%>
  124. d-i apt-setup/local<%= repos %>/repository string http://ppa.launchpad.net/saltstack/salt/ubuntu <%= @host.operatingsystem.release_name %> main
  125. d-i apt-setup/local<%= repos %>/comment string SaltStack Repository
  126. d-i apt-setup/local<%= repos %>/key string http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x4759FA960E27C0A6
  127. <% repos += 1 -%>
  128. <% end -%>
  129. <% end -%>
  130. <% end -%>
  131.  
  132. # Install task set
  133. tasksel tasksel/first multiselect ubuntu-desktop,standard
  134.  
  135. # Install some base packages
  136. d-i pkgsel/install-recommends true
  137. d-i pkgsel/include string <%= additional_packages %>
  138. d-i pkgsel/update-policy select <%= host_param('preseed-update-policy') || 'unattended-upgrades' %>
  139. d-i pkgsel/upgrade select <%= host_param('preseed-post-install-upgrade') || 'none' %>
  140. d-i pkgsel/include string openssh-server build-essential curl git vim wget clamav
  141.  
  142. popularity-contest popularity-contest/participate boolean false
  143.  
  144. # Boot loader settings
  145. #grub-pc grub-pc/hidden_timeout boolean false
  146. #grub-pc grub-pc/timeout string 10
  147. d-i grub-installer/only_debian boolean true
  148. d-i grub-installer/with_other_os boolean true
  149. d-i finish-install/reboot_in_progress note
  150.  
  151.  
  152. d-i preseed/late_command string \
  153. in-target /usr/bin/git clone http://local.repo/scripts/bionic-scripts.git /root/hardening; \
  154. in-target /bin/bash /root/hardening/ubuntu_package_cleanup.sh; \
  155. in-target /bin/sed -i 's/^GRUB_CMDLINE_LINUX.*$/GRUB_CMDLINE_LINUX=\"nosplash\"/g' /etc/default/grub; \
  156. in-target /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg; \
  157. in-target /usr/bin/ubuntu-drivers autoinstall
  158. 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
  159.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement