chef-provisioning-azure 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,15 @@
1
- require 'bundler'
2
- require 'bundler/gem_tasks'
3
-
4
- task :spec do
5
- require File.expand_path('spec/run')
6
- end
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
3
+
4
+ task :spec do
5
+ require File.expand_path("spec/run")
6
+ end
7
+
8
+ require "github_changelog_generator/task"
9
+
10
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
11
+ config.future_release = Chef::Provisioning::AzureDriver::VERSION
12
+ config.enhancement_labels = "enhancement,Enhancement,New Feature".split(",")
13
+ config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",")
14
+ config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog".split(",")
15
+ end
@@ -0,0 +1,33 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib')
2
+ require 'chef/provisioning/azure_driver/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'chef-provisioning-azure'
6
+ s.version = Chef::Provisioning::AzureDriver::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.extra_rdoc_files = %w(README.md LICENSE)
9
+ s.summary = 'Provisioner for creating Microsoft Azure resources using ' \
10
+ 'Chef Provisioning.'
11
+ s.description = 'This is a driver that works with chef-provisioning that ' \
12
+ 'allows Chef Provisioning to manage objects in Microsoft Azure.'
13
+ s.author = 'John Ewart'
14
+ s.email = 'jewart@getchef.com'
15
+ s.homepage = 'https://github.com/chef/chef-provisioning-azure'
16
+ s.license = 'Apache-2.0'
17
+
18
+ s.add_dependency 'chef-provisioning', '~> 1.0'
19
+ s.add_dependency 'stuartpreston-azure-sdk-for-ruby', '~> 0.7'
20
+
21
+ s.add_development_dependency 'chef', '>= 12.0'
22
+ s.add_development_dependency 'rspec'
23
+ s.add_development_dependency 'rake'
24
+ s.add_development_dependency 'yard'
25
+ s.add_development_dependency 'github_changelog_generator'
26
+
27
+ s.bindir = 'bin'
28
+ s.executables = %w( )
29
+
30
+ s.require_path = 'lib'
31
+ s.files = %w(Gemfile Rakefile LICENSE README.md) + Dir.glob('*.gemspec')
32
+ s.files += Dir.glob('{distro,lib,tasks,spec}/**/*', File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
33
+ end
@@ -1,21 +1,21 @@
1
- require 'chef/provisioning/azure_driver/azure_provider'
2
-
3
- class Chef
4
- class Provider
5
- class AzureCloudService < Chef::Provisioning::AzureDriver::AzureProvider
6
- action :create do
7
- Chef::Log.info("Creating AzureCloudService: #{new_resource.name}")
8
- csms = Azure::CloudServiceManagementService.new
9
- csms.create_cloud_service(new_resource.name, new_resource.options)
10
- properties = csms.get_cloud_service_properties(new_resource.name)
11
- Chef::Log.debug("Properties of #{new_resource.name}: #{properties.inspect}")
12
- end
13
-
14
- action :destroy do
15
- Chef::Log.info("Destroying AzureCloudService: #{new_resource.name}")
16
- csms = Azure::CloudServiceManagementService.new
17
- csms.delete_cloud_service(new_resource.name)
18
- end
19
- end
20
- end
21
- end
1
+ require 'chef/provisioning/azure_driver/azure_provider'
2
+
3
+ class Chef
4
+ class Provider
5
+ class AzureCloudService < Chef::Provisioning::AzureDriver::AzureProvider
6
+ action :create do
7
+ Chef::Log.info("Creating AzureCloudService: #{new_resource.name}")
8
+ csms = Azure::CloudServiceManagementService.new
9
+ csms.create_cloud_service(new_resource.name, new_resource.options)
10
+ properties = csms.get_cloud_service_properties(new_resource.name)
11
+ Chef::Log.debug("Properties of #{new_resource.name}: #{properties.inspect}")
12
+ end
13
+
14
+ action :destroy do
15
+ Chef::Log.info("Destroying AzureCloudService: #{new_resource.name}")
16
+ csms = Azure::CloudServiceManagementService.new
17
+ csms.delete_cloud_service(new_resource.name)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,36 +1,36 @@
1
- require 'chef/provisioning/azure_driver/azure_provider'
2
-
3
- class Chef
4
- class Provider
5
- class AzureSqlServer < Chef::Provisioning::AzureDriver::AzureProvider
6
- action :create do
7
- restore = Azure.config.management_endpoint
8
- Azure.config.management_endpoint = azure_sql_management_endpoint
9
- Chef::Log.info("Creating AzureSqlServer: #{new_resource.name}")
10
- csql = Azure::SqlDatabaseManagementService.new
11
- Chef::Log.info("#{new_resource.options.inspect}")
12
- properties = csql.create_server("#{new_resource.options[:login]}", \
13
- "#{new_resource.options[:password]}", \
14
- "#{new_resource.options[:location]}")
15
- server = properties.name
16
-
17
- new_resource.options[:firewall_rules].each do | rule |
18
- rule_name = URI::encode(rule[:name])
19
- range = {
20
- :start_ip_address => rule[:start_ip_address],
21
- :end_ip_address => rule[:end_ip_address]
22
- }
23
- csql.set_sql_server_firewall_rule(server, rule_name, range)
24
- end
25
-
26
- Chef::Log.info("Properties of #{new_resource.name}: #{properties.inspect}")
27
- Azure.config.management_endpoint = restore
28
- end
29
-
30
- action :destroy do
31
- # not supported
32
- fail "Destroy not yet implemented on Azure SQL Server using ASM."
33
- end
34
- end
35
- end
36
- end
1
+ require 'chef/provisioning/azure_driver/azure_provider'
2
+
3
+ class Chef
4
+ class Provider
5
+ class AzureSqlServer < Chef::Provisioning::AzureDriver::AzureProvider
6
+ action :create do
7
+ restore = Azure.config.management_endpoint
8
+ Azure.config.management_endpoint = azure_sql_management_endpoint
9
+ Chef::Log.info("Creating AzureSqlServer: #{new_resource.name}")
10
+ csql = Azure::SqlDatabaseManagementService.new
11
+ Chef::Log.info("#{new_resource.options.inspect}")
12
+ properties = csql.create_server("#{new_resource.options[:login]}", \
13
+ "#{new_resource.options[:password]}", \
14
+ "#{new_resource.options[:location]}")
15
+ server = properties.name
16
+
17
+ new_resource.options[:firewall_rules].each do | rule |
18
+ rule_name = URI::encode(rule[:name])
19
+ range = {
20
+ :start_ip_address => rule[:start_ip_address],
21
+ :end_ip_address => rule[:end_ip_address]
22
+ }
23
+ csql.set_sql_server_firewall_rule(server, rule_name, range)
24
+ end
25
+
26
+ Chef::Log.info("Properties of #{new_resource.name}: #{properties.inspect}")
27
+ Azure.config.management_endpoint = restore
28
+ end
29
+
30
+ action :destroy do
31
+ # not supported
32
+ fail "Destroy not yet implemented on Azure SQL Server using ASM."
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,21 +1,21 @@
1
- require 'chef/provisioning/azure_driver/azure_provider'
2
-
3
- class Chef
4
- class Provider
5
- class AzureStorageAccount < Chef::Provisioning::AzureDriver::AzureProvider
6
- action :create do
7
- Chef::Log.info("Creating AzureStorageAccount: #{new_resource.name}")
8
- sms = Azure::StorageManagementService.new
9
- sms.create_storage_account(new_resource.name, new_resource.options)
10
- properties = sms.get_storage_account_properties(new_resource.name)
11
- Chef::Log.debug("Properties of #{new_resource.name}: #{properties.inspect}")
12
- end
13
-
14
- action :destroy do
15
- Chef::Log.info("Destroying AzureStorageAccount: #{new_resource.name}")
16
- sms = Azure::StorageManagementService.new
17
- sms.delete_storage_account(new_resource.name)
18
- end
19
- end
20
- end
21
- end
1
+ require 'chef/provisioning/azure_driver/azure_provider'
2
+
3
+ class Chef
4
+ class Provider
5
+ class AzureStorageAccount < Chef::Provisioning::AzureDriver::AzureProvider
6
+ action :create do
7
+ Chef::Log.info("Creating AzureStorageAccount: #{new_resource.name}")
8
+ sms = Azure::StorageManagementService.new
9
+ sms.create_storage_account(new_resource.name, new_resource.options)
10
+ properties = sms.get_storage_account_properties(new_resource.name)
11
+ Chef::Log.debug("Properties of #{new_resource.name}: #{properties.inspect}")
12
+ end
13
+
14
+ action :destroy do
15
+ Chef::Log.info("Destroying AzureStorageAccount: #{new_resource.name}")
16
+ sms = Azure::StorageManagementService.new
17
+ sms.delete_storage_account(new_resource.name)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
- require 'chef/provisioning'
2
- require 'chef/provisioning/azure_driver/driver'
3
- require 'chef/provisioning/azure_driver/resources'
1
+ require 'chef/provisioning'
2
+ require 'chef/provisioning/azure_driver/driver'
3
+ require 'chef/provisioning/azure_driver/resources'
@@ -1,33 +1,33 @@
1
- require 'chef/provider/lwrp_base'
2
- require 'chef/provisioning/azure_driver/azure_resource'
3
- require 'chef/provisioning/chef_provider_action_handler'
4
- require 'azure'
5
-
6
- class Chef
7
- module Provisioning
8
- module AzureDriver
9
- class AzureProvider < Chef::Provider::LWRPBase
10
- use_inline_resources
11
-
12
- AzureResource = Chef::Provisioning::AzureDriver::AzureResource
13
-
14
- def azure_sql_management_endpoint
15
- 'https://management.database.windows.net:8443'
16
- end
17
-
18
- def action_handler
19
- @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
20
- end
21
-
22
- # All these need to implement whyrun
23
- def whyrun_supported?
24
- true
25
- end
26
-
27
- def driver
28
- new_resource.driver
29
- end
30
- end
31
- end
32
- end
33
- end
1
+ require 'chef/provider/lwrp_base'
2
+ require 'chef/provisioning/azure_driver/azure_resource'
3
+ require 'chef/provisioning/chef_provider_action_handler'
4
+ require 'azure'
5
+
6
+ class Chef
7
+ module Provisioning
8
+ module AzureDriver
9
+ class AzureProvider < Chef::Provider::LWRPBase
10
+ use_inline_resources
11
+
12
+ AzureResource = Chef::Provisioning::AzureDriver::AzureResource
13
+
14
+ def azure_sql_management_endpoint
15
+ 'https://management.database.windows.net:8443'
16
+ end
17
+
18
+ def action_handler
19
+ @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
20
+ end
21
+
22
+ # All these need to implement whyrun
23
+ def whyrun_supported?
24
+ true
25
+ end
26
+
27
+ def driver
28
+ new_resource.driver
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,51 +1,51 @@
1
- require 'chef/resource/lwrp_base'
2
- require 'chef/provisioning/azure_driver/subscriptions'
3
-
4
- class Chef
5
- module Provisioning
6
- module AzureDriver
7
- class AzureResource < Chef::Resource::LWRPBase
8
- def initialize(*args)
9
- super
10
- if run_context
11
- @chef_environment = run_context.cheffish.current_environment
12
- @chef_server = run_context.cheffish.current_chef_server
13
- @driver = run_context.chef_provisioning.current_driver
14
- end
15
-
16
- config = run_context.chef_provisioning.config
17
- scheme, account_id = driver.split(':', 2)
18
-
19
- if account_id.nil? || account_id.empty?
20
- subscription = Subscriptions.default_subscription(config)
21
- config = Cheffish::MergedConfig.new({ azure_subscriptions: subscription }, config)
22
- if !subscription
23
- raise "Driver #{driver} did not specify a subscription ID, and no default subscription was found. Have you downloaded the Azure CLI and used `azure account download` and `azure account import` to set up Azure? Alternately, you can set azure_subscriptions to [ { subscription_id: '...', management_credentials: ... }] in your Chef configuration."
24
- end
25
- else
26
- subscription_id = account_id || subscription[:subscription_id]
27
- subscription = Subscriptions.get_subscription(config, subscription_id)
28
- end
29
-
30
- if !subscription
31
- raise "Driver #{driver} has a subscription ID (#{subscription_id}), but the system has no credentials configured for it! If you have access to this subscription, you can use `azure account download` and `azure account import` in the Azure CLI to get the credentials, or set azure_subscriptions to [ { subscription_id: '...', management_credentials: ... }] in your Chef configuration."
32
- else
33
- Chef::Log.debug("Using subscription: #{subscription.inspect}")
34
- end
35
-
36
- Azure.configure do |azure|
37
- azure.management_certificate = subscription[:management_certificate]
38
- azure.subscription_id = subscription[:subscription_id]
39
- azure.management_endpoint = subscription[:management_endpoint]
40
- end
41
- end
42
-
43
- attribute :driver
44
- attribute :chef_server, kind_of: Hash
45
- attribute :managed_entry_store, kind_of: Chef::Provisioning::ManagedEntryStore,
46
- lazy_default: proc { Chef::Provisioning::ChefManagedEntryStore.new(chef_server) }
47
- attribute :subscription
48
- end
49
- end
50
- end
51
- end
1
+ require 'chef/resource/lwrp_base'
2
+ require 'chef/provisioning/azure_driver/subscriptions'
3
+
4
+ class Chef
5
+ module Provisioning
6
+ module AzureDriver
7
+ class AzureResource < Chef::Resource::LWRPBase
8
+ def initialize(*args)
9
+ super
10
+ if run_context
11
+ @chef_environment = run_context.cheffish.current_environment
12
+ @chef_server = run_context.cheffish.current_chef_server
13
+ @driver = run_context.chef_provisioning.current_driver
14
+ end
15
+
16
+ config = run_context.chef_provisioning.config
17
+ scheme, account_id = driver.split(':', 2)
18
+
19
+ if account_id.nil? || account_id.empty?
20
+ subscription = Subscriptions.default_subscription(config)
21
+ config = Cheffish::MergedConfig.new({ azure_subscriptions: subscription }, config)
22
+ if !subscription
23
+ raise "Driver #{driver} did not specify a subscription ID, and no default subscription was found. Have you downloaded the Azure CLI and used `azure account download` and `azure account import` to set up Azure? Alternately, you can set azure_subscriptions to [ { subscription_id: '...', management_credentials: ... }] in your Chef configuration."
24
+ end
25
+ else
26
+ subscription_id = account_id || subscription[:subscription_id]
27
+ subscription = Subscriptions.get_subscription(config, subscription_id)
28
+ end
29
+
30
+ if !subscription
31
+ raise "Driver #{driver} has a subscription ID (#{subscription_id}), but the system has no credentials configured for it! If you have access to this subscription, you can use `azure account download` and `azure account import` in the Azure CLI to get the credentials, or set azure_subscriptions to [ { subscription_id: '...', management_credentials: ... }] in your Chef configuration."
32
+ else
33
+ Chef::Log.debug("Using subscription: #{subscription.inspect}")
34
+ end
35
+
36
+ Azure.configure do |azure|
37
+ azure.management_certificate = subscription[:management_certificate]
38
+ azure.subscription_id = subscription[:subscription_id]
39
+ azure.management_endpoint = subscription[:management_endpoint]
40
+ end
41
+ end
42
+
43
+ attribute :driver
44
+ attribute :chef_server, kind_of: Hash
45
+ attribute :managed_entry_store, kind_of: Chef::Provisioning::ManagedEntryStore,
46
+ lazy_default: proc { Chef::Provisioning::ChefManagedEntryStore.new(chef_server) }
47
+ attribute :subscription
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,25 +1,25 @@
1
- class Chef
2
- module Provisioning
3
- module AzureDriver
4
- # Represents available options when bootstrapping a host on Azure
5
- # These are used to tell Azure some initial pieces of information
6
- # for building a new VM.
7
- class BootstrapOptions < Chef::Provisioning::BootstrapOptions
8
- # @return [String] The name of the VM
9
- attr_accessor :vm_name
10
-
11
- # @return [String] The VM user
12
- attr_accessor :vm_user
13
-
14
- # @return [String] The identifier for the VM image to use
15
- attr_accessor :image
16
-
17
- # @return [String] the password to use
18
- attr_accessor :password
19
-
20
- # @return [String] The Azure location to store this in
21
- attr_accessor :location
22
- end
23
- end
24
- end
25
- end
1
+ class Chef
2
+ module Provisioning
3
+ module AzureDriver
4
+ # Represents available options when bootstrapping a host on Azure
5
+ # These are used to tell Azure some initial pieces of information
6
+ # for building a new VM.
7
+ class BootstrapOptions < Chef::Provisioning::BootstrapOptions
8
+ # @return [String] The name of the VM
9
+ attr_accessor :vm_name
10
+
11
+ # @return [String] The VM user
12
+ attr_accessor :vm_user
13
+
14
+ # @return [String] The identifier for the VM image to use
15
+ attr_accessor :image
16
+
17
+ # @return [String] the password to use
18
+ attr_accessor :password
19
+
20
+ # @return [String] The Azure location to store this in
21
+ attr_accessor :location
22
+ end
23
+ end
24
+ end
25
+ end