ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
248 stars 332 forks source link

azure_Rm_deployment module does not work with parameters file. #132

Open banicr opened 4 years ago

banicr commented 4 years ago

I am trying to use the azure_rm_deployment module to create azure vm. I have a custom byol template. This template works fine if i use just the template. But when i pass the parameters file along with the template, it throws the below mentioned error:

fatal: [localhost]: FAILED! => {"changed": false, "failed_deployment_operations": [], "msg": "Deployment failed with status code: 400 and message: Operation failed with status: 'Bad Request'. Details: 400 Client Error: Bad Request for url: https://management.azure.com/subscriptions//resourcegroups//providers/Microsoft.Resources/deployments/<deployment_name??api-version=2017-05-10"}

When i click on the link, it gives some authorization error as shown below: {"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}}

But it does not throw this error if i remove the "parameters: "{{ (lookup('file', 'parameters.json') | from_json).parameters }}"" line from the playbook and pass the default values in the template file.

COMPONENT NAME

azure_rm_deployment

ANSIBLE VERSION

ansible 2.9.7

CONFIGURATION

ANSIBLE_SSH_CONTROL_PATH_DIR(/home/bhavani/ansible.cfg) = /tmp/.ansible/cp ANSIBLE_SSH_EXECUTABLE(/home/bhavani/ansible.cfg) = /usr/bin/ssh DEFAULT_LOG_PATH(/home/bhavani/ansible.cfg) = /home/bhavani/ansible.log DEFAULT_VAULT_PASSWORD_FILE(/home/bhavani/ansible.cfg) = /home/bhavani/.vault-pass.txt DEPRECATION_WARNINGS(/home/bhavani/ansible.cfg) = False HOST_KEY_CHECKING(/home/bhavani/ansible.cfg) = False LOCALHOST_WARNING(/home/bhavani/ansible.cfg) = False RETRY_FILES_ENABLED(/home/bhavani/ansible.cfg) = False

STEPS TO REPRODUCE

playbook:

hosts: localhost connection: local gather_facts: yes tasks: name: Ensure the VM is deployed to Azure azure_rm_deployment: state: present name: deploymentname location: West India resource_group_name: resource_group template: "{{ lookup('file', 'deploy-f5-byol.json') }}" parameters: "{{ (lookup('file', 'parameters.json') | from_json).parameters }}"

ACTUAL RESULTS

When i run the playbook, it throws the below error: command: ansible-playbook ansiblevm.yaml [WARNING]: No inventory was parsed, only implicit localhost is available

PLAY [localhost] *****

TASK [Gathering Facts] *** ok: [localhost]

TASK [Ensure the VM is deployed to Azure] **** fatal: [localhost]: FAILED! => {"changed": false, "failed_deployment_operations": [], "msg": "Deployment failed with status code: 400 and message: Operation failed with status: 'Bad Request'. Details: 400 Client Error: Bad Request for url: https://management.azure.com/subscriptions//resourcegroups//providers/Microsoft.Resources/deployments/deploymentname?api-version=2017-05-10"}

PLAY RECAP *** localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

raghureddy45 commented 3 years ago

Damnn.. No update since 2020. :(