配置实例时,我使用“remote-exec”执行一些命令,然后通过 terraform 启动一个 tomcat 实例。它看起来像这样:
resource "null_resource" "mount_fss_on_DFSrvr" {
depends_on = ["oci_core_instance.DFSrvr",
"oci_file_storage_export.export_FileListener_FileListenerMount",
]
count = "${var.proddfsrvr_count}"
provisioner "remote-exec" {
connection {
agent = false
timeout = "15m"
host = "${oci_core_instance.DFSrvr.*.public_ip[count.index % var.proddfsrvr_count]}"
user = "opc"
private_key = "${file(var.ssh_private_key)}"
}
inline = [
"some commands",
"./catalina.sh start",
"exit"
]
}
}
输出显示 tomcat 已启动,但是当我查看实例时,日志显示它尚未启动(没有日志记录)。我可以 ssh 进入实例并运行“./catalina.sh start”,它工作正常。我还尝试在 remote-exec 内联命令中创建服务并运行“sudo service tomee start”而不是“./catalina.sh start”,但这也不起作用。我在这里做错了什么?
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CATALINA_BASE: /apache-tomee-plus-7.0.4
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CATALINA_HOME: /apache-tomee-plus-7.0.4
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CATALINA_TMPDIR: /apache-tomee-plus-7.0.4/temp
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using JRE_HOME: /usr
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Using CLASSPATH: /apache-tomee-plus-7.0.4/bin/bootstrap.jar:/apache-tomee-plus-7.0.4/bin/tomcat-juli.jar
null_resource.mount_fss_on_DFSrvr[1] (remote-exec): Tomcat started.