Skip to content

Commit afc88d3

Browse files
committed
Fixes #38229 - Add new template snapshot host for Ubuntu
Next to ubuntu_autoinst4dhcp (a Ubuntu 20 machine with default host4dhcp config), add a second scenario to cover a more common Ubuntu scenario: ubuntu_autoinstmulti4dhcp. * has two IPv4 NICs * both NICs don't set the identifier When the NIC identifier is not set, the preseed_netplan_generic_interface snippet adds a MAC-based match section which shall be included in snapshot tests.
1 parent d7f35fe commit afc88d3

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

app/services/foreman/template_snapshot_service.rb

+20
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def self.ubuntu_autoinst4dhcp
3838
new.ubuntu_autoinst4dhcp
3939
end
4040

41+
def self.ubuntu_autoinstmulti4dhcp
42+
new.ubuntu_autoinstmulti4dhcp
43+
end
44+
4145
def self.rhel9_dhcp
4246
new.rhel9_dhcp
4347
end
@@ -188,6 +192,22 @@ def ubuntu_autoinst4dhcp
188192
define_host_params(host)
189193
end
190194

195+
def ubuntu_autoinstmulti4dhcp
196+
nic_a = FactoryBot.build(:nic_primary_and_provision, identifier: '',
197+
mac: '00-f0-54-1a-7e-e0',
198+
ip: '192.168.42.42')
199+
nic_b = FactoryBot.build(:nic_managed, identifier: '',
200+
mac: '00-f0-54-1a-7e-e1',
201+
ip: '192.168.42.43')
202+
203+
host = FactoryBot.build(:host_for_snapshots_ipv4_dhcp_ubuntu20,
204+
name: 'snapshot-ipv4-dhcp-ubuntu20',
205+
subnet: FactoryBot.build(:subnet_ipv4_dhcp_for_snapshots),
206+
interfaces: [nic_a, nic_b])
207+
host.define_singleton_method(:managed_interfaces) { interfaces }
208+
define_host_params(host)
209+
end
210+
191211
def rhel9_dhcp
192212
host = FactoryBot.build(:host_for_snapshots_ipv4_dhcp_rhel9,
193213
name: 'snapshot-ipv4-dhcp-rhel9',

app/views/unattended/provisioning_templates/user_data/preseed_autoinstall_cloud_init.erb

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ oses:
66
- ubuntu
77
test_on:
88
- ubuntu_autoinst4dhcp
9+
- ubuntu_autoinstmulti4dhcp
910
description: |
1011
The provisioning template for Autoinstall based distributions. To customize the installation,
1112
modify the host parameters
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#cloud-config
2+
autoinstall:
3+
version: 1
4+
apt:
5+
geoip: false
6+
preserve_sources_list: false
7+
primary:
8+
- arches: [amd64, i386]
9+
uri: http://archive.ubuntu.com/ubuntu
10+
- arches: [default]
11+
uri: http://ports.ubuntu.com/ubuntu-ports
12+
user-data:
13+
disable_root: false
14+
fqdn: snapshot-ipv4-dhcp-ubuntu20
15+
users:
16+
- name: root
17+
gecos: root
18+
lock_passwd: false
19+
hashed_passwd: $1$rtd8Ub7R$5Ohzuy8WXlkaK9cA2T1wb0
20+
keyboard:
21+
layout: us
22+
toggle: null
23+
variant: ''
24+
locale: en_US.UTF-8
25+
network:
26+
version: 2
27+
ethernets:
28+
id0:
29+
match:
30+
macaddress: "00-f0-54-1a-7e-e0"
31+
dhcp4: true
32+
dhcp6: false
33+
id0:
34+
match:
35+
macaddress: "00-f0-54-1a-7e-e0"
36+
dhcp4: false
37+
dhcp6: false
38+
ssh:
39+
allow-pw: true
40+
install-server: true
41+
updates: security
42+
storage:
43+
layout:
44+
name: lvm
45+
46+
late-commands:
47+
48+
- wget --no-proxy http://foreman.example.com/unattended/finish -O /target/tmp/finish.sh
49+
- curtin in-target -- chmod +x /tmp/finish.sh
50+
- curtin in-target -- /tmp/finish.sh

0 commit comments

Comments
 (0)