I have the Terraform script/template to provision a VM in Azure,it accepts the input and provision the VM along with the required resources.
I have created the Azure Storage Account and uploaded the script into the blob container.
We are using Jenkins as our CI/CD tool.
Now, I want to build the pipeline or automation using Jenkins which would take the necessary input and run Terraform script to provision the VM.
How do I build the Jenkins pipeline so that I can run the pipeline / automation multiple times and provision the individual VMs?
Any sample Jenkins pipeline would be really helpful.
if your sole purpose is to run the terraform through jenkins then there are many pipeline scripts available , I have pasted one below the link, which will help to build a jenkins pipeline and has guided documentation as well.
https://github.com/manheim/terraform-pipeline
There is a dedicated architecture reference and sample available on the Azure documentation on Immutable Infrastructure CI/CD using Jenkins and Terraform on Azure Virtual Architecture
And here is the template as well
New-AzResourceGroup -Name <resource-group-name> -Location <resource-group-location> #use this command when you need to create a new resource group for your deployment
New-AzResourceGroupDeployment -ResourceGroupName <resource-group-name> -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/application-workloads/jenkins/jenkins-cicd-vmss/azuredeploy.json
Related
I am getting started with Ansible + Azure. While I see Ansible modules for quite a few tasks, I am kinda stuck at the basic task of obtaining the subscription_id and subscription_name
To work around this I am using the az account show --subscription <subscription_name> command instead. I pull the output of that command into ansible and extract subscription_id and subscription_name
Is there a way to perform this task via an Ansible module instead ?
Looks it is not possible to perform this task via the Ansible module, all the Ansible module on Azure here, there is no one can do this.
Is there a way to figure out if resource was deployed manually (via Azure portal) or via arm template?
I would say that your best option, although it won't guarantee 100% accuracy, is to look at the deployment name. If you look at a Resource Group from the Azure Portal and navigate to Deployments, you'll see a list of all deployments to that RG.
From my observations:
if the deployment name is in the format Resource.Provider-Timestamp (Microsoft.RouteTable-20200824154745) it was done via the Portal
if the deployment name is somewhat friendly or irregular (VirtualWanDeployment) it was a manual ARM template deployment (PowerShell in my case)
if the deployment name is in the format resource-date-time-xxxx (applicationGateway-20200821-135645-bf71) it was an Azure DevOps pipeline
I have a VM running in Azure which has ansible installed.
Is it possible to run ansible to find the tags associated with this VM (which ansible is running on)?
Furthermore Can it be done as part of a "lookup" expression?
E.g hosts: {{lookup(tag_name) }}
Elaborating Hassan Raza's suggestion:
This is Azure REST API reference and this is Tags REST API section and this REST API helps to get the entire set of tags on a resource. So you may just use this REST API to accomplish your requirement.
On the other hand, you can also leverage Az PowerShell to get the entire set of tags on a resource and this is that Az PowerShell cmdlet which is part of Az.Resources module so you need it this module imported as a pre-requisite. Again, you may just use this cmdlet from your local machine or from wherever you want to.
On the another hand, you may also create something called Azure Automation Runbook (in general words its a script that's created in Azure cloud under an Azure Automation account). So you may create an Azure Automation account and then a simple runbook to get the entire set of tags on a resource.
The solution we went with was to use the Ansible azure_rm_virtualmachine_info_module :
https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_virtualmachine_info_module.html
This returns azure tag info.
My dev ADF has pipeline triggers that are Active and set to run every hour. Using devops repos & CI/CD, I deployed these triggers from our dev to test ADF environments. The pipeline triggers were successfully created in my test environment, but they are inactive. Why are these not coming over in a 'Started' status. The ARM template shows the trigger as Started
These need to be turned on automatically after deployment as I don't have rights to turn these on manually. I can't tell if this is a bug or if I'm missing something to turn these on within the deployment. Please see screenshots:
We have the same issue and are using a powershell step in Azure Devops to enable the trigger:
Start-AzureRmDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryResourceName -Name $PipelineTriggerName -Force
I'm trying to onboard a VM to Azure Automation DSC. Can we add a VM from a different subscription as a DSC node ?
You won't be able to use the Register-AzureRMAutomationDSC to setup VMs cross subscription.
Following the instructions located here there are steps to run the Get-AzureRMAutomationRegistrationInfo cmdlet to get the registration key required (of the target Azure Automation account) and then steps to configure the DSC Extension on the target VM. Please note the instructions are for ASM VMs, but you can use Set-AzureRMVMExtension for ASR VMs.
Alternatively, for a more manual approach, follow the instructions here to obtain the registration url and the registration key, and then configure the Local DSC manager using the Set-DscLocalConfigurationManager cmdlet.