Skip to content

Commit dc3e25b

Browse files
author
aliasgar16
committed
Added Secret and SecretFile options in ChefExtension for ARM commands.
Signed-off-by: aliasgar16 <[email protected]>
1 parent 0e23f5e commit dc3e25b

File tree

4 files changed

+108
-1
lines changed

4 files changed

+108
-1
lines changed

src/ResourceManager/Compute/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
- FullBackupWindowInHours : Specifies the window (in hours) when Sql Server Full Backup should occur.
3030
- LogBackupFrequencyInMinutes : Specifies the frequency of Sql Server Log Backup.
3131
* New-AzureVMSqlServer* cmdlets are renamed to New-AzureRmVMSqlServer* now. Old ones will continue to work however.
32+
* Updated Set-AzureRmVMChefExtension cmdlet to add following new options :
33+
- Daemon: Configures the chef-client service for unattended execution. e.g. -Daemon 'none' or e.g. -Daemon 'service'."
34+
- Secret: The encryption key used to encrypt and decrypt the data bag item values.
35+
- SecretFile: The path to the file that contains the encryption key used to encrypt and decrypt the data bag item values.
3236

3337
## Version 2.4.0
3438
* Add Remove-AzureRmVMSecret cmdlet.

src/ResourceManager/Compute/Commands.Compute/Extension/Chef/SetAzureVMChefExtension.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineExtensionBaseCmdlet
4949
private string ChefServiceIntervalTemplate = "chef_service_interval";
5050
private string RunListTemplate = "runlist";
5151
private string DaemonTemplate = "daemon";
52+
private string SecretTemplate = "encrypted_data_bag_secret";
5253

5354
[Parameter(
5455
Mandatory = true,
@@ -124,6 +125,18 @@ public string TypeHandlerVersion
124125
[ValidateNotNullOrEmpty]
125126
public string Daemon { get; set; }
126127

128+
[Parameter(
129+
ValueFromPipelineByPropertyName = true,
130+
HelpMessage = "The encryption key used to encrypt and decrypt the data bag item values.")]
131+
[ValidateNotNullOrEmpty]
132+
public string Secret { get; set; }
133+
134+
[Parameter(
135+
ValueFromPipelineByPropertyName = true,
136+
HelpMessage = "The path to the file that contains the encryption key used to encrypt and decrypt the data bag item values.")]
137+
[ValidateNotNullOrEmpty]
138+
public string SecretFile { get; set; }
139+
127140
[Parameter(
128141
ValueFromPipelineByPropertyName = true,
129142
HelpMessage = "The Chef Server Node Runlist.")]
@@ -330,6 +343,12 @@ private Hashtable PrivateConfiguration
330343
if (this.privateConfiguration == null)
331344
{
332345
var hashTable = new Hashtable();
346+
347+
if (!string.IsNullOrEmpty(this.SecretFile))
348+
hashTable.Add(SecretTemplate, File.ReadAllText(this.SecretFile).TrimEnd('\r', '\n'));
349+
else if (!string.IsNullOrEmpty(this.Secret))
350+
hashTable.Add(SecretTemplate, this.Secret);
351+
333352
hashTable.Add(PrivateConfigurationTemplate, File.ReadAllText(this.ValidationPem).TrimEnd('\r', '\n'));
334353
this.privateConfiguration = hashTable;
335354
}
@@ -428,6 +447,12 @@ private void ValidateParameters()
428447
throw new ArgumentException(
429448
"Invalid use of -Daemon option.");
430449
}
450+
451+
if (!string.IsNullOrEmpty(this.SecretFile) && !File.Exists(this.SecretFile))
452+
{
453+
throw new FileNotFoundException(
454+
"File specified in -SecretFile option does not exist.");
455+
}
431456
}
432457

433458
public override void ExecuteCmdlet()

src/ResourceManager/Compute/Commands.Compute/Microsoft.Azure.Commands.Compute.dll-Help.xml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13015,6 +13015,24 @@ PS C:\&gt; Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName "Reso
1301513015
<maml:uri /></dev:type>
1301613016
<dev:defaultValue>None</dev:defaultValue>
1301713017
</command:parameter>
13018+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>Secret</maml:name>
13019+
<maml:Description><maml:para>The encryption key used to encrypt and decrypt the data bag item values.
13020+
</maml:para>
13021+
</maml:Description>
13022+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13023+
<dev:type><maml:name>String</maml:name>
13024+
<maml:uri /></dev:type>
13025+
<dev:defaultValue>None</dev:defaultValue>
13026+
</command:parameter>
13027+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>SecretFile</maml:name>
13028+
<maml:Description><maml:para>The path to the file that contains the encryption key used to encrypt and decrypt the data bag item values.
13029+
</maml:para>
13030+
</maml:Description>
13031+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13032+
<dev:type><maml:name>String</maml:name>
13033+
<maml:uri /></dev:type>
13034+
<dev:defaultValue>None</dev:defaultValue>
13035+
</command:parameter>
1301813036
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>ClientRb</maml:name>
1301913037
<maml:Description><maml:para>Specifies the full path of the Chef client.rb.
1302013038
</maml:para>
@@ -13185,6 +13203,36 @@ PS C:\&gt; Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName "Reso
1318513203
<maml:uri /></dev:type>
1318613204
<dev:defaultValue>None</dev:defaultValue>
1318713205
</command:parameter>
13206+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>Daemon</maml:name>
13207+
<maml:Description><maml:para>Configures the chef-client service for unattended execution. The node platform should be Windows.
13208+
Options: 'none' or 'service'
13209+
none - Currently prevents the chef-client service from being configured as a service.
13210+
service - Configures the chef-client to run automatically in the background as a service.
13211+
</maml:para>
13212+
</maml:Description>
13213+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13214+
<dev:type><maml:name>String</maml:name>
13215+
<maml:uri /></dev:type>
13216+
<dev:defaultValue>None</dev:defaultValue>
13217+
</command:parameter>
13218+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>Secret</maml:name>
13219+
<maml:Description><maml:para>The encryption key used to encrypt and decrypt the data bag item values.
13220+
</maml:para>
13221+
</maml:Description>
13222+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13223+
<dev:type><maml:name>String</maml:name>
13224+
<maml:uri /></dev:type>
13225+
<dev:defaultValue>None</dev:defaultValue>
13226+
</command:parameter>
13227+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>SecretFile</maml:name>
13228+
<maml:Description><maml:para>The path to the file that contains the encryption key used to encrypt and decrypt the data bag item values.
13229+
</maml:para>
13230+
</maml:Description>
13231+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13232+
<dev:type><maml:name>String</maml:name>
13233+
<maml:uri /></dev:type>
13234+
<dev:defaultValue>None</dev:defaultValue>
13235+
</command:parameter>
1318813236
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>ClientRb</maml:name>
1318913237
<maml:Description><maml:para>Specifies the full path of the Chef client.rb.
1319013238
</maml:para>
@@ -13310,6 +13358,36 @@ PS C:\&gt; Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName "Reso
1331013358
<maml:uri /></dev:type>
1331113359
<dev:defaultValue>None</dev:defaultValue>
1331213360
</command:parameter>
13361+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>Daemon</maml:name>
13362+
<maml:Description><maml:para>Configures the chef-client service for unattended execution. The node platform should be Windows.
13363+
Options: 'none' or 'service'
13364+
none - Currently prevents the chef-client service from being configured as a service.
13365+
service - Configures the chef-client to run automatically in the background as a service.
13366+
</maml:para>
13367+
</maml:Description>
13368+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13369+
<dev:type><maml:name>String</maml:name>
13370+
<maml:uri /></dev:type>
13371+
<dev:defaultValue>None</dev:defaultValue>
13372+
</command:parameter>
13373+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>Secret</maml:name>
13374+
<maml:Description><maml:para>The encryption key used to encrypt and decrypt the data bag item values.
13375+
</maml:para>
13376+
</maml:Description>
13377+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13378+
<dev:type><maml:name>String</maml:name>
13379+
<maml:uri /></dev:type>
13380+
<dev:defaultValue>None</dev:defaultValue>
13381+
</command:parameter>
13382+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>SecretFile</maml:name>
13383+
<maml:Description><maml:para>The path to the file that contains the encryption key used to encrypt and decrypt the data bag item values.
13384+
</maml:para>
13385+
</maml:Description>
13386+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
13387+
<dev:type><maml:name>String</maml:name>
13388+
<maml:uri /></dev:type>
13389+
<dev:defaultValue>None</dev:defaultValue>
13390+
</command:parameter>
1331313391
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none"><maml:name>ClientRb</maml:name>
1331413392
<maml:Description><maml:para>Specifies the full path of the Chef client.rb.
1331513393
</maml:para>

src/ServiceManagement/Services/Commands.Utilities/ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- FullBackupWindowInHours : Specifies the window (in hours) when Sql Server Full Backup should occur.
2929
- LogBackupFrequencyInMinutes : Specifies the frequency of Sql Server Log Backup.
3030
* Updated Set-AzureVMChefExtension cmdlet to add following new options :
31-
- Daemon: Configures the chef-client service for unattended execution. e.g. -Daemon 'auto' or e.g. -Daemon 'service'."
31+
- Daemon: Configures the chef-client service for unattended execution. e.g. -Daemon 'none' or e.g. -Daemon 'service'."
3232
- Secret: The encryption key used to encrypt and decrypt the data bag item values.
3333
- SecretFile: The path to the file that contains the encryption key used to encrypt and decrypt the data bag item values.
3434

0 commit comments

Comments
 (0)