diff --git a/doc/Kadeploy.tex b/doc/Kadeploy.tex index 42a640f30ec0ca137801584fee210519710da2b7..51173ebde263d403b14f1f4ffe960dd9d3346cbf 100644 --- a/doc/Kadeploy.tex +++ b/doc/Kadeploy.tex @@ -1169,6 +1169,7 @@ automata: \begin{itemize} \item \yfieldd{sleep\_time\_before\_boot}{Integer}{20} seconds of sleep before the first ping request to detect when a node is ready. Generally, it represents the average time during the node power up until it sends a dhcp request. \item \yfield{install\_bootloader}{String} Path to a script that install a bootloader on the deployment partition. You can use Kadeploy3 environment variables (see section \ref{sec:env_vars}) in this script. Please refer to section \ref{sec:bootscript}) for further informations. + \item \yfield{startup\_script}{String} An admin script to be executed on each node at the boot of the deployment kernel. Can be ommited. You can use Kadeploy3 environment variables (see section \ref{sec:env_vars}) in this script. Please refer to section \ref{sec:bootscript}) for further informations. \end{itemize} \item \ypath{/boot/kernels} Options of OS kernel's that are booted by Kadeploy3 diff --git a/lib/kadeploy3/server/config.rb b/lib/kadeploy3/server/config.rb index 521a85a25621fd50c3c84bf4e002658bc7fc0575..dae2259a63acb33d9ddbb8e880fab55c811c2614 100644 --- a/lib/kadeploy3/server/config.rb +++ b/lib/kadeploy3/server/config.rb @@ -878,6 +878,7 @@ module Configuration attr_reader :nfsroot_params attr_reader :admin_pre_install attr_reader :admin_post_install + attr_reader :startup_script attr_reader :use_ip_to_deploy attr_reader :cmd_ext attr_reader :trusted_deployment_user @@ -1033,6 +1034,8 @@ module Configuration @sleep_time_before_ping = cp.value('sleep_time_before_ping', Integer, 20) @bootloader_script = cp.value('install_bootloader', String, nil, { :type => 'file', :readable => true, :prefix => Config.dir() }) + @startup_script = cp.value('startup_script', String, '', + { :type => 'file', :readable => true, :prefix => Config.dir() }) cp.parse('kernels', true) do cp.parse('user') do @kernel_params = cp.value('params', String, '') diff --git a/lib/kadeploy3/server/macrostep.rb b/lib/kadeploy3/server/macrostep.rb index 7995ea885e589bbcd8424d6f902aa0f035664ad1..3e30b2fec959ae37187e658dc7566e6155110d5a 100644 --- a/lib/kadeploy3/server/macrostep.rb +++ b/lib/kadeploy3/server/macrostep.rb @@ -318,8 +318,9 @@ module Macrostep delete_task(:manage_user_post_install, "no user postinstall") if cexec.environment.postinstall.nil? - delete_task(:set_default_vlan, "no vlan cmd set") if cexec.vlan_id.nil? && context[:common].set_vlan_cmd.nil? && context[:common].set_vlan_script.empty? + delete_task(:set_default_vlan, "no vlan cmd set") if cexec.vlan_id.nil? || context[:common].set_vlan_cmd.nil? || context[:common].set_vlan_script.empty? delete_task(:set_vlan, "no vlan set") if cexec.vlan_id.nil? + delete_task(:startup_script, "no startup script set") if context[:cluster].startup_script.nil? || context[:cluster].startup_script.empty? # Do not reformat deploy partition if !cexec.deploy_part.nil? and cexec.deploy_part != "" diff --git a/lib/kadeploy3/server/microsteps.rb b/lib/kadeploy3/server/microsteps.rb index 8779f2bb00518373cdd40fff4b6f50822014506c..898cf592fc760b708c73b0f7648d1a7226d7079b 100644 --- a/lib/kadeploy3/server/microsteps.rb +++ b/lib/kadeploy3/server/microsteps.rb @@ -1947,6 +1947,16 @@ class Microstep < Automata::QueueTask return parallel_exec("mount #{tmp_part} /tmp") end + # Custom script executed just after Deployment Mini OS boot + def ms_startup_script + parallel_exec( + run_script(), + { + :input_file => context[:cluster].startup_script, + :scattering => :tree + }) + end + # Send the SSH key in the deployed environment # # Arguments diff --git a/lib/kadeploy3/server/stepdeploy.rb b/lib/kadeploy3/server/stepdeploy.rb index 1959add7f993183409ec121361897f95e918b73c..7f020147adf5cd192532e191f8ff7cf461f3b25f 100644 --- a/lib/kadeploy3/server/stepdeploy.rb +++ b/lib/kadeploy3/server/stepdeploy.rb @@ -16,6 +16,7 @@ module Macrostep [:set_default_vlan], [:reboot, "soft"], [:wait_reboot], + [:startup_script], [:send_key_in_deploy_env, :tree], [:create_partition_table], [:format_deploy_part], @@ -34,6 +35,7 @@ module Macrostep [:set_default_vlan], [:kexec, :to_deploy_kernel], [:wait_reboot], + [:startup_script], [:send_key_in_deploy_env, :tree], [:create_partition_table], [:format_deploy_part], @@ -56,6 +58,7 @@ module Macrostep [:set_default_vlan], [:reboot, "soft"], [:wait_reboot], + [:startup_script], [:send_key_in_deploy_env, :tree], [:manage_admin_pre_install, :tree], ] @@ -79,6 +82,7 @@ module Macrostep [:set_default_vlan], [:reboot, "soft"], [:wait_reboot], + [:startup_script], [:send_key_in_deploy_env, :tree], [:create_partition_table], [:format_deploy_part], diff --git a/vagrant-env/kadeploy_conf/sample-cluster.conf b/vagrant-env/kadeploy_conf/sample-cluster.conf index 4eef65d6ccae147dd1563964450f138368e351da..3db47caac8b24c7b454314d86c1243706740ceed 100644 --- a/vagrant-env/kadeploy_conf/sample-cluster.conf +++ b/vagrant-env/kadeploy_conf/sample-cluster.conf @@ -25,6 +25,7 @@ arch: boot: sleep_time_before_ping: 0 install_bootloader: /vagrant/scripts/install-grub2-dev.sh + startup_script: /vagrant/scripts/startup.sh kernels: deploy: initrd: kernels/kadeploy3-deploy-kernel-buster.initrd.img diff --git a/vagrant-env/scripts/startup.sh b/vagrant-env/scripts/startup.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc9d44b58a72ff9da9ce7eaf1cc012354d583351 --- /dev/null +++ b/vagrant-env/scripts/startup.sh @@ -0,0 +1 @@ +echo "Execution of startup script" > /dev/kmsg