diff --git a/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py b/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py index 8eb43542731..8b2ebebd856 100755 --- a/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py @@ -610,6 +610,7 @@ class AzureRMLoadBalancer(AzureRMModuleBase): self.natpool_frontend_port_end = None self.natpool_backend_port = None self.natpool_protocol = None + self.tags = None self.results = dict(changed=False, state=dict()) @@ -620,7 +621,7 @@ class AzureRMLoadBalancer(AzureRMModuleBase): def exec_module(self, **kwargs): """Main module execution method""" - for key in self.module_args.keys(): + for key in list(self.module_args.keys()) + ['tags']: setattr(self, key, kwargs[key]) changed = False @@ -685,6 +686,13 @@ class AzureRMLoadBalancer(AzureRMModuleBase): changed = True self.results['state'] = load_balancer_to_dict(load_balancer) + if 'tags' in self.results['state']: + update_tags, self.results['state']['tags'] = self.update_tags(self.results['state']['tags']) + if update_tags: + changed = True + else: + if self.tags: + changed = True self.results['changed'] = changed if self.state == 'present' and changed: @@ -761,6 +769,7 @@ class AzureRMLoadBalancer(AzureRMModuleBase): param = self.network_models.LoadBalancer( sku=self.network_models.LoadBalancerSku(self.sku) if self.sku else None, location=self.location, + tags=self.tags, frontend_ip_configurations=frontend_ip_configurations_param, backend_address_pools=backend_address_pools_param, probes=probes_param,