azure_rm_deployment failing

Using Ansible to deploy VMs to Azure using the azure_rm_deployment module. The deployment in Azure works but I get the following errors back in Ansible

TASK [Hedberg_deploy_template : Execute Azure Deployment] ***********************************************************************************************************************************************************************************
Thursday 21 June 2018 19:51:16 +0000 (0:00:00.745) 0:00:00.936 *********
fatal: [localhost]: FAILED! => {
“changed”: false,
“rc”: 1
}

MSG:

MODULE FAILURE

MODULE_STDERR:

No handlers could be found for logger “msrestazure.azure_active_directory”
Traceback (most recent call last):
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 664, in
main()
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 660, in main
AzureRMDeploymentManager()
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 434, in init
supports_check_mode=False)
File “/tmp/ansible_JHtP7p/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py”, line 345, in init
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 457, in exec_module
instances=self._get_instances(deployment)
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 609, in _get_instances
for vm, nics in vms_and_nics]
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 653, in _nic_to_public_ips_instance
nic[‘dep’].resource_name) for nic in nics)
File “/tmp/ansible_JHtP7p/ansible_module_azure_rm_deployment.py”, line 653, in
nic[‘dep’].resource_name) for nic in nics)
File “/tmp/ansible_JHtP7p/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py”, line 889, in network_client
File “/tmp/ansible_JHtP7p/ansible_modlib.zip/ansible/module_utils/azure_rm_common.py”, line 843, in get_mgmt_svc_client
File “/usr/lib/python2.7/site-packages/azure/mgmt/network/network_management_client.py”, line 98, in init
profile=profile
File “/usr/lib/python2.7/site-packages/azure/profiles/multiapiclient.py”, line 47, in init
raise ValueError(“Cannot use api-version and profile parameters at the same time”)
ValueError: Cannot use api-version and profile parameters at the same time

The Ansible role that is failing is as follows:

  • name: Create a unique string to be used as a Azure deployment id

shell: echo “date +"%Y%m%d%H%M%S"-$(cat /dev/urandom | tr -cd [:alpha:] | tr ‘[:upper:]’ ‘[:lower:]’ | head -c 8)”

register: deployment_id

  • name: Execute Azure Deployment

azure_rm_deployment:

ad_user: “{{ authprofile[inventory_target].azure_ad_user }}”

password: “{{ authprofile[inventory_target].azure_password }}”

subscription_id: “{{ authprofile[inventory_target].azure_subscription_id }}”

state: present

deployment_mode: incremental

deployment_name: “{{ deployment_id.stdout }}”

location: “{{ location }}”

resource_group_name: “{{ resourcegroupname }}”

template: “{{ lookup(‘file’, ‘{{ template_file_name }}’) }}”

parameters:

“{{ ARMtemplateprofile[ARM_profile] }}”

register: azureout"

My Ansible version is …

ansible --version
ansible 2.5.5
config file = None
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.14 (default, Feb 22 2018, 22:26:54) [GCC 5.3.0]

Given the error message, “Cannot use api-version and profile parameters at the same time”, my guess its there is something unexpected about the contents of your

parameters: "{{ ARMtemplateprofile[ARM_profile] }}"

I suggest maybe using debug module on that to make sure it contains what you expect. Add a task in to your playbook something like this:

`

  • name: show profile
    debug:
    var: “{{ ARMtemplateprofile[ARM_profile] }}”

`

Hope this helps,

Jon