Skip to content

Commit e6b777f

Browse files
committed
Fixes #38877 - Add Agama installer templates (SLES16)
1 parent a661a85 commit e6b777f

File tree

7 files changed

+389
-0
lines changed

7 files changed

+389
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<%#
2+
kind: ptable
3+
name: Agama default
4+
model: Ptable
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
%>
9+
10+
"drives": [
11+
{
12+
"search": "*",
13+
"partitions": [
14+
{
15+
"search": "*",
16+
"delete": true
17+
},
18+
{
19+
"filesystem": { "path": "/boot", "type": "ext3", "name": "boot" },
20+
"size": { "min": "2 GiB", "max": "4 GiB" }
21+
},
22+
{
23+
"filesystem": { "path": "/boot/efi", "type": "vfat", "name": "vfat" },
24+
"size": "2 GiB"
25+
},
26+
{
27+
"generate": "default"
28+
}
29+
]
30+
}
31+
],
32+
"boot": {
33+
"configure": false,
34+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<%#
2+
kind: ptable
3+
name: Agama LVM
4+
model: Ptable
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
%>
9+
10+
"boot": { "configure": false },
11+
"drives": [
12+
{
13+
"alias": "disk",
14+
"search": "*",
15+
"partitions": [
16+
{
17+
"search": "*",
18+
"delete": true
19+
},
20+
{
21+
"filesystem": { "path": "/boot/efi", "type": "vfat" },
22+
"size": "2 GiB"
23+
},
24+
{
25+
"alias": "pv",
26+
"id": "lvm",
27+
"size": { "min": "20 GiB" }
28+
}
29+
]
30+
}
31+
],
32+
"volumeGroups": [
33+
{
34+
"name": "system",
35+
"physicalVolumes": [ "pv" ],
36+
"logicalVolumes": [
37+
{
38+
"filesystem": { "path": "/", "type": "ext3", "name": "root" },
39+
"size": { "min": "10 GiB" }
40+
},
41+
{
42+
"filesystem": { "path": "/var", "type": "ext3", "name": "var" },
43+
"size": { "min": "2 GiB", "max": "10 GiB" }
44+
},
45+
{
46+
"filesystem": { "path": "swap", "type": "swap", "name": "swap" },
47+
"size": { "min": "1 GiB", "max": "8 GiB" }
48+
}
49+
]
50+
}
51+
]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 [email protected]_loader_efi?
15+
linuxcmd = "linux"
16+
initrdcmd = "initrd"
17+
else
18+
linuxcmd = "linuxefi"
19+
initrdcmd = "initrdefi"
20+
end
21+
22+
if host_param('http-proxy')
23+
if host_param('http-proxy-port')
24+
http_proxy_string = "proxy=http://" + host_param('http-proxy') + ":" + host_param('http-proxy-port')
25+
else
26+
http_proxy_string = "proxy=http://" + host_param('http-proxy')
27+
end
28+
else
29+
http_proxy_string = ''
30+
end
31+
32+
kernel_options = "showopts root=live:#{@mediapath}/LiveOS/squashfs.img inst.install_url=#{@mediapath}/install/ inst.auto=#{foreman_url('provision')} #{http_proxy_string}"
33+
-%>
34+
35+
set default=<%= host_param('default_grub_install_entry') || 0 %>
36+
set timeout=<%= host_param('loader_timeout') || 10 %>
37+
38+
menuentry '<%= template_name %>' {
39+
<%= linuxcmd %> <%= @kernel %> <%= kernel_options %>
40+
<%= initrdcmd %> <%= @initrd %>
41+
}
42+
43+
<%
44+
# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1811561 and https://bugzilla.redhat.com/show_bug.cgi?id=1842893
45+
subnet = @host.provision_interface.subnet || @host.provision_interface.subnet6
46+
if subnet && subnet.httpboot
47+
proxy_http_port = subnet.httpboot.httpboot_http_port
48+
proxy_https_port = subnet.httpboot.httpboot_https_port
49+
# Workaround for "no DNS server configured" https://bugzilla.redhat.com/show_bug.cgi?id=1842509
50+
proxy_host = dns_lookup(subnet.httpboot.hostname)
51+
-%>
52+
<% if proxy_http_port -%>
53+
menuentry '<%= template_name %> EFI HTTP' --id efi_http {
54+
<%= linuxcmd %> (http,<%= proxy_host %>:<%= proxy_http_port %>)/httpboot/<%= @kernel %> <%= kernel_options %>
55+
<%= initrdcmd %> (http,<%= proxy_host %>:<%= proxy_http_port %>)/httpboot/<%= @initrd %>
56+
}
57+
<% else -%>
58+
# Smart proxy does not have HTTPBoot feature with HTTP port enabled, skipping EFI HTTP boot menu entry
59+
<% end -%>
60+
61+
<% if proxy_https_port -%>
62+
menuentry '<%= template_name %> EFI HTTPS' --id efi_https {
63+
<%= linuxcmd %> (https,<%= proxy_host %>:<%= proxy_https_port %>)/httpboot/<%= @kernel %> <%= kernel_options %>
64+
<%= initrdcmd %> (https,<%= proxy_host %>:<%= proxy_https_port %>)/httpboot/<%= @initrd %>
65+
}
66+
<% else -%>
67+
# Smart proxy does not have HTTPBoot feature with HTTPS port enabled, skipping EFI HTTPS boot menu entry
68+
<% end -%>
69+
70+
<% end %>
71+
72+
<%= snippet_if_exists(template_name + " custom menu") %>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
<%
13+
extra_args = []
14+
if host_param('http-proxy') && host_param('http-proxy-port')
15+
extra_args << "proxy=http://" + host_param('http-proxy') + ":" + host_param('http-proxy-port')
16+
elsif host_param('http-proxy')
17+
extra_args << "proxy=http://" + host_param('http-proxy')
18+
end
19+
subnet = @host.subnet
20+
unless subnet.respond_to?(:dhcp_boot_mode?) and subnet.dhcp_boot_mode?
21+
extra_args << "useDHCP=0"
22+
extra_args << "netsetup=-dhcp"
23+
extra_args << "ifcfg=*=#{@host.primary_interface.ip}/#{@host.primary_interface.subnet.cidr},#{@host.primary_interface.subnet.gateway},#{@host.primary_interface.subnet.dns_primary},#{@host.domain}"
24+
end
25+
26+
kernel_options = "showopts root=live:#{@mediapath}/LiveOS/squashfs.img inst.install_url=#{@mediapath}/install/ inst.auto=#{foreman_url('provision')} #{http_proxy_string}"
27+
-%>
28+
DEFAULT linux
29+
30+
LABEL linux
31+
KERNEL <%= @kernel %>
32+
APPEND initrd=<%= @initrd %> <%= kernel_options %> <%= extra_args.join(' ') %>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<%#
2+
kind: finish
3+
name: Agama orcharhino 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+
<%= snippet('remote_execution_ssh_keys') -%>
20+
21+
<% if plugin_present?('katello') && host_param_true?('enable-remote-execution-pull') -%>
22+
<%= save_to_file('/root/remote_execution_pull_setup.sh', snippet('remote_execution_pull_setup'), verbatim: true) %>
23+
chmod +x /root/remote_execution_pull_setup.sh
24+
/root/remote_execution_pull_setup.sh
25+
<% end -%>
26+
27+
<%= snippet "blacklist_kernel_modules" -%>
28+
29+
<% if puppet_enabled -%>
30+
<%= snippet 'puppet_setup' -%>
31+
<% end -%>
32+
33+
<% if salt_enabled -%>
34+
<%= snippet 'saltstack_setup' -%>
35+
<% end -%>
36+
37+
<%= snippet 'eject_cdrom' -%>
38+
39+
<%= snippet_if_exists(template_name + " custom post") -%>
40+
41+
# Mark the build as finished
42+
<%= snippet 'built' -%>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<%#
2+
kind: provision
3+
name: Agama orcharhino 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').present?
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+
{
38+
"id": "Wired Connection",
39+
"method4": "auto",
40+
"method6": "disabled",
41+
"ignoreAutoDns": false,
42+
"status": "up",
43+
"autoconnect": true,
44+
"persistent": true
45+
}
46+
]
47+
},
48+
"storage": {
49+
<%= indent(8, skip1: true) { @host.diskLayout } %>
50+
},
51+
"scripts": {
52+
"post": [
53+
{
54+
"name": "enable-sshd",
55+
"chroot": true,
56+
"content": |||
57+
#!/usr/bin/bash
58+
systemctl enable sshd.service
59+
|||
60+
},
61+
{
62+
"name": "eject-cdrom",
63+
"chroot": true,
64+
"content": |||
65+
<%= indent(20, skip1: true) { snippet 'eject_cdrom' } -%>
66+
|||
67+
},
68+
{
69+
"name": "foreman-finish",
70+
"chroot": true,
71+
"content": |||
72+
#!/usr/bin/bash
73+
<% if host_param('http-proxy') -%>
74+
export http_proxy="http://<%= host_param('http-proxy') %>:<%= host_param('http-proxy-port') -%>"
75+
<% if host_param('noproxy') -%>
76+
export no_proxy="<%= host_param('http-proxy') %> <%= host_param('noproxy') -%>"
77+
<% end -%>
78+
<% end -%>
79+
<%= indent(20, skip1: true) { snippet_if_exists(template_name + " custom finish pre") } -%>
80+
<%= indent(20, skip1: true) { snippet('remote_execution_ssh_keys') } -%>
81+
82+
<% if plugin_present?('katello') && host_param_true?('enable-remote-execution-pull') -%>
83+
<%= save_to_file('/root/remote_execution_pull_setup.sh', snippet('remote_execution_pull_setup'), verbatim: true) %>
84+
chmod +x /root/remote_execution_pull_setup.sh
85+
/root/remote_execution_pull_setup.sh
86+
<% end -%>
87+
88+
<%= indent(20, skip1: true) { snippet "blacklist_kernel_modules" } -%>
89+
<% if puppet_enabled -%>
90+
<%= indent(20, skip1: true) { snippet 'puppet_setup' } -%>
91+
<% end -%>
92+
93+
<% if salt_enabled -%>
94+
<%= indent(20, skip1: true) { snippet 'saltstack_setup' } -%>
95+
<% end -%>
96+
<%= indent(20, skip1: true) { snippet_if_exists(template_name + " custom finish post") } -%>
97+
98+
|||
99+
},
100+
{
101+
"name": "built",
102+
"content": |||
103+
<%= indent(20, skip1: true) { snippet 'built' } -%>
104+
105+
|||
106+
}
107+
]
108+
}
109+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<%#
2+
kind: user_data
3+
name: Agama default user data
4+
model: ProvisioningTemplate
5+
oses:
6+
- OpenSUSE
7+
- SLES
8+
description: |
9+
This template is used during image based provisioning, when the image is configured to use user-data.
10+
The output is a shell script that cloud-init runs to configures the VM
11+
booted from the image. The image must have cloud-init installed in order for this to work.
12+
This script can be used with OpenSUSE and SLES images.
13+
-%>
14+
<%
15+
# safemode renderer does not support unary negation
16+
puppet_enabled = !host_param_true?('skip-puppet-setup') && (host_puppet_server.present? || host_param_true?('force-puppet'))
17+
salt_enabled = host_param('salt_master') ? true : false
18+
-%>
19+
#!/bin/bash
20+
21+
<%= snippet_if_exists(template_name + " custom pre") -%>
22+
23+
<%# Cloud instances frequently have incorrect hosts data %>
24+
<%= snippet 'fix_hosts' -%>
25+
26+
<% if @host.provision_method == 'image' && root_pass.present? -%>
27+
# Install the root password
28+
echo 'root:<%= root_pass -%>' | /usr/sbin/chpasswd -e
29+
<% end -%>
30+
31+
<%= snippet('remote_execution_ssh_keys') -%>
32+
33+
<%= snippet "blacklist_kernel_modules" -%>
34+
35+
<% if puppet_enabled -%>
36+
<% if host_param_true?('enable-official-openvox8-repo') -%>
37+
<%= snippet 'puppetlabs_repo' -%>
38+
<% end -%>
39+
<%= snippet 'puppet_setup' -%>
40+
<% end -%>
41+
42+
<% if salt_enabled -%>
43+
<%= snippet 'saltstack_setup' -%>
44+
<% end -%>
45+
46+
<%= snippet_if_exists(template_name + " custom post") -%>
47+
48+
# Mark the build as finished
49+
<%= snippet 'built' -%>

0 commit comments

Comments
 (0)