From df35e120932ac58a93ac03809137fbf8f8f3a0dd Mon Sep 17 00:00:00 2001 From: Nicolas Bock Date: Wed, 23 Nov 2016 12:14:49 -0700 Subject: [PATCH] [provisioner] Add autoyast self update option --- .../cookbooks/provisioner/recipes/update_nodes.rb | 4 ++++ .../templates/default/autoyast.xml.erb | 15 +++++++++++++++ .../migrate/provisioner/102_self_update.rb | 9 +++++++++ chef/data_bags/crowbar/template-provisioner.json | 3 ++- .../data_bags/crowbar/template-provisioner.schema | 1 + .../provisioner/_edit_attributes.html.haml | 2 ++ .../config/locales/provisioner/en.yml | 1 + 7 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 chef/data_bags/crowbar/migrate/provisioner/102_self_update.rb diff --git a/chef/cookbooks/provisioner/recipes/update_nodes.rb b/chef/cookbooks/provisioner/recipes/update_nodes.rb index 96bd8915dd..076ef4c4a7 100644 --- a/chef/cookbooks/provisioner/recipes/update_nodes.rb +++ b/chef/cookbooks/provisioner/recipes/update_nodes.rb @@ -290,6 +290,7 @@ def find_node_boot_mac_addresses(node, admin_data_net) append << "ifcfg=dhcp4 netwait=60" append << "squash=0" # workaround bsc#962397 append << "autoupgrade=1" if mnode[:state] == "os-upgrading" + append << "self_update" target_platform_distro = os.gsub(/-.*$/, "") target_platform_version = os.gsub(/^.*-/, "") @@ -333,6 +334,9 @@ def find_node_boot_mac_addresses(node, admin_data_net) web_port: web_port, packages: packages, repos: repos, + self_update_url: node[:provisioner][:self_update_url].gsub( + //, "#{admin_ip}:#{web_port}" + ), rootpw_hash: node[:provisioner][:root_password_hash] || "", timezone: timezone, boot_device: (mnode[:crowbar_wall][:boot_device] rescue nil), diff --git a/chef/cookbooks/provisioner/templates/default/autoyast.xml.erb b/chef/cookbooks/provisioner/templates/default/autoyast.xml.erb index 3d57491eab..1eaa1e2b62 100644 --- a/chef/cookbooks/provisioner/templates/default/autoyast.xml.erb +++ b/chef/cookbooks/provisioner/templates/default/autoyast.xml.erb @@ -26,7 +26,22 @@ true + <% unless @self_update_url.nil? || @self_update_url.empty? -%> + <%= @self_update_url %> + <% end -%> + + + true + true + 10 + + + true + true + 10 + + <% @repos.keys.sort.each do |name| %> diff --git a/chef/data_bags/crowbar/migrate/provisioner/102_self_update.rb b/chef/data_bags/crowbar/migrate/provisioner/102_self_update.rb new file mode 100644 index 0000000000..dbb24cf26c --- /dev/null +++ b/chef/data_bags/crowbar/migrate/provisioner/102_self_update.rb @@ -0,0 +1,9 @@ +def upgrade(ta, td, a, d) + a["self_update_url"] = ta["self_update_url"] + return a, d +end + +def downgrade(ta, td, a, d) + delete a["self_update_url"] + return a, d +end diff --git a/chef/data_bags/crowbar/template-provisioner.json b/chef/data_bags/crowbar/template-provisioner.json index f7a4a45d7e..3f0fb46ea7 100644 --- a/chef/data_bags/crowbar/template-provisioner.json +++ b/chef/data_bags/crowbar/template-provisioner.json @@ -9,6 +9,7 @@ "access_keys": "", "shell_prompt": "USER@HOST:CWD SUFFIX", "enable_pxe": true, + "self_update_url": "", "discovery": { "append": "" }, @@ -199,7 +200,7 @@ "provisioner": { "crowbar-revision": 0, "crowbar-applied": false, - "schema-revision": 101, + "schema-revision": 102, "element_states": { "provisioner-server": [ "readying", "ready", "applying" ], "provisioner-base": [ "hardware-installing", "readying", "ready", "applying" ] diff --git a/chef/data_bags/crowbar/template-provisioner.schema b/chef/data_bags/crowbar/template-provisioner.schema index 6f6deb9d5c..1a9a841db8 100644 --- a/chef/data_bags/crowbar/template-provisioner.schema +++ b/chef/data_bags/crowbar/template-provisioner.schema @@ -19,6 +19,7 @@ "access_keys": { "type": "str", "required": true }, "shell_prompt": { "type": "str", "required": true }, "enable_pxe": { "type": "bool", "required": true }, + "self_update_url": { "type": "str", "required": true }, "web_port": { "type": "int", "required": true }, "keep_existing_hostname": { "type": "bool", "required": true }, "timezone": { "type": "str", "required": true }, diff --git a/crowbar_framework/app/views/barclamp/provisioner/_edit_attributes.html.haml b/crowbar_framework/app/views/barclamp/provisioner/_edit_attributes.html.haml index 01e43e4218..563c6f384f 100644 --- a/crowbar_framework/app/views/barclamp/provisioner/_edit_attributes.html.haml +++ b/crowbar_framework/app/views/barclamp/provisioner/_edit_attributes.html.haml @@ -7,6 +7,8 @@ %span.help-block = t(".access_keys_hint") + = string_field :self_update_url + = string_field :shell_prompt %span.help-block = t(".shell_prompt_hint") diff --git a/crowbar_framework/config/locales/provisioner/en.yml b/crowbar_framework/config/locales/provisioner/en.yml index 7708da5404..303e3a563a 100644 --- a/crowbar_framework/config/locales/provisioner/en.yml +++ b/crowbar_framework/config/locales/provisioner/en.yml @@ -21,6 +21,7 @@ en: edit_attributes: access_keys: 'Additional SSH keys' access_keys_hint: 'Each SSH key must be on its own line' + self_update_url: 'AutoYaST Self-update URL (The alias can be used to specify the admin node)' 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'