Ability to create Azure automation account via Ansible

Hi Guys,

Are we not able to create an Azure automation account with Ansible? Seems a simple request but I am not able to figure it out.

Would appreciate your guidance.

Thank you very much.

Kind regards
Ameya Agashe

P. S: Kindly ignore if this sounds too simple question, I am new to Ansible world.

Apparently, there is no module for creation of azure automation account?

Hi is this message gone in spam somewhere??

Ameya

No, I have no idea what azure is. So, can’t offer any help. You have not provided any details. Possibly describe what the process is for creating an azure account without ansible and what problems you are having with using ansible. Give us the steps you have attempted so far.

Hi Brad,

Appreciate your prompt response.Azure is a public cloud offering from Microsoft. WIthout Ansible, I would create the account with “Azure PowerShell” with the below command.:

New-AzureRmAutomationAccount -ResourceGroupName "${resource_grp_name_fred_nxt_old_prod}"
-Name “${azure_automation_account_name}” `
-Location “${automation_account_location}”

What I have done so far is, I am being able to provision a base Windows 2016 Server in Azure, I want to now, automate the manual configuration task, first thing is to provision an automation account. The below snippet is of my yaml file which I run in Azure cloud shell and it provisions the environment.

  • name: Create Azure VM
    hosts: localhost
    connection: local
    tasks:
  • name: Create resource group
    azure_rm_resourcegroup:
    name: myResourceGroup
    location: eastus
  • name: Create virtual network
    azure_rm_virtualnetwork:
    resource_group: myResourceGroup
    name: myVnet
    address_prefixes: “10.0.0.0/16
  • name: Add subnet
    azure_rm_subnet:
    resource_group: myResourceGroup
    name: mySubnet
    address_prefix: “10.0.1.0/24
    virtual_network: myVnet
  • name: Create public IP address
    azure_rm_publicipaddress:
    resource_group: myResourceGroup
    allocation_method: Static
    name: myPublicIP
    register: output_ip_address
  • name: Dump public IP for VM which will be created
    debug:
    msg: “The public IP is {{ output_ip_address.state.ip_address }}.”
  • name: Create Network Security Group that allows RDP
    azure_rm_securitygroup:
    resource_group: myResourceGroup
    name: myNetworkSecurityGroup
    rules:
  • name: RDP
    protocol: Tcp
    destination_port_range: 3389
    access: Allow
    priority: 1002
    direction: Inbound
  • name: Create virtual network inteface card
    azure_rm_networkinterface:
    resource_group: myResourceGroup
    name: myNIC
    virtual_network: myVnet
    subnet: mySubnet
    public_ip_name: myPublicIP
    security_group: myNetworkSecurityGroup
  • name: Create VM
    azure_rm_virtualmachine:
    resource_group: myResourceGroup
    name: myVM
    vm_size: Standard_DS1_v2
    admin_username: svc_admin
    admin_password: Hash#Dollar$135
    os_type: Windows
    network_interfaces: myNIC
    image:
    offer: WindowsServer
    publisher: MicrosoftWindowsServer
    sku: ‘2016-Datacenter’
    version: latest

The main game, as I see is using Azure ansible modules, I couldn’t locate the equivalent to create an automation account.

Kindly assist

Thanks
Ameya Agashe

OK. Haven’t touched Windows Server for a couple of years. :slight_smile:
I searched the azure modules in ansible and like you, did not see anything directly related. My suggestion: since you already have a poweshell command to create the account, use the win_command module to run the powershell command where needed. That will probably be your fastest method to get your task accomplished.