Fail to add chef extensions for VM in resource manager template - templates

I am trying to create a windows VM with chef client by ARM (Azure resource manager) template. I find an example template in github:
https://github.com/Azure/azure-quickstart-templates/tree/master/chef-extension-windows-vm
{
"name": "[concat(variables('vmName'),'/',variables('chefClientName'))]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2015-05-01-preview",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Chef.Bootstrap.WindowsAzure",
"type": "ChefClient",
"typeHandlerVersion": "1201.12",
"settings": {
"client_rb": "[parameters('client_rb')]",
"runlist": "[parameters('runlist')]"
},
"protectedSettings": {
"validation_key": "[parameters('validation_key')]"
}
}
}
I deploy this template in powershell, storageAcount/vNet/IP/NIC/VM are created successfully. But the chef extension create fail with the following error:
New-AzureResourceGroupDeployment : 3:44:51 PM - Resource Microsoft.Compute/virtualMachines/extensions
'myVM/chefExtension' failed with message 'Extension with publisher 'Chef.Bootstrap.WindowsAzure', type 'ChefClient',
and type handler version '1201.12' could not be found in the extension repository.'
At line:1 char:1
+ New-AzureResourceGroupDeployment -Name $deployName -ResourceGroupName $RGName -T ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand
How can I create a VM with chef by ARM template ?
Thanks.

The failure is cause by wrong "typeHandlerVersion", "1201.12" is no longer available. "1207.12" works fine. To get the available extension information, use the following powershell command:
Get-AzureVMAvailableExtension | select ExtensionName,Publisher,Version,PublishedDate

Related

Import Azure Data explorer Arm Template fails

i exported my arm template from develop environment related to my Azure Data Explorer.
Now i'am trying to import it in test environment but the process fails:
New-AzResourceGroupDeployment : 12:18:24 - The deployment 'template' failed with error(s). Showing 3 out of 10 error(s). Status Message: [BadRequest] Validation Errors found: mapping does not exist (Code:EventHubValidationErrorFound) Status Message: [BadRequest] Validation Errors found: mapping does not exist (Code:EventHubValidationErrorFound) Status Message: [BadRequest] Validation Errors found: mapping does not exist (Code:EventHubValidationErrorFound) CorrelationId: b27cdf8e-c583-4dee-8dbc-2b0e4876b8ca
I have different Data Connections from my Azure DATA Explorer to an Event HUB:
`
{
"type": "Microsoft.Kusto/Clusters/Databases/EventHubConnections",
"apiVersion": "2018-09-07-preview",
"name": "[concat(parameters('Clusters_xyzazne_name'), '/asd/asd-fondi')]",
"location": "North Europe",
"dependsOn": [
"[resourceId('Microsoft.Kusto/Clusters/Databases', parameters('Clusters__name'), 'DNA_R_NRT')]",
"[resourceId('Microsoft.Kusto/Clusters', parameters('Clusters__name'))]"
],
"kind": "EventHub",
"properties": {
"eventHubResourceId": "[concat(parameters('namespaces_ehub_externalid'), '/eventhubs/fondi')]",
"consumerGroup": "fondi_consumer",
"tableName": "fondi",
"mappingRuleName": "fondi_mapping",
"dataFormat": "multijson"
}
}
`
I'm trying to import an Azure Data Explorer Arm Template to another environment but fails

cloudformation windows userdata cfn-init.exe end of line issues

Working through adding some cfn-init to request data from an S3 bucket.
I believe I've got a syntax problem with the cfn-init.exe call from powershell but cannot seem to find where. This structure was taken from the Bootstrapping AWS CloudFormation Windows Stacks AWS Example. I've also tried adapting from the bash structure from AWS cfn-init documentation with no success.
"UserData": {"Fn::Base64": {"Fn::Join": ["\n", [
"<powershell>",
...
"cfn-init.exe -v -s", { "Ref" : "AWS::StackName" },
" -r EC2Instance",
"</powershell>"
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config": {
"files" : {
"C:\\chef\\validator.pem" : {
"source" : "https://s3.amazonaws.com/dtcfstorage/validator.pem",
"authentication" : "s3creds"
}
}
},
"AWS::CloudFormation::Authentication" : {
"s3creds" : {
"type" : "S3",
"roleName" : "awss3chefkeyaccess"
}
}
}
}
The cfn-init.exe is being run but errors out as the arguments are passing to new lines:
2018/05/21 15:35:08Z: Message: The errors from user scripts: Usage: cfn-init.exe [options]
or: cfn-init.exe [options]
or: cat | cfn-init.exe [options] -
cfn-init.exe: error: -s option requires an argument
cloudinittest : The term 'cloudinittest' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Windows\TEMP\UserScript.ps1:30 char:1
+ cloudinittest
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (cloudinittest:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-r : The term '-r' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Windows\TEMP\UserScript.ps1:31 char:2
+ -r EC2Instance
+ ~~
+ CategoryInfo : ObjectNotFound: (-r:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
It's because you have joined using \n at the top. Every arg to the join function will separate by a newline event if you type some on the same line!
Therefore, your command cfn-init has been interpreted as:
cfn-init.exe -v -s
stack-name
-r EC2Instance
...
Since the line is broken, the command doesn't get run properly.
As such, you can join by a space character. You can try replacing the above by this:
{"Fn::Join": [" ", ["cfn-init.exe -v -s", {"Ref":"AWS::StackName"},
"-r EC2Instance"]}

Is there any easy way / API to find out the number of pipelines on a gocd server?

Sorry for the brief question, but just wondering if there's an API to find out the number of pipelines on a GoCD server.
The Pipeline Groups API will give you what you need after some JSON parsing.
$ curl 'https://ci.example.com/go/api/config/pipeline_groups' \
-u 'username:password'
Returns:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
[
{
"pipelines": [
{
"stages": [
{
"name": "up42_stage"
}
],
"name": "up42",
"materials": [
{
"description": "URL: https://github.com/gocd/gocd, Branch: master",
"fingerprint": "2d05446cd52a998fe3afd840fc2c46b7c7e421051f0209c7f619c95bedc28b88",
"type": "Git"
}
],
"label": "${COUNT}"
}
],
"name": "first"
}
]
You can grab the config.xml file and parse it. from the config repo or via http.
As an alternative, you can just get the cctray file from your server at http://yourgoserver/go/cctray.xml and parse it.
It contains information about all the pipelines (including its stages)
I would recommend using yagocd:
from yagocd import Yagocd
go = Yagocd(server='https://build.gocd.io')
# login as guest
go._session.get('https://build.gocd.io/go/plugin/interact/gocd.guest.user.auth.plugin/index')
print(len(list(go.pipelines)))
Yes, of course. You can get the desired output in different ways. The first easy way to get the number of pipelines and other statistical information from the GoCD support URL (https://example.com/go/api/support) which requires admin privilege.
If the user does not have the admin privilege, we need to go with the GoCD pipeline_groups API. The below command should give you the exact result with jq(JSON processor)
$ curl 'https://example.com/go/api/config/pipeline_groups' -u 'username:password' | jq -r '.[] | .pipelines[].name' | wc -l
NOTE: Still Go Administrator users can get the actual number of pipelines.

Apache Drill: Not able to query the database

I am using UBUNTU 14.04.
I have started to explore about querying HDFS using apache drill, installed it my local system and configured the Storage plugin to point remote HDFS. Below is the configuration setup:
{
"type": "file",
"enabled": true,
"connection": "hdfs://devlpmnt.mycrop.kom:8020",
"workspaces": {
"root": {
"location": "/",
"writable": false,
"defaultInputFormat": null
}
},
"formats": {
"json": {
"type": "json"
}
}
}
After creating a json file "rest.json", I passed the query:
select * from hdfs.`/tmp/rest.json` limit 1
I am getting following error:
org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR: From line 1, column 15 to line 1, column 18: Table 'hdfs./tmp/rest.json' not found
I would appreciate if someone tries to help me figure out what is wrong.
Thanks in advance!!

AWS Cloudformation issue installing custom binaries

I'm trying to install a custom compiled package that I have in S3 as a zip file. I added this on my Cloudformation template:
"sources" : {
"/opt" : "https://s3.amazonaws.com/mybucket/installers/myapp-3.2.1.zip"
},
It downloads and unzip it on /opt without issues, but all the "executables" files don't have the "x" permission. I mean "-rw-r--r-- 1 root root 220378 Dec 4 18:23 myapp".
If I download the zip and unzip it in any directory, the permissions are Ok.
I already read the Cloudformation documentation and there is no clue there.
Someone can help me figuring this out? Thanks in advance.
Maybe you can combine a "configSets" (to guarantee the execution order) and a "command" element to write something like :
"AWS::CloudFormation::Init" : {
"configSets" : {
"default" : [ "download", "fixPermissions" ]
},
"download" : {
"sources" : {
"/opt" : "https://s3.amazonaws.com/mybucket/installers/myapp-3.2.1.zip"
},
},
"fixPermissions" : {
"commands" : {
"fixMyAppPermissions" : {
"command" : "chmod +x /opt/myapp-3.2.1/myapp"
}
}
}
}
Source :
https://s3.amazonaws.com/cloudformation-examples/BoostrappingApplicationsWithAWSCloudFormation.pdf
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html