Class: Chef::Knife::BootstrapAzurerm
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::BootstrapAzurerm
- Includes:
- AzurermBase, Chef::Knife::Bootstrap::Bootstrapper, Chef::Knife::Bootstrap::CommonBootstrapOptions
- Defined in:
- lib/chef/knife/bootstrap_azurerm.rb
Constant Summary
Constants included from Azure::ARM::ReadCred
Azure::ARM::ReadCred::CRED_TYPE_DOMAIN_CERTIFICATE, Azure::ARM::ReadCred::CRED_TYPE_DOMAIN_PASSWORD, Azure::ARM::ReadCred::CRED_TYPE_DOMAIN_VISIBLE_PASSWORD, Azure::ARM::ReadCred::CRED_TYPE_GENERIC
Instance Method Summary collapse
Methods included from Chef::Knife::Bootstrap::Bootstrapper
#bootstrap_common_params, #bootstrap_exec, #bootstrap_for_node, #bootstrap_for_windows_node, #create_node_and_client_pem, #default_bootstrap_template, #default_hint_options, #get_chef_extension_name, #get_chef_extension_private_params, #get_chef_extension_public_params, #get_chef_extension_publisher, #get_chef_extension_version, #load_cloud_attributes_in_hints, #load_correct_secret, #load_winrm_deps, #ohai_hints, #tcp_test_ssh, #tcp_test_winrm
Methods included from Chef::Knife::Bootstrap::CommonBootstrapOptions
Methods included from AzurermBase
#authentication_details, #azure_authentication, #check_token_validity, #find_file, #get_azure_cli_version, included, #is_token_valid?, #locate_config_value, #msg_server_summary, #parse_publish_settings_file, #refresh_token, #service, #token_details_for_linux, #token_details_for_windows, #token_details_from_accessToken_file, #validate_arm_keys!, #validate_azure_login, #validate_params!
Methods included from Azure::ARM::WindowsCredentials
#latest_credential_target, #target_name, #token_details_from_WCM
Instance Method Details
#run ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/chef/knife/bootstrap_azurerm.rb', line 42 def run ui.log("Validating...") validate_arm_keys!(:azure_resource_group_name, :azure_service_location) begin if @name_args.length == 1 ui.log("Creating VirtualMachineExtension....") ext_params = set_ext_params vm_extension = service.create_vm_extension(ext_params) if vm_extension if ext_params[:chef_extension_public_param][:extendedLogs] == "true" service.fetch_chef_client_logs(ext_params[:azure_resource_group_name], ext_params[:azure_vm_name], ext_params[:chef_extension], Time.now) end ui.log("VirtualMachineExtension creation successfull.") ui.log("Virtual Machine Extension name is: #{vm_extension.name}") ui.log("Virtual Machine Extension ID is: #{vm_extension.id}") end else raise ArgumentError, "Please specify the SERVER name which needs to be bootstrapped via the Chef Extension." if @name_args.length == 0 raise ArgumentError, "Please specify only one SERVER name which needs to be bootstrapped via the Chef Extension." if @name_args.length > 1 end rescue => error service.common_arm_rescue_block(error) end end |
#set_ext_params ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/chef/knife/bootstrap_azurerm.rb', line 68 def set_ext_params server = service.find_server(locate_config_value(:azure_resource_group_name), name_args[0]) if server if service.extension_already_installed?(server) raise "Virtual machine #{server.name} already has Chef extension installed on it." else ext_params = Hash.new case server.storage_profile.os_disk.os_type.downcase when "windows" ext_params[:chef_extension] = "ChefClient" when "linux" if %w{ubuntu debian rhel centos}.any? { |platform| server.storage_profile.image_reference.offer.downcase.include? platform } ext_params[:chef_extension] = "LinuxChefClient" else raise "Offer #{server.storage_profile.image_reference.offer} is not supported in the extension." end else raise "OS type #{server.storage_profile.os_disk.os_type} is not supported." end ext_params[:azure_resource_group_name] = locate_config_value(:azure_resource_group_name) ext_params[:azure_vm_name] = @name_args[0] ext_params[:azure_service_location] = locate_config_value(:azure_service_location) ext_params[:chef_extension_publisher] = get_chef_extension_publisher ext_params[:chef_extension_version] = get_chef_extension_version(ext_params[:chef_extension]) ext_params[:chef_extension_public_param] = get_chef_extension_public_params ext_params[:chef_extension_private_param] = get_chef_extension_private_params end else raise "The given server '#{@name_args[0]}' does not exist under resource group '#{locate_config_value(:azure_resource_group_name)}'" end ext_params end |