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