Skip to content

Commit e470883

Browse files
committed
Fixes #38877 - Add Agama installer templates (SLES16)
1 parent 3f64667 commit e470883

File tree

18 files changed

+1107
-0
lines changed

18 files changed

+1107
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<%#
2+
kind: ptable
3+
name: Agama default
4+
model: Ptable
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
%>
9+
<%
10+
pxe_loader = @host.pxe_loader || ''
11+
-%>
12+
13+
"drives": [
14+
{
15+
"search": "*",
16+
"partitions": [
17+
{
18+
"search": "*",
19+
"delete": true
20+
},
21+
{
22+
"filesystem": { "path": "/boot", "type": "ext3", "name": "boot" },
23+
"size": { "min": "2 GiB", "max": "4 GiB" }
24+
},
25+
<%- if pxe_loader.include?('UEFI') -%>
26+
{
27+
"filesystem": { "path": "/boot/efi", "type": "vfat", "name": "vfat" },
28+
"size": "1 GiB"
29+
},
30+
<%- end -%>
31+
{
32+
"generate": "default"
33+
}
34+
]
35+
}
36+
],
37+
"boot": {
38+
"configure": false
39+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<%#
2+
kind: ptable
3+
name: Agama LVM
4+
model: Ptable
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
%>
9+
<%
10+
pxe_loader = @host.pxe_loader || ''
11+
-%>
12+
13+
"boot": { "configure": false },
14+
"drives": [
15+
{
16+
"alias": "disk",
17+
"search": "*",
18+
"partitions": [
19+
{
20+
"search": "*",
21+
"delete": true
22+
},
23+
<%- if pxe_loader.include?('UEFI') -%>
24+
{
25+
"filesystem": { "path": "/boot/efi", "type": "vfat" },
26+
"size": "1 GiB"
27+
},
28+
<%- else -%>
29+
{
30+
"filesystem": { "path": "/boot/", "type": "ext3" },
31+
"size": "2 GiB"
32+
},
33+
<%- end -%>
34+
{
35+
"alias": "pv",
36+
"id": "lvm",
37+
"size": { "min": "20 GiB" }
38+
}
39+
]
40+
}
41+
],
42+
"volumeGroups": [
43+
{
44+
"name": "system",
45+
"physicalVolumes": [ "pv" ],
46+
"logicalVolumes": [
47+
{
48+
"filesystem": { "path": "/", "type": "ext3", "name": "root" },
49+
"size": { "min": "10 GiB" }
50+
},
51+
{
52+
"filesystem": { "path": "/var", "type": "ext3", "name": "var" },
53+
"size": { "min": "2 GiB", "max": "10 GiB" }
54+
},
55+
{
56+
"filesystem": { "path": "swap", "type": "swap", "name": "swap" },
57+
"size": { "min": "1 GiB", "max": "8 GiB" }
58+
}
59+
]
60+
}
61+
]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<%#
2+
kind: PXEGrub2
3+
name: Agama default PXEGrub2
4+
model: ProvisioningTemplate
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
description: |
9+
The template to render PXEGrub2 bootloader configuration for Agama based distributions.
10+
The output is deployed on the host's subnet TFTP proxy.
11+
-%>
12+
# This file was deployed via '<%= template_name %>' template
13+
<%
14+
if !@host.pxe_loader_efi?
15+
linuxcmd = "linux"
16+
initrdcmd = "initrd"
17+
else
18+
linuxcmd = "linuxefi"
19+
initrdcmd = "initrdefi"
20+
end
21+
kernel_options = snippet('agama_kernel_options')
22+
-%>
23+
24+
set default=<%= host_param('default_grub_install_entry') || 0 %>
25+
set timeout=<%= host_param('loader_timeout') || 10 %>
26+
27+
menuentry '<%= template_name %>' {
28+
<%= linuxcmd %> <%= @kernel %> <%= kernel_options %>
29+
<%= initrdcmd %> <%= @initrd %>
30+
}
31+
32+
<%
33+
# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1811561 and https://bugzilla.redhat.com/show_bug.cgi?id=1842893
34+
subnet = @host.provision_interface.subnet || @host.provision_interface.subnet6
35+
if subnet && subnet.httpboot
36+
proxy_http_port = subnet.httpboot.httpboot_http_port
37+
proxy_https_port = subnet.httpboot.httpboot_https_port
38+
# Workaround for "no DNS server configured" https://bugzilla.redhat.com/show_bug.cgi?id=1842509
39+
proxy_host = dns_lookup(subnet.httpboot.hostname)
40+
-%>
41+
<% if proxy_http_port -%>
42+
menuentry '<%= template_name %> EFI HTTP' --id efi_http {
43+
<%= linuxcmd %> (http,<%= proxy_host %>:<%= proxy_http_port %>)/httpboot/<%= @kernel %> <%= kernel_options %>
44+
<%= initrdcmd %> (http,<%= proxy_host %>:<%= proxy_http_port %>)/httpboot/<%= @initrd %>
45+
}
46+
<% else -%>
47+
# Smart proxy does not have HTTPBoot feature with HTTP port enabled, skipping EFI HTTP boot menu entry
48+
<% end -%>
49+
50+
<% if proxy_https_port -%>
51+
menuentry '<%= template_name %> EFI HTTPS' --id efi_https {
52+
<%= linuxcmd %> (https,<%= proxy_host %>:<%= proxy_https_port %>)/httpboot/<%= @kernel %> <%= kernel_options %>
53+
<%= initrdcmd %> (https,<%= proxy_host %>:<%= proxy_https_port %>)/httpboot/<%= @initrd %>
54+
}
55+
<% else -%>
56+
# Smart proxy does not have HTTPBoot feature with HTTPS port enabled, skipping EFI HTTPS boot menu entry
57+
<% end -%>
58+
59+
<% end %>
60+
61+
<%= snippet_if_exists(template_name + " custom menu") %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<%#
2+
kind: PXELinux
3+
name: Agama default PXELinux
4+
model: ProvisioningTemplate
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
description: |
9+
The template to render PXELinux bootloader configuration for SLES and OpenSUSE distributions.
10+
The output is deployed on the host's subnet TFTP proxy.
11+
-%>
12+
DEFAULT linux
13+
LABEL linux
14+
KERNEL <%= @kernel %>
15+
APPEND initrd=<%= @initrd %> <%= snippet("agama_kernel_options").strip %>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<%#
2+
kind: finish
3+
name: Agama default finish
4+
model: ProvisioningTemplate
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
-%>
9+
<%
10+
pm_set = @host.puppet_server.present?
11+
puppet_enabled = pm_set || host_param_true?('force-puppet')
12+
salt_enabled = host_param('salt_master').present?
13+
-%>
14+
15+
/usr/bin/hostnamectl set-hostname <%= @host.name %>
16+
17+
<%= snippet_if_exists(template_name + " custom pre") -%>
18+
19+
<%- if plugin_present?('katello') && host_param('kt_activation_keys') -%>
20+
<%= snippet_if_exists("sles_register") -%>
21+
<% end -%>
22+
23+
<%= snippet('remote_execution_ssh_keys') -%>
24+
25+
<% if plugin_present?('katello') && host_param_true?('enable-remote-execution-pull') -%>
26+
<%= save_to_file('/root/remote_execution_pull_setup.sh', snippet('remote_execution_pull_setup'), verbatim: true) %>
27+
chmod +x /root/remote_execution_pull_setup.sh
28+
/root/remote_execution_pull_setup.sh
29+
<% end -%>
30+
31+
<%= snippet "blacklist_kernel_modules" -%>
32+
33+
<% if puppet_enabled -%>
34+
<%= snippet 'puppet_setup' -%>
35+
<% end -%>
36+
37+
<% if salt_enabled -%>
38+
<%= snippet 'saltstack_setup' -%>
39+
<% end -%>
40+
41+
<%= snippet 'eject_cdrom' -%>
42+
43+
<%= snippet_if_exists(template_name + " custom post") -%>
44+
45+
# Mark the build as finished
46+
<%= snippet 'built' -%>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!gpxe
2+
<%#
3+
kind: iPXE
4+
name: Agama default iPXE
5+
model: ProvisioningTemplate
6+
oses:
7+
- SLES
8+
- OpenSUSE
9+
description: |
10+
The template to render iPXE installation script for SLES and OpenSUSE
11+
The output is deployed on the host's subnet TFTP proxy.
12+
See https://ipxe.org/scripting for more details
13+
-%>
14+
echo Trying to ping Gateway: ${netX/gateway}
15+
ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available.
16+
echo Trying to ping DNS: ${netX/dns}
17+
ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available.
18+
19+
<% boot_files_uris = @host.operatingsystem.boot_files_uri(medium_provider) -%>
20+
<% kernel = boot_files_uris[0] -%>
21+
<% initrd = boot_files_uris[1] -%>
22+
23+
<% subnet = @host.subnet -%>
24+
kernel <%= kernel %> initrd=initrd.img <%= snippet("agama_kernel_options").strip %>
25+
initrd <%= initrd %>
26+
boot
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<%#
2+
kind: provision
3+
name: Agama sles default
4+
model: ProvisioningTemplate
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
-%>
9+
<%
10+
os_major = @host.operatingsystem.major.to_i
11+
os_minor = @host.operatingsystem.minor.to_i
12+
pm_set = @host.puppet_server.present?
13+
puppet_enabled = pm_set || host_param_true?('force-puppet')
14+
salt_enabled = host_param('salt_master') ? true : false
15+
-%>
16+
{
17+
"product": {
18+
"id": "SLES"
19+
},
20+
"hostname": {
21+
"static": "<%= @host.name %>"
22+
},
23+
"root": {
24+
"hashedPassword": true,
25+
"password": "<%= root_pass %>"
26+
},
27+
"localization": {
28+
"language": "en_US.UTF-8",
29+
"keyboard": "us",
30+
"timezone": "<%= host_param('time-zone') || 'Europe/London' %>"
31+
},
32+
"software": {
33+
"packages": ["openssh", "wget"]
34+
},
35+
"network": {
36+
"connections": [
37+
<%= indent(8, skip1: true) { snippet('agama_network_setup') } %>
38+
]
39+
},
40+
"storage": {
41+
<%= indent(8, skip1: true) { @host.diskLayout } %>
42+
},
43+
"scripts": {
44+
"post": [
45+
{
46+
"name": "enable-sshd",
47+
"chroot": true,
48+
"content": |||
49+
#!/usr/bin/bash
50+
systemctl enable sshd.service
51+
|||
52+
},
53+
{
54+
"name": "eject-cdrom",
55+
"chroot": true,
56+
"content": |||
57+
# eject bootdisk if this is requested provisioning method
58+
<%= indent(20, skip1: true) { snippet 'eject_cdrom' } -%>
59+
60+
|||
61+
},
62+
{
63+
"name": "foreman-finish",
64+
"chroot": true,
65+
"content": |||
66+
#!/usr/bin/bash
67+
<%- if host_param('http-proxy') -%>
68+
export http_proxy="http://<%= host_param('http-proxy') %>:<%= host_param('http-proxy-port') -%>"
69+
<%- if host_param('noproxy') -%>
70+
export no_proxy="<%= host_param('http-proxy') %> <%= host_param('noproxy') -%>"
71+
<%- end -%>
72+
<%- end -%>
73+
<%= indent(20, skip1: true) { snippet_if_exists(template_name + " custom finish pre") } -%>
74+
<%- if plugin_present?('katello') && host_param('kt_activation_keys') -%>
75+
<%= indent(20, skip1: true) { snippet_if_exists("sles_register") } -%>
76+
<%- end -%>
77+
78+
<%= indent(20, skip1: true) { snippet "blacklist_kernel_modules" } -%>
79+
80+
# Fix agama vs puppet/salt cleaning the /etc/resolv.conf
81+
# https://github.com/agama-project/agama/issues/2911
82+
cp /etc/resolv.conf /etc/resolv.conf.backup
83+
84+
<%- if puppet_enabled -%>
85+
<%= indent(20, skip1: true) { snippet 'puppet_setup' } -%>
86+
# Fix agama vs puppet/salt cleaning the /etc/resolv.conf
87+
# https://github.com/agama-project/agama/issues/2911
88+
cat /etc/resolv.conf.backup >/etc/resolv.conf
89+
<%- end -%>
90+
91+
<%- if salt_enabled -%>
92+
<%= indent(20, skip1: true) { snippet 'saltstack_setup' } -%>
93+
# Fix agama vs puppet/salt cleaning the /etc/resolv.conf
94+
# https://github.com/agama-project/agama/issues/2911
95+
cat /etc/resolv.conf.backup >/etc/resolv.conf
96+
<%- end -%>
97+
98+
<%= indent(20, skip1: true) { snippet_if_exists(template_name + " custom finish post") } -%>
99+
100+
echo "End of foreman-finish script"
101+
|||
102+
},
103+
{
104+
"name": "built",
105+
"content": |||
106+
# Let foreman know that the build is complete
107+
<%= indent(20, skip1: true) { snippet 'built' } -%>
108+
109+
|||
110+
}
111+
],
112+
"init": [
113+
{
114+
"name": "foreman-init",
115+
"content": |||
116+
#!/usr/bin/bash
117+
<%= indent(20, skip1: true) { snippet_if_exists(template_name + " custom init pre") } -%>
118+
<%= indent(20, skip1: true) { snippet('remote_execution_ssh_keys') } -%>
119+
<%- if plugin_present?('katello') && host_param_true?('enable-remote-execution-pull') -%>
120+
<%= indent(20, skip1: true) { save_to_file('/root/remote_execution_pull_setup.sh', snippet('remote_execution_pull_setup'), verbatim: true) } %>
121+
chmod +x /root/remote_execution_pull_setup.sh
122+
/root/remote_execution_pull_setup.sh
123+
<%- end -%>
124+
<%= indent(20, skip1: true) { snippet_if_exists(template_name + " custom init post") } -%>
125+
126+
echo "End of foreman-init script"
127+
|||
128+
}
129+
]
130+
}
131+
}

0 commit comments

Comments
 (0)