Forum Discussion
santoshavvari
May 09, 2021Copper Contributor
Azure ARM template - Multi line bash script
Hi,
Greetings!!!
I would like to include the following bash scripts as a startup script for a VM. I am creating the VM using ARM template. I would like to know the syntax to use to include this multiline bash script in ARM template. If it is one line script, it is working fine however having issue with multi line script.
script:
service=/etc/sysconfig/iptables
cat > $service << FW_EOF
*filter
:INPUT ACCEPT [196:15477]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [84655:113694509]
COMMIT
FW_EOF
I have included it as follows in my ARM template.
script: "
service=/etc/sysconfig/iptables
cat > $service << FW_EOF
*filter
:INPUT ACCEPT [196:15477]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [84655:113694509]
COMMIT
FW_EOF"
It is not working. Any help appreciated.
Thanks,
Santosh
- pazdedavSteel Contributor
Have you considered saving that script in e.g. GitHub and referring to it in your template, as described here? https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux#template-deployment
Alternatively, you could leverage two other options for initial VM configuration:
- cloud-init - link
- config management tools like Ansible, Chef, etc.