Skip to content

Commit ffaef28

Browse files
committed
provisioner: Add autoyast self update option
AutoYaST can update itself before installing the OS. This patch enables this feature and adds a field to the provisioner barclamp so that a repository URL can be set by the user. The special token `<ADMINWEB>` resolves to the IP:port of the admin node. An empty URL defaults to the SUSE customer center (scc.suse.com).
1 parent e3efd02 commit ffaef28

File tree

7 files changed

+67
-2
lines changed

7 files changed

+67
-2
lines changed

chef/cookbooks/provisioner/recipes/update_nodes.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,26 @@ def find_node_boot_mac_addresses(node, admin_data_net)
301301
end
302302

303303
when /^(open)?suse/
304+
expanded_self_update_url = node[:provisioner][:suse][:autoyast][:self_update_url].gsub(
305+
"<ADMINWEB>", "#{admin_ip}:#{web_port}"
306+
)
307+
do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
308+
if do_self_update && !expanded_self_update_url.empty?
309+
do_self_update = system("wget --quiet --spider " +
310+
expanded_self_update_url.gsub("$arch", "#{arch}"))
311+
unless do_self_update
312+
Chef::Log.warn("AutoYaST self-update URL #{expanded_self_update_url} does not exist")
313+
end
314+
end
315+
304316
append << "install=#{install_url} autoyast=#{node_url}/autoyast.xml"
305317
if node[:provisioner][:use_serial_console]
306318
append << "textmode=1"
307319
end
308320
append << "ifcfg=dhcp4 netwait=60"
309321
append << "squash=0" # workaround bsc#962397
310322
append << "autoupgrade=1" if mnode[:state] == "os-upgrading"
323+
append << "self_update" if do_self_update
311324

312325
target_platform_distro = os.gsub(/-.*$/, "")
313326
target_platform_version = os.gsub(/^.*-/, "")
@@ -350,6 +363,8 @@ def find_node_boot_mac_addresses(node, admin_data_net)
350363
web_port: web_port,
351364
packages: packages,
352365
repos: repos,
366+
do_self_update: do_self_update,
367+
self_update_url: expanded_self_update_url,
353368
rootpw_hash: node[:provisioner][:root_password_hash] || "",
354369
timezone: timezone,
355370
boot_device: boot_device,

chef/cookbooks/provisioner/templates/default/autoyast.xml.erb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,24 @@
2626
<import_gpg_key config:type="boolean">true</import_gpg_key>
2727
</signature-handling>
2828
<storage/>
29+
<% if @do_self_update %>
30+
<self_update_url>
31+
<%= @self_update_url %>
32+
</self_update_url>
33+
<% end -%>
2934
</general>
35+
<report>
36+
<errors>
37+
<log config:type="boolean">true</log>
38+
<show config:type="boolean">true</show>
39+
<timeout config:type="integer">10</timeout>
40+
</errors>
41+
<warnings>
42+
<log config:type="boolean">true</log>
43+
<show config:type="boolean">true</show>
44+
<timeout config:type="integer">10</timeout>
45+
</warnings>
46+
</report>
3047
<add-on>
3148
<add_on_products config:type="list">
3249
<% @repos.keys.sort.each do |name| %>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def upgrade(ta, td, a, d)
2+
a["suse"] = {} unless a.key?("suse")
3+
a["suse"]["autoyast"] = {} unless a["suse"].key?("autoyast")
4+
a["suse"]["autoyast"]["do_self_update"] = ta["suse"]["autoyast"]["do_self_update"]
5+
a["suse"]["autoyast"]["self_update_url"] = ta["suse"]["autoyast"]["self_update_url"]
6+
return a, d
7+
end
8+
9+
def downgrade(ta, td, a, d)
10+
delete a["suse"]["autoyast"]["do_self_update"]
11+
delete a["suse"]["autoyast"]["self_update_url"]
12+
delete a["suse"]["autoyast"] if a["suse"]["autoyast"].empty?
13+
delete a["suse"] if a["suse"].empty?
14+
return a, d
15+
end

chef/data_bags/crowbar/template-provisioner.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@
158158
}
159159
}
160160
},
161+
"suse": {
162+
"autoyast": {
163+
"do_self_update": false,
164+
"self_update_url": "http://<ADMINWEB>/suse-12.2/$arch/repos/installer-update"
165+
}
166+
},
161167
"keep_existing_hostname": false,
162168
"timezone": "UTC",
163169
"web_port": 8091,
@@ -200,7 +206,7 @@
200206
"provisioner": {
201207
"crowbar-revision": 0,
202208
"crowbar-applied": false,
203-
"schema-revision": 102,
209+
"schema-revision": 103,
204210
"element_states": {
205211
"provisioner-server": [ "readying", "ready", "applying" ],
206212
"provisioner-base": [ "hardware-installing", "readying", "ready", "applying" ]

chef/data_bags/crowbar/template-provisioner.schema

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
"type": "map",
6262
"required": false,
6363
"mapping": {
64-
"ssh_password": { "type": "str", "required": false }
64+
"ssh_password": { "type": "str", "required": false },
65+
"do_self_update": { "type": "bool", "required": true },
66+
"self_update_url": { "type": "str", "required": true }
6567
}
6668
}
6769
}

crowbar_framework/app/views/barclamp/provisioner/_edit_attributes.html.haml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
%span.help-block
88
= t(".access_keys_hint")
99

10+
= boolean_field %w(suse autoyast do_self_update)
11+
= string_field %w(suse autoyast self_update_url)
12+
%span.help-block
13+
= t(".suse.autoyast.self_update_url_hint")
14+
1015
= string_field :shell_prompt
1116
%span.help-block
1217
= t(".shell_prompt_hint")

crowbar_framework/config/locales/provisioner/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ en:
2121
edit_attributes:
2222
access_keys: 'Additional SSH keys'
2323
access_keys_hint: 'Each SSH key must be on its own line'
24+
suse:
25+
autoyast:
26+
do_self_update: 'Update AutoYaST before installing node'
27+
self_update_url: 'AutoYaST Self-update URL'
28+
self_update_url_hint: 'The alias <ADMINWEB> can be used to specify the admin server. An empty URL implies scc.suse.com.'
2429
shell_prompt: 'Custom Shell Prompt'
2530
shell_prompt_hint: 'You can use the placeholders USER, ALIAS, HOST, FQDN, CWD and SUFFIX to customize the shell prompt on all nodes. Add a \n for a new line within the prompt.'
2631
serial_console: 'Serial Console'

0 commit comments

Comments
 (0)