diff --git a/lib/chef_metal_fog/fog_driver.rb b/lib/chef_metal_fog/fog_driver.rb index 269235f..dc24b1c 100644 --- a/lib/chef_metal_fog/fog_driver.rb +++ b/lib/chef_metal_fog/fog_driver.rb @@ -429,11 +429,13 @@ def overwrite_default_key_willy_nilly(action_handler) 'metal_default' end + def bootstrap_helper(action_handler, machine_spec, machine_options, bootstrap_options) + bootstrap_options + end + def bootstrap_options_for(action_handler, machine_spec, machine_options) bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {}) - if provider == 'AWS' && !bootstrap_options[:key_name] - bootstrap_options[:key_name] = overwrite_default_key_willy_nilly(action_handler) - end + bootstrap_options = bootstrap_helper(action_handler, machine_spec, machine_options, bootstrap_options) tags = { 'Name' => machine_spec.name, 'BootstrapId' => machine_spec.id, diff --git a/lib/chef_metal_fog/providers/aws.rb b/lib/chef_metal_fog/providers/aws.rb index 81e0823..df5deb9 100644 --- a/lib/chef_metal_fog/providers/aws.rb +++ b/lib/chef_metal_fog/providers/aws.rb @@ -20,6 +20,13 @@ def default_ssh_username 'ubuntu' end + def bootstrap_helper(action_handler, machine_spec, machine_options, bootstrap_options) + unless bootstrap_options[:key_name] + bootstrap_options[:key_name] = overwrite_default_key_willy_nilly(action_handler) + end + bootstrap_options + end + def self.get_aws_profile(driver_options, aws_account_id) aws_credentials = get_aws_credentials(driver_options) compute_options = driver_options[:compute_options] || {} diff --git a/lib/chef_metal_fog/providers/digitalocean.rb b/lib/chef_metal_fog/providers/digitalocean.rb index faa1354..810056f 100644 --- a/lib/chef_metal_fog/providers/digitalocean.rb +++ b/lib/chef_metal_fog/providers/digitalocean.rb @@ -9,22 +9,11 @@ def creator '' end - def bootstrap_options_for(action_handler, machine_spec, machine_options) - bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {}) + def bootstrap_helper(action_handler, machine_spec, machine_options, bootstrap_options) unless bootstrap_options[:key_name] bootstrap_options[:key_name] = overwrite_default_key_willy_nilly(action_handler) end - tags = { - 'Name' => machine_spec.name, - 'BootstrapId' => machine_spec.id, - 'BootstrapHost' => Socket.gethostname, - 'BootstrapUser' => Etc.getlogin - } - # User-defined tags override the ones we set - tags.merge!(bootstrap_options[:tags]) if bootstrap_options[:tags] - bootstrap_options.merge!({ :tags => tags }) - if !bootstrap_options[:image_id] bootstrap_options[:image_name] ||= 'CentOS 6.4 x32' bootstrap_options[:image_id] = compute.images.select { |image| image.name == bootstrap_options[:image_name] }.first.id