foreman_azure_rm 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 416621db4c525470113b126a84a30a5701999e6bc442f6e18beb0bdd6b3379a3
4
- data.tar.gz: 6ec1793bc3394b0a19f92f5ad98a33c005e30fce89bd549ebde954529ab7d895
3
+ metadata.gz: 03cab7177e77cb36e5e24755b2fadcd0b6934203001667ba89bd194b0d8d97a1
4
+ data.tar.gz: 2ddd6e70ddc620a1a859190f36b65fcd662241d8503b08bda0de606364a8a1df
5
5
  SHA512:
6
- metadata.gz: f8a953836164727d9bba985be5d77b8211c73bc2cc20f45c7de563d49fb06cd32652695e6b4a0b42c19e0dcd5a5d86b51b347562b460f90eb33342f518044fd7
7
- data.tar.gz: 79cbe567f0cb3556b046f208c6f7218876c4ab10fb8b74d4ae6e2d9df8a9f601b8a895cff46e236630c306f1f977a00c5976517af99c39744b6060a72b0cfda7
6
+ metadata.gz: fc7729cc420203fc3647557f5bdf13f0059a66613ef6e975062440ad75c3494f829c3ec8347470c49aebb35da50003bf8230a94529109debd6f5737d77d85d53
7
+ data.tar.gz: 42db1d9a7f3b210ac202d2c08fcb41fe8e7055c14a2e195facff44cc450dd34a61ef99f0ac8f8d2ea2b0efe676e676bb30cf5f879cf53f75f6643d219550eb15
@@ -10,8 +10,7 @@ module AzureComputeResourceHelper
10
10
  end
11
11
  selectable_f(f, :url, regions, {}, {:label => _('Azure Region'), :disabled => regions.empty?, :required => true, :help_inline_permanent => load_button_f(f, regions.present?, _("Load Regions")) })
12
12
  end
13
- def azure_doc_url
13
+ def azure_doc_version
14
14
  doc_version = Foreman::Plugin.find(:foreman_azure_rm).version.scan(/\d+\.\d+/).first + '.x'
15
- "https://theforeman.org/plugins/foreman_azure/#{doc_version}"
16
15
  end
17
16
  end
@@ -4,7 +4,7 @@ module ForemanAzureRm
4
4
  module ManagedVM
5
5
  extend ActiveSupport::Concern
6
6
 
7
- def define_managed_storage_profile(vm_name, os_disk_caching, platform, premium_os_disk)
7
+ def define_managed_storage_profile(vm_name, os_disk_caching, platform, premium_os_disk, os_disk_size_gb)
8
8
  storage_profile = ComputeModels::StorageProfile.new
9
9
  os_disk = ComputeModels::OSDisk.new
10
10
  managed_disk_params = ComputeModels::ManagedDiskParameters.new
@@ -12,6 +12,7 @@ module ForemanAzureRm
12
12
  # Create OS disk
13
13
  os_disk.name = "#{vm_name}-osdisk"
14
14
  os_disk.os_type = platform
15
+ os_disk.disk_size_gb = os_disk_size_gb
15
16
  os_disk.create_option = ComputeModels::DiskCreateOptionTypes::FromImage
16
17
  os_disk.caching = disk_caching(os_disk_caching)
17
18
  managed_disk_params.storage_account_type = if premium_os_disk == 'true'
@@ -187,21 +188,23 @@ module ForemanAzureRm
187
188
  os_profile.admin_password = vm_hash[:password]
188
189
 
189
190
  # Adding the ssh-key support for authentication
190
- os_profile.linux_configuration = ComputeModels::LinuxConfiguration.new.tap do |linux|
191
- linux.disable_password_authentication = vm_hash[:disable_password_authentication]
192
- linux.ssh = ComputeModels::SshConfiguration.new.tap do |ssh_config|
193
- ssh_config.public_keys = [
194
- ComputeModels::SshPublicKey.new.tap do |foreman_key|
195
- foreman_key.key_data = key_pair.public
196
- foreman_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
191
+ if vm_hash[:platform] == 'Linux'
192
+ os_profile.linux_configuration = ComputeModels::LinuxConfiguration.new.tap do |linux|
193
+ linux.disable_password_authentication = vm_hash[:disable_password_authentication]
194
+ linux.ssh = ComputeModels::SshConfiguration.new.tap do |ssh_config|
195
+ ssh_config.public_keys = [
196
+ ComputeModels::SshPublicKey.new.tap do |foreman_key|
197
+ foreman_key.key_data = key_pair.public
198
+ foreman_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
199
+ end
200
+ ]
201
+ if vm_hash[:ssh_key_data].present?
202
+ key_data = vm_hash[:ssh_key_data]
203
+ pub_key = ComputeModels::SshPublicKey.new
204
+ pub_key.key_data = key_data
205
+ pub_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
206
+ ssh_config.public_keys << pub_key
197
207
  end
198
- ]
199
- if vm_hash[:ssh_key_data].present?
200
- key_data = vm_hash[:ssh_key_data]
201
- pub_key = ComputeModels::SshPublicKey.new
202
- pub_key.key_data = key_data
203
- pub_key.path = "/home/#{vm_hash[:username]}/.ssh/authorized_keys"
204
- ssh_config.public_keys << pub_key
205
208
  end
206
209
  end
207
210
  end
@@ -212,7 +215,8 @@ module ForemanAzureRm
212
215
  vm_hash[:name],
213
216
  vm_hash[:os_disk_caching],
214
217
  vm_hash[:platform],
215
- vm_hash[:premium_os_disk]
218
+ vm_hash[:premium_os_disk],
219
+ vm_hash[:os_disk_size_gb]
216
220
  )
217
221
  vm.hardware_profile = ComputeModels::HardwareProfile.new.tap do |hw_profile|
218
222
  hw_profile.vm_size = vm_hash[:vm_size]
@@ -235,11 +239,22 @@ module ForemanAzureRm
235
239
  if args[:script_command].present? || args[:script_uris].present?
236
240
  args[:script_uris] ||= args[:script_uris].to_s
237
241
  extension = ComputeModels::VirtualMachineExtension.new
238
- if args[:platform] == 'Linux'
242
+
243
+ case args[:platform]
244
+ # https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux
245
+ when 'Linux'
239
246
  extension.publisher = 'Microsoft.Azure.Extensions'
240
247
  extension.virtual_machine_extension_type = 'CustomScript'
241
248
  extension.type_handler_version = '2.0'
249
+ # https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
250
+ when 'Windows'
251
+ extension.publisher = 'Microsoft.Compute'
252
+ extension.virtual_machine_extension_type = 'CustomScriptExtension'
253
+ extension.type_handler_version = '1.10'
254
+ else
255
+ raise RuntimeError, "Unsupported platform #{args[:platform]}"
242
256
  end
257
+
243
258
  extension.auto_upgrade_minor_version = true
244
259
  extension.location = region
245
260
  extension.settings = {
@@ -115,7 +115,8 @@ module ForemanAzureRm
115
115
  platform: opts[:platform],
116
116
  ssh_key_data: opts[:ssh_key_data],
117
117
  os_disk_caching: opts[:os_disk_caching],
118
- premium_os_disk: opts[:premium_os_disk]
118
+ premium_os_disk: opts[:premium_os_disk],
119
+ os_disk_size_gb: opts[:os_disk_size_gb]
119
120
  )
120
121
  if opts[:interfaces].present?
121
122
  ifaces = []
@@ -268,23 +269,26 @@ module ForemanAzureRm
268
269
  args = args.to_h.deep_symbolize_keys
269
270
  args[:vm_name] = args[:name].split('.')[0]
270
271
  nics = create_nics(region, args)
271
- if args[:password].present? && !args[:ssh_key_data].present?
272
- # Any change to sudoers_cmd and formation of new
273
- # args[:script_command] must be accordingly changed
274
- # in script_command method in AzureRmCompute class
275
- sudoers_cmd = "$echo #{args[:password]} | sudo -S echo '\"#{args[:username]}\" ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/waagent"
276
- if args[:script_command].present?
277
- # to run the script_cmd given through form as username
278
- user_command = args[:script_command]
279
- args[:script_command] = sudoers_cmd + " ; su - \"#{args[:username]}\" -c \"#{user_command}\""
272
+
273
+ if args[:platform] == 'Linux'
274
+ if args[:password].present? && !args[:ssh_key_data].present?
275
+ # Any change to sudoers_cmd and formation of new
276
+ # args[:script_command] must be accordingly changed
277
+ # in script_command method in AzureRmCompute class
278
+ sudoers_cmd = "$echo #{args[:password]} | sudo -S echo '\"#{args[:username]}\" ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/waagent"
279
+ if args[:script_command].present?
280
+ # to run the script_cmd given through form as username
281
+ user_command = args[:script_command]
282
+ args[:script_command] = sudoers_cmd + " ; su - \"#{args[:username]}\" -c \"#{user_command}\""
283
+ else
284
+ args[:script_command] = sudoers_cmd
285
+ end
286
+ disable_password_auth = false
287
+ elsif args[:ssh_key_data].present? && !args[:password].present?
288
+ disable_password_auth = true
280
289
  else
281
- args[:script_command] = sudoers_cmd
290
+ disable_password_auth = false
282
291
  end
283
- disable_password_auth = false
284
- elsif args[:ssh_key_data].present? && !args[:password].present?
285
- disable_password_auth = true
286
- else
287
- disable_password_auth = false
288
292
  end
289
293
 
290
294
  vm = create_managed_virtual_machine(
@@ -301,6 +305,7 @@ module ForemanAzureRm
301
305
  image_id: args[:image_id],
302
306
  os_disk_caching: args[:os_disk_caching],
303
307
  premium_os_disk: args[:premium_os_disk],
308
+ os_disk_size_gb: args[:os_disk_size_gb],
304
309
  data_disks: args[:volumes_attributes],
305
310
  custom_data: args[:user_data],
306
311
  script_command: args[:script_command],
@@ -179,6 +179,10 @@ module ForemanAzureRm
179
179
  @azure_vm.storage_profile.os_disk.managed_disk.storage_account_type
180
180
  end
181
181
 
182
+ def os_disk_size_gb
183
+ @azure_vm.storage_profile.os_disk.disk_size_gb
184
+ end
185
+
182
186
  def os_disk_caching
183
187
  @azure_vm.storage_profile.os_disk.caching
184
188
  end
@@ -4,8 +4,7 @@
4
4
  ['China', 'azurechina'],
5
5
  ['Germany', 'azuregermancloud'],
6
6
  ], {}, { :label => _('Cloud'), :required => true } %>
7
- <%= text_f f, :app_ident, :label => _('Client ID'), :required => true, :help_inline => link_to(icon_text('help', _('Documentation'), :kind => 'pficon'),
8
- azure_doc_url, :rel => 'external', :class => 'btn btn-default btn-docs', :target => '_blank') %>
7
+ <%= text_f f, :app_ident, :label => _('Client ID'), :required => true, :help_inline => link_to('Documentation', external_link_path(type: 'plugin_manual', name: 'foreman_azure', version: azure_doc_version), :kind => 'pficon', :rel => 'external', :class => 'btn btn-default btn-docs', :target => '_blank') %>
9
8
  <%= password_f f, :password, :label => _('Client Secret'), :keep_value => true, :required => true %>
10
9
  <%= text_f f, :user, :label => _('Subscription ID'), :required => true %>
11
10
  <%= text_f f, :uuid, :label => _('Tenant ID'), :required => true %>
@@ -154,6 +154,16 @@
154
154
  'false'
155
155
  %>
156
156
 
157
+ <%= number_f f, :os_disk_size_gb,
158
+ {
159
+ :label => _('Override OS Disk Size (GB)'),
160
+ :label_help => _("Leave empty to use default image size"),
161
+ :required => false,
162
+ :min => 1,
163
+ :class => "col-md-2",
164
+ }
165
+ %>
166
+
157
167
  <%= selectable_f f, :os_disk_caching, %w(None ReadOnly ReadWrite),
158
168
  { :include_blank => _("Azure's Default") },
159
169
  {
@@ -1,3 +1,3 @@
1
1
  module ForemanAzureRm
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,101 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_azure_rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aditi Puntambekar
8
8
  - Shimon Shtein
9
9
  - Tyler Gregory
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-03-05 00:00:00.000000000 Z
13
+ date: 2021-04-07 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: deface
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '2.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "<"
27
- - !ruby/object:Gem::Version
28
- version: '2.0'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: azure_mgmt_resources
31
17
  requirement: !ruby/object:Gem::Requirement
32
18
  requirements:
33
19
  - - "~>"
34
20
  - !ruby/object:Gem::Version
35
- version: 0.17.9
21
+ version: 0.18.1
36
22
  type: :runtime
37
23
  prerelease: false
38
24
  version_requirements: !ruby/object:Gem::Requirement
39
25
  requirements:
40
26
  - - "~>"
41
27
  - !ruby/object:Gem::Version
42
- version: 0.17.9
28
+ version: 0.18.1
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: azure_mgmt_network
45
31
  requirement: !ruby/object:Gem::Requirement
46
32
  requirements:
47
33
  - - "~>"
48
34
  - !ruby/object:Gem::Version
49
- version: 0.23.4
35
+ version: 0.26.1
50
36
  type: :runtime
51
37
  prerelease: false
52
38
  version_requirements: !ruby/object:Gem::Requirement
53
39
  requirements:
54
40
  - - "~>"
55
41
  - !ruby/object:Gem::Version
56
- version: 0.23.4
42
+ version: 0.26.1
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: azure_mgmt_storage
59
45
  requirement: !ruby/object:Gem::Requirement
60
46
  requirements:
61
47
  - - "~>"
62
48
  - !ruby/object:Gem::Version
63
- version: 0.21.1
49
+ version: 0.23.0
64
50
  type: :runtime
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
54
  - - "~>"
69
55
  - !ruby/object:Gem::Version
70
- version: 0.21.1
56
+ version: 0.23.0
71
57
  - !ruby/object:Gem::Dependency
72
58
  name: azure_mgmt_compute
73
59
  requirement: !ruby/object:Gem::Requirement
74
60
  requirements:
75
61
  - - "~>"
76
62
  - !ruby/object:Gem::Version
77
- version: 0.19.3
63
+ version: 0.22.0
78
64
  type: :runtime
79
65
  prerelease: false
80
66
  version_requirements: !ruby/object:Gem::Requirement
81
67
  requirements:
82
68
  - - "~>"
83
69
  - !ruby/object:Gem::Version
84
- version: 0.19.3
70
+ version: 0.22.0
85
71
  - !ruby/object:Gem::Dependency
86
72
  name: azure_mgmt_subscriptions
87
73
  requirement: !ruby/object:Gem::Requirement
88
74
  requirements:
89
75
  - - "~>"
90
76
  - !ruby/object:Gem::Version
91
- version: 0.18.4
77
+ version: 0.18.5
92
78
  type: :runtime
93
79
  prerelease: false
94
80
  version_requirements: !ruby/object:Gem::Requirement
95
81
  requirements:
96
82
  - - "~>"
97
83
  - !ruby/object:Gem::Version
98
- version: 0.18.4
84
+ version: 0.18.5
99
85
  - !ruby/object:Gem::Dependency
100
86
  name: rubocop
101
87
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +201,7 @@ homepage: https://github.com/theforeman/foreman_azure_rm
215
201
  licenses:
216
202
  - GPL-3.0
217
203
  metadata: {}
218
- post_install_message:
204
+ post_install_message:
219
205
  rdoc_options: []
220
206
  require_paths:
221
207
  - lib
@@ -231,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
217
  version: '0'
232
218
  requirements: []
233
219
  rubygems_version: 3.1.4
234
- signing_key:
220
+ signing_key:
235
221
  specification_version: 4
236
222
  summary: Azure Resource Manager as a compute resource for The Foreman
237
223
  test_files: []