From 14c218bb2f8a9f345cd99bda4bc3060c46561c60 Mon Sep 17 00:00:00 2001 From: MyronFanQiu <49134743+MyronFanQiu@users.noreply.github.com> Date: Tue, 7 May 2019 09:26:02 +0800 Subject: [PATCH] Check existence before calling get method (#56105) --- lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index 2c931cd5c96..f12f3fbeb09 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -306,6 +306,7 @@ options: description: - Accept terms for marketplace images that require it - Only Azure service admin/account admin users can purchase images from the marketplace + - C(plan) must be set when C(accept_terms) is true type: bool default: false version_added: "2.7" @@ -1282,7 +1283,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase): # Before creating VM accept terms of plan if `accept_terms` is True if self.accept_terms is True: - if not all([self.plan.get('name'), self.plan.get('product'), self.plan.get('publisher')]): + if not self.plan or not all([self.plan.get('name'), self.plan.get('product'), self.plan.get('publisher')]): self.fail("parameter error: plan must be specified and include name, product, and publisher") try: plan_name = self.plan.get('name')