i have two bash scripts A and B and i am requesting two instances in terraform using vra7 provider. how to run script A to instanceA and script B to instance B using remote-exec. tried with the below code. but getting error.
resource_configuration = {
rvar.ip_address = ""
}
provisioner "file" {
source = "/work/scripts/runit.sh"
destination = "/tmp/runit.sh"
connection {
type = "ssh"
user = "${var.username1}"
host = "${self.resource_configuration.rvar.ip_address[0]}"
password = "${var.password1}"
}
}
provisioner "remote-exec" {
inline = [
"sudo -S <<< ${var.password1} chmod +x /tmp/runit.sh",
"sudo /tmp/runit.sh"
]
connection {
type = "ssh"
user = "${var.username1}"
host = "${self.resource_configuration.rvar.ip_address[0]}"
password = "${var.password1}"
}
}
#second proviioner (file and remote-exec)
provisioner "file" {
source = "/work/scripts/runit1.sh"
destination = "/tmp/runit.sh"
connection {
type = "ssh"
user = "${var.username1}"
host = "${self.resource_configuration.rvar.ip_address[1]}"
password = "${var.password1}"
}
}
provisioner "remote-exec" {
inline = [
"sudo -S <<< ${var.password1} chmod +x /tmp/runit.sh",
"sudo /tmp/runit.sh"
]
connection {
type = "ssh"
user = "${var.username1}"
host = "${self.resource_configuration.rvar.ip_address[1]}"
password = "${var.password1}"
}
}
}
while running i am getting the below error
invalid index operation into non-indexable type: TypeString in: