main.tf.bak 988 B

12345678910111213141516171819202122232425262728293031323334
  1. # 什么 provider 都不需要!
  2. # 不用下载、不用镜像、不用 GitHub、不连外网!
  3. resource "null_resource" "k3s_install_all" {
  4. # SSH 登录你的服务器
  5. connection {
  6. type = "ssh"
  7. host = "101.201.78.54"
  8. user = "root"
  9. password = "Xs261617"
  10. }
  11. # 远程执行命令(你原来的所有逻辑,一模一样)
  12. provisioner "remote-exec" {
  13. inline = [
  14. # 1. 安装依赖
  15. #"apt update -y || yum install -y curl",
  16. #"apt install -y curl || true",
  17. # 2. 下载 k3s 二进制
  18. "wget -O /usr/local/bin/k3s http://download.9981.tech/k3s-v1.35.0%2Bk3s1",
  19. "chmod +x /usr/local/bin/k3s",
  20. # 3. 安装服务(不下载!只用本地二进制!)
  21. "INSTALL_K3S_SKIP_DOWNLOAD=true /usr/local/bin/k3s install server",
  22. "systemctl enable k3s",
  23. "systemctl restart k3s"
  24. ]
  25. }
  26. }
  27. output "结果" {
  28. value = "k3s 安装完成!完全没有使用 tenstad/remote 插件!"
  29. }