diff --git a/plugins/doc_fragments/azure.py b/plugins/doc_fragments/azure.py index c990a0564..5acdde2e5 100644 --- a/plugins/doc_fragments/azure.py +++ b/plugins/doc_fragments/azure.py @@ -4,6 +4,9 @@ # Copyright: (c) 2016 Chris Houseknecht, # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function +__metaclass__ = type + class ModuleDocFragment(object): diff --git a/plugins/doc_fragments/azure_tags.py b/plugins/doc_fragments/azure_tags.py index ea4268c8c..5b971e876 100644 --- a/plugins/doc_fragments/azure_tags.py +++ b/plugins/doc_fragments/azure_tags.py @@ -4,6 +4,9 @@ # Copyright: (c) 2016, Chris Houseknecht, # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function +__metaclass__ = type + class ModuleDocFragment(object): diff --git a/plugins/modules/azure_rm_storageaccount.py b/plugins/modules/azure_rm_storageaccount.py index 1ee956504..1ad241145 100644 --- a/plugins/modules/azure_rm_storageaccount.py +++ b/plugins/modules/azure_rm_storageaccount.py @@ -112,7 +112,7 @@ description: - When I(default_action=Deny) this controls which Azure components can still reach the Storage Account. - The list is comma separated. - - It can be any combination of the following: AzureServices, Logging, Metrics. + - It can be any combination of the example C(AzureServices), C(Logging), C(Metrics). - If no Azure components are allowed, explicitly set I(bypass=""). default: AzureServices suboptions: @@ -207,7 +207,7 @@ tags: testing: testing - - name: configure firewall and virtual networks + - name: configure firewall and virtual networks azure_rm_storageaccount: resource_group: myResourceGroup name: clh0002 @@ -305,7 +305,8 @@ "virtual_network_rules": [ { "action": "Allow", - "id": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet" + "id": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/ \ + providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet" } ], "ip_rules": [ @@ -631,7 +632,7 @@ def update_network_rule_set(self): self.fail("Failed to update account type: {0}".format(str(exc))) def sort_list_of_dicts(self, rule_set, dict_key): - return sorted(rule_set, key = lambda i: i[dict_key]) + return sorted(rule_set, key=lambda i: i[dict_key]) def update_account(self): self.log('Update storage account {0}'.format(self.name)) @@ -642,26 +643,29 @@ def update_account(self): self.update_network_rule_set() if self.network_acls.get('default_action', 'Allow') == 'Deny': - if sorted(self.network_acls['bypass'].replace(' ','').split(',')) != sorted(self.account_dict['network_acls']['bypass'].replace(' ','').split(',')): + if sorted(self.network_acls['bypass'].replace(" ',' ").split(',')) != \ + sorted(self.account_dict['network_acls']['bypass'].replace(" ',' ").split(',')): self.results['changed'] = True self.account_dict['network_acls']['bypass'] = self.network_acls['bypass'] self.update_network_rule_set() - if self.network_acls.get('virtual_network_rules', None) != None and self.account_dict['network_acls']['virtual_network_rules'] != []: - if self.sort_list_of_dicts(self.network_acls['virtual_network_rules'], 'id') != self.sort_list_of_dicts(self.account_dict['network_acls']['virtual_network_rules'], 'id'): + if self.network_acls.get('virtual_network_rules', None) is not None and self.account_dict['network_acls']['virtual_network_rules'] != []: + if self.sort_list_of_dicts(self.network_acls['virtual_network_rules'], 'id') != \ + self.sort_list_of_dicts(self.account_dict['network_acls']['virtual_network_rules'], 'id'): self.results['changed'] = True self.account_dict['network_acls']['virtual_network_rules'] = self.network_acls['virtual_network_rules'] self.update_network_rule_set() - if self.network_acls.get('virtual_network_rules', None) != None and self.account_dict['network_acls']['virtual_network_rules'] == []: + if self.network_acls.get('virtual_network_rules', None) is not None and self.account_dict['network_acls']['virtual_network_rules'] == []: self.results['changed'] = True self.update_network_rule_set() - if self.network_acls.get('ip_rules', None) != None and self.account_dict['network_acls']['ip_rules'] != []: - if self.sort_list_of_dicts(self.network_acls['ip_rules'], 'value') != self.sort_list_of_dicts(self.account_dict['network_acls']['ip_rules'], 'value'): + if self.network_acls.get('ip_rules', None) is not None and self.account_dict['network_acls']['ip_rules'] != []: + if self.sort_list_of_dicts(self.network_acls['ip_rules'], 'value') != \ + self.sort_list_of_dicts(self.account_dict['network_acls']['ip_rules'], 'value'): self.results['changed'] = True self.account_dict['network_acls']['ip_rules'] = self.network_acls['ip_rules'] self.update_network_rule_set() - if self.network_acls.get('ip_rules', None) != None and self.account_dict['network_acls']['ip_rules'] == []: + if self.network_acls.get('ip_rules', None) is not None and self.account_dict['network_acls']['ip_rules'] == []: self.results['changed'] = True self.update_network_rule_set() @@ -852,6 +856,7 @@ def set_network_acls(self): except Exception as exc: self.fail("Failed to update account type: {0}".format(str(exc))) + def main(): AzureRMStorageAccount() diff --git a/plugins/modules/azure_rm_storageaccount_info.py b/plugins/modules/azure_rm_storageaccount_info.py index 4267abf81..f85f6a954 100644 --- a/plugins/modules/azure_rm_storageaccount_info.py +++ b/plugins/modules/azure_rm_storageaccount_info.py @@ -184,7 +184,8 @@ "virtual_network_rules": [ { "action": "Allow", - "id": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet" + "id": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroup/ \ + providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet" } ], "ip_rules": [ diff --git a/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml b/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml index 735c6df1b..f606ee53e 100644 --- a/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml +++ b/tests/integration/targets/azure_rm_storageaccount/tasks/main.yml @@ -41,7 +41,7 @@ tags: test: test galaxy: galaxy - http_only: yes + https_only: yes network_acls: bypass: AzureServices default_action: Deny @@ -84,7 +84,7 @@ tags: test: test galaxy: galaxy - http_only: yes + https_only: yes network_acls: bypass: AzureServices default_action: Deny