'Can I create Azure File Share using Ansible?

Is it possible to create an azure storage file share using Ansible ?
There is an Ansible module to create Azure Storage Account, so I am good there.
I dont see anything for File Share.
There is something called azure_rm_resource but I have not been able to get it to work with it.
Any input will be appreciated.



Solution 1:[1]

Custom script solution

If you need custom implementation, I would suggest to use Azure CLI for developing a custom script, and then run it in your Ansible playbook.

E.g. reference fileshare.ps1 script with content of az storage share create --account-name MyAccount --name MyFileShare ...etc.

Documentation: https://docs.microsoft.com/en-us/cli/azure/storage/share?view=azure-cli-latest#az_storage_share_create

Simple solution with Ansible module (Edit: not sufficient at the moment)

Edit: this solution only creates the storage account as of now, so it is not sufficient in most scenarios.

There is an Ansible module for this, already implemented, called azure_rm_storageaccount in the azure namespace. See the link in the bottom.

Make sure to use the kind property and specify FileStorage value. Example:

- name: Create an account with kind of FileStorage
  azure_rm_storageaccount:
    resource_group: souser_resource_group
    name: souser_file_storage
    type: Premium_LRS
    kind: FileStorage
    tags:
      testing: testing

Documentation: https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_storageaccount_module.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1