Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[provisioner] Add autoyast self update option #823

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions chef/cookbooks/provisioner/recipes/update_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,26 @@ def find_node_boot_mac_addresses(node, admin_data_net)
end

when /^(open)?suse/
expanded_self_update_url = node[:provisioner][:suse][:autoyast][:self_update_url].gsub(
"<ADMINWEB>", "#{admin_ip}:#{web_port}"
)
do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && !expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider " +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/LineEndConcatenation: Use \ instead of + or << to concatenate those strings.

expanded_self_update_url.gsub("$arch", "#{arch}"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected token tIDENTIFIER
unexpected token tRPAREN

unless do_self_update

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)

Chef::Log.warn("AutoYaST self-update URL #{expanded_self_update_url} does not exist")
end
end

append << "install=#{install_url} autoyast=#{node_url}/autoyast.xml"
if node[:provisioner][:use_serial_console]
append << "textmode=1"
end
append << "ifcfg=dhcp4 netwait=60"
append << "squash=0" # workaround bsc#962397
append << "autoupgrade=1" if mnode[:state] == "os-upgrading"
append << "self_update" if do_self_update

target_platform_distro = os.gsub(/-.*$/, "")
target_platform_version = os.gsub(/^.*-/, "")
Expand Down Expand Up @@ -350,6 +363,8 @@ def find_node_boot_mac_addresses(node, admin_data_net)
web_port: web_port,
packages: packages,
repos: repos,
do_self_update: do_self_update,
self_update_url: expanded_self_update_url,
rootpw_hash: node[:provisioner][:root_password_hash] || "",
timezone: timezone,
boot_device: boot_device,
Expand Down
17 changes: 17 additions & 0 deletions chef/cookbooks/provisioner/templates/default/autoyast.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,24 @@
<import_gpg_key config:type="boolean">true</import_gpg_key>
</signature-handling>
<storage/>
<% if @do_self_update %>
<self_update_url>
<%= @self_update_url %>
</self_update_url>
<% end -%>
</general>
<report>
<errors>
<log config:type="boolean">true</log>
<show config:type="boolean">true</show>
<timeout config:type="integer">10</timeout>
</errors>
<warnings>
<log config:type="boolean">true</log>
<show config:type="boolean">true</show>
<timeout config:type="integer">10</timeout>
</warnings>
</report>
<add-on>
<add_on_products config:type="list">
<% @repos.keys.sort.each do |name| %>
Expand Down
15 changes: 15 additions & 0 deletions chef/data_bags/crowbar/migrate/provisioner/103_self_update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def upgrade(ta, td, a, d)
a["suse"] = {} unless a.key?("suse")
a["suse"]["autoyast"] = {} unless a["suse"].key?("autoyast")
a["suse"]["autoyast"]["do_self_update"] = ta["suse"]["autoyast"]["do_self_update"]
a["suse"]["autoyast"]["self_update_url"] = ta["suse"]["autoyast"]["self_update_url"]
return a, d
end

def downgrade(ta, td, a, d)
delete a["suse"]["autoyast"]["do_self_update"]
delete a["suse"]["autoyast"]["self_update_url"]
delete a["suse"]["autoyast"] if a["suse"]["autoyast"].empty?
delete a["suse"] if a["suse"].empty?
return a, d
end
8 changes: 7 additions & 1 deletion chef/data_bags/crowbar/template-provisioner.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@
}
}
},
"suse": {
"autoyast": {
"do_self_update": false,
"self_update_url": "http://<ADMINWEB>/suse-12.2/$arch/repos/installer-update"
}
},
"keep_existing_hostname": false,
"timezone": "UTC",
"web_port": 8091,
Expand Down Expand Up @@ -200,7 +206,7 @@
"provisioner": {
"crowbar-revision": 0,
"crowbar-applied": false,
"schema-revision": 102,
"schema-revision": 103,
"element_states": {
"provisioner-server": [ "readying", "ready", "applying" ],
"provisioner-base": [ "hardware-installing", "readying", "ready", "applying" ]
Expand Down
4 changes: 3 additions & 1 deletion chef/data_bags/crowbar/template-provisioner.schema
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
"type": "map",
"required": false,
"mapping": {
"ssh_password": { "type": "str", "required": false }
"ssh_password": { "type": "str", "required": false },
"do_self_update": { "type": "bool", "required": true },
"self_update_url": { "type": "str", "required": true }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
%span.help-block
= t(".access_keys_hint")

= boolean_field %w(suse autoyast do_self_update)
= string_field %w(suse autoyast self_update_url)
%span.help-block
= t(".suse.autoyast.self_update_url_hint")

= string_field :shell_prompt
%span.help-block
= t(".shell_prompt_hint")
Expand Down
5 changes: 5 additions & 0 deletions crowbar_framework/config/locales/provisioner/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ en:
edit_attributes:
access_keys: 'Additional SSH keys'
access_keys_hint: 'Each SSH key must be on its own line'
suse:
autoyast:
do_self_update: 'Update AutoYaST before installing node'
self_update_url: 'AutoYaST Self-update URL'
self_update_url_hint: 'The alias <ADMINWEB> can be used to specify the admin server. An empty URL implies scc.suse.com.'
shell_prompt: 'Custom Shell Prompt'
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.'
serial_console: 'Serial Console'
Expand Down