remote-exec provisioner: Exporting parameters to Shell Scripts

969 views
Skip to first unread message

Jaskaran Singh

unread,
Dec 24, 2015, 9:36:09 AM12/24/15
to Terraform
Hi,

I am using the file provisioner to upload shell scripts to a AWS ubuntu machine, and then using the remote-exec provisioner  to run the scripts.
Now i need to pass parameters from the remote-exec inline provisioner to the shell scripts.
 
As per the documentation, args can be sent as below:
resource "aws_instance" "web" 
{
 provisioner "file" { source = "script.sh" destination = "/tmp/script.sh" } 
 provisioner "remote-exec" { inline = [ "chmod +x /tmp/script.sh", "/tmp/script.sh args" ] } 
}

Is there any other way to pass parameters? Can i 'export' parameters in the  remote-exec inline provisioner as shown below:
{.... 
 provisioner "file" { source = "script.sh" destination = "/tmp/script.sh" } 
 provisioner "remote-exec" { 
inline = [ 
"export data=xyz",
"chmod +x /tmp/script.sh", 
"/tmp/script.sh" 
}

The exported parameters are not available when my scripts are executed. (ie the shell scripts do not find the exported environment parameters)

Please help.

Thanks
Jaskaran


Jaskaran Singh

unread,
Dec 24, 2015, 10:10:32 AM12/24/15
to Terraform
Hi, its working for me now. I am using bash shell instead of sh shell...
thanks

ra...@rmenn.in

unread,
Dec 25, 2015, 3:28:15 AM12/25/15
to Jaskaran Singh
Could you try something like

DEBUG=true. /script_name



Sent from my BlackBerry 10 smartphone.
From: Jaskaran Singh
Sent: Thursday, December 24, 2015 20:06
To: Terraform
Subject: [terraform] remote-exec provisioner: Exporting parameters to Shell Scripts

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/f693833b-4459-492d-8c57-05c1a1171521%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jaskaran Singh

unread,
Dec 27, 2015, 4:50:01 AM12/27/15
to terrafo...@googlegroups.com
Thanks Rahul
The debug option will be helpful.
You received this message because you are subscribed to a topic in the Google Groups "Terraform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/terraform-tool/d8FbGYB8KuE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/20151225082811.4915280.39351.4364%40rmenn.in.
Reply all
Reply to author
Forward
0 new messages