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