# Azure custom\_data usage

**URL:** <https://forum.ansible.com/t/azure-custom-data-usage/31739>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [November 27, 2019, 8:58pm UTC](https://forum.ansible.com/t/azure-custom-data-usage/31739 "2019-11-27T20:58:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Ally](https://avatars.discourse-cdn.com/v4/letter/c/e19adc/32.png) [@Christian\_Ally](https://forum.ansible.com/u/Christian_Ally)\
**Post date:** [November 27, 2019, 8:58pm UTC](https://forum.ansible.com/t/azure-custom-data-usage/31739/1 "2019-11-27T20:58:49Z")

</div>

Hi,

I am looking for examples on how to use the custom\_data field in Ansible azure\_rm\_virtualmachine.

I am wondering if we can pass an inline script that will use parameters passed from the ansible playbook.

Something like :

- name: Create VM  
azure\_rm\_virtualmachine:  
resource\_group: “{{ depName }}ResourceGroup”  
name: “{{ depName }}VM”  
vm\_size: Standard\_DS1\_v2  
admin\_username: userName  
ssh\_password\_enabled: true  
admin\_password: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
network\_interfaces:

- “{{ depName }}AdminNIC”

- “{{ depName }}UserNIC”  
custom\_data: “#!/bin/bash  
echo ‘Deployment Name is {{ depName }}’ \> ~/toto.txt”

When I do that all the data is sent to cloud\_init in one single string and the script fail to execute.

In Terraform we can do something like this but it does not seems to work with Ansible:

custom\_data: “\<\<-EOF  
#!/bin/bash  
echo ‘Deployment Name is {{ depName }}’ \> ~/toto.txt  
EOF”

Thanks
