Skip to content
Snippets Groups Projects
Commit 3a9a1cd1 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Add partition table and unattend seeds

parent d9896473
No related branches found
No related tags found
No related merge requests found
<%#
kind: wds_unattend
name: Unattend Windows Server 2016
oses:
- Windows Server 2016
-%>
<%
registration = {
organization: 'Organization name',
owner: 'Owner name'
}
-%>
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UserLocale>en-US</UserLocale>
</component>
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<%= indent(6) { @host.diskLayout } %>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName><%= @host.shortname %></ComputerName>
<RegisteredOrganization><%= registration[:organization] %></RegisteredOrganization>
<RegisteredOwner><%= registration[:owner] %></RegisteredOwner>
<TimeZone>W. Europe Standard Time</TimeZone>
</component>
<component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Interfaces>
<%- iface = @host.primary_interface # @host.managed_interfaces.each.with_index do |iface, i| -%>
<Interface wcm:action="add">
<Identifier><%= iface.identifier.empty? ? 'Ethernet0' : iface.identifier %></Identifier>
<UnicastIpAddresses>
<%- if !iface.ip.empty? && iface.subnet -%>
<IpAddress wcm:action="add" wcm:keyValue="1"><%= iface.ip %>/<%= iface.subnet.cidr %></IpAddress>
<%- end -%>
<%- if !iface.ip6.empty? && iface.subnet6 -%>
<IpAddress wcm:action="add" wcm:keyValue="2"><%= iface.ip6 %>/<%= iface.subnet6.cidr %></IpAddress>
<%- end -%>
</UnicastIpAddresses>
<Routes>
<%- if iface.subnet && !iface.subnet.gateway.empty? -%>
<Route wcm:action="add">
<Identifier>1</Identifier>
<Metric>10</Metric>
<NextHopAddress><%= iface.subnet.gateway %></NextHopAddress>
<Prefix>0.0.0.0/0</Prefix>
</Route>
<%- end -%>
<%- if iface.subnet6 && !iface.subnet6.gateway.empty? -%>
<Route wcm:action="add">
<Identifier>1</Identifier>
<Metric>10</Metric>
<NextHopAddress><%= iface.subnet6.gateway %></NextHopAddress>
<Prefix>::/0</Prefix>
</Route>
<%- end -%>
</Routes>
</Interface>
</Interfaces>
</component>
<component name="Microsoft-Windows-DNS-Client" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DNSSuffixSearchOrder>
<DomainName wcm:action="add" wcm:keyValue="1"><%= @host.domain %></DomainName>
</DNSSuffixSearchOrder>
<Interfaces>
<Interface wcm:action="add">
<DNSServerSearchOrder>
<IpAddress wcm:action="add" wcm:keyValue="1"><%= iface.subnet.dns_primary %></IpAddress>
<IpAddress wcm:action="add" wcm:keyValue="2"><%= iface.subnet.dns_secondary %></IpAddress>
</DNSServerSearchOrder>
<Identifier><%= iface.identifier.empty? ? 'Ethernet0' : iface.identifier %></Identifier>
</Interface>
</Interfaces>
<DNSDomain><%= @host.domain %></DNSDomain>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UserAccounts>
<AdministratorPassword>
<Value><%= @host.unattend_pass 'AdministratorPassword' %></Value>
<PlainText>false</PlainText>
</AdministratorPassword>
</UserAccounts>
</component>
</settings>
</unattend>
<%#
name: Windows default
snippet: false
model: Ptable
oses:
- Windows
-%>
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>350</Size>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>Primary</Type>
<Size>122880</Size>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>System Reserved</Label>
<Format>NTFS</Format>
<Active>true</Active>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<Active>false</Active>
<Extend>false</Extend>
<Format>NTFS</Format>
<Label>SYSTEM</Label>
<Letter>C</Letter>
<Order>2</Order>
<PartitionID>2</PartitionID>
</ModifyPartition>
</ModifyPartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
</DiskConfiguration>
Ptable.without_auditing do
{ 'windows_ptable.xml.erb' => 'Windows default' }.each do |tmpl_file, tmpl_name|
content = File.read(File.join(ForemanWds::Engine.root, 'app', 'views', 'foreman_wds', tmpl_file))
tmpl = Ptable.unscoped.where(name: tmpl_name).first_or_create(
snippet: false,
template: content
)
tmpl.attributes = {
template: content,
default: true,
vendor: 'Foreman WDS',
locked: false
}
tmpl.save!(validate: false) if tmpl.changes.present?
end
end
kind = TemplateKind.unscoped.where(name: 'wds_unattend').first_or_create
ProvisioningTemplate.without_auditing do
{ 'unattend_2016.xml.erb' => 'Windows Server 2016' }.each do |tmpl_name, os_name|
content = File.read(File.join(ForemanWds::Engine.root, 'app', 'views', 'foreman_wds', tmpl_name))
tmpl = ProvisioningTemplate.unscoped.where(name: "Unattend #{os_name}").first_or_create(
template_kind_id: kind.id,
snippet: false,
template: content
)
tmpl.attributes = {
template: content,
default: true,
vendor: 'Foreman WDS',
locked: false
}
tmpl.save!(validate: false) if tmpl.changes.present?
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment