Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add large_file_shares_state to azure_rm_storageaccount #1210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion plugins/modules/azure_rm_storageaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@
description:
- The absolute path of the custom 404 page.
type: str
large_file_shares_state:
description:
- Allow large file shares if sets to Enabled.
type: str
choices:
- Enabled
- Disabled
encryption:
description:
- The encryption settings on the storage account.
Expand Down Expand Up @@ -578,6 +585,12 @@
returned: always
type: str
sample: "Microsoft.Storage/storageAccounts"
large_file_shares_state:
description:
- Allow large file shares if sets to Enabled.
type: str
returned: always
sample: Enabled
static_website:
description:
- Static website configuration for the storage account.
Expand Down Expand Up @@ -690,6 +703,7 @@ def __init__(self):
blob_cors=dict(type='list', options=cors_rule_spec, elements='dict'),
static_website=dict(type='dict', options=static_website_spec),
is_hns_enabled=dict(type='bool'),
large_file_shares_state=dict(type='str', choices=['Enabled', 'Disabled']),
encryption=dict(
type='dict',
options=dict(
Expand Down Expand Up @@ -745,6 +759,7 @@ def __init__(self):
self.static_website = None
self.encryption = None
self.is_hns_enabled = None
self.large_file_shares_state = None

super(AzureRMStorageAccount, self).__init__(self.module_arg_spec,
supports_check_mode=True)
Expand Down Expand Up @@ -849,6 +864,7 @@ def account_obj_to_dict(self, account_obj, blob_mgmt_props=None, blob_client_pro
allow_blob_public_access=account_obj.allow_blob_public_access,
network_acls=account_obj.network_rule_set,
is_hns_enabled=account_obj.is_hns_enabled if account_obj.is_hns_enabled else False,
large_file_shares_state=account_obj.large_file_shares_state,
static_website=dict(
enabled=False,
index_document=None,
Expand Down Expand Up @@ -1108,6 +1124,21 @@ def update_account(self):
except Exception as exc:
self.fail("Failed to update access tier: {0}".format(str(exc)))

if self.large_file_shares_state is not None:
if self.large_file_shares_state != self.account_dict['large_file_shares_state']:
self.results['changed'] = True
self.account_dict['large_file_shares_state'] = self.large_file_shares_state

if self.results['changed'] and not self.check_mode:
if self.large_file_shares_state == 'Disabled':
parameters = self.storage_models.StorageAccountUpdateParameters(large_file_shares_state=None)
else:
parameters = self.storage_models.StorageAccountUpdateParameters(large_file_shares_state=self.large_file_shares_state)
try:
self.storage_client.storage_accounts.update(self.resource_group, self.name, parameters)
except Exception as exc:
self.fail("Failed to update large_file_shares_state: {0}".format(str(exc)))

update_tags, self.account_dict['tags'] = self.update_tags(self.account_dict['tags'])
if update_tags:
self.results['changed'] = True
Expand Down Expand Up @@ -1177,6 +1208,7 @@ def create_account(self):
allow_blob_public_access=self.allow_blob_public_access,
encryption=self.encryption,
is_hns_enabled=self.is_hns_enabled,
large_file_shares_state=self.large_file_shares_state,
tags=dict()
)
if self.tags:
Expand All @@ -1202,7 +1234,8 @@ def create_account(self):
allow_blob_public_access=self.allow_blob_public_access,
encryption=self.encryption,
is_hns_enabled=self.is_hns_enabled,
access_tier=self.access_tier)
access_tier=self.access_tier,
large_file_shares_state=self.large_file_shares_state)
self.log(str(parameters))
try:
poller = self.storage_client.storage_accounts.begin_create(self.resource_group, self.name, parameters)
Expand Down
7 changes: 7 additions & 0 deletions plugins/modules/azure_rm_storageaccount_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@
returned: always
type: dict
sample: { "tag1": "abc" }
large_file_shares_state:
description:
- Allow large file shares if sets to Enabled.
type: str
returned: always
sample: Enabled
static_website:
description:
- Static website configuration for the storage account.
Expand Down Expand Up @@ -676,6 +682,7 @@ def account_obj_to_dict(self, account_obj):
public_network_access=account_obj.public_network_access,
allow_blob_public_access=account_obj.allow_blob_public_access,
is_hns_enabled=account_obj.is_hns_enabled if account_obj.is_hns_enabled else False,
large_file_shares_state=account_obj.large_file_shares_state,
static_website=dict(
enabled=False,
index_document=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}06"
account_type: Standard_LRS
large_file_shares_state: Enabled
kind: StorageV2
is_hns_enabled: true
register: output
- name: Assert output
assert:
that:
- output.changed
- output.state.large_file_shares_state == 'Enabled'

- name: Gather facts of storage account
azure_rm_storageaccount_info:
Expand All @@ -156,6 +158,7 @@
that:
- "output.storageaccounts | length == 1"
- output.storageaccounts[0].is_hns_enabled == true
- output.storageaccounts[0].large_file_shares_state == 'Enabled'

- name: Create storage account with static website enabled
azure_rm_storageaccount:
Expand Down