Terraform 使用本地提供程序/插件

时间:2021-06-29 16:38:54

标签: terraform

我在 linux_amd64(Oracle Linux Srv 8.4 64 位)上安装了 Terraform v1.0.1。

我正在尝试使用我保存在文件夹中的本地提供程序/插件:/root/.terraform.d/plugins

Arguments

这是我的vim /root/.terraformrc

p.StartInfo = new ProcessStartInfo
{
    FileName = @"C:\Program Files (x86)\Windows Media Player\wmplayer.exe",
    Arguments = @"something.mp4",
    UseShellExecute = false, // Not needed on .NET Core, since that's already the default
};

这是我的ma​​in.tf

# ll /root/.terraform.d/plugins
drwxr-xr-x. 2 root root       38 Jun 29 15:42 oldversion
-rwxr-xr-x. 1 root root 30068808 Jun 29 15:42 terraform-provider-zabbix
drwxr-xr-x. 2 root root       52 Jun 29 15:42 test_plugging

但是当我跑步时:provider_installation { filesystem_mirror { path = "/root/.terraform.d/plugins" } direct { exclude = ["registry.terraform.io/*/*"] } }

<块引用>

正在初始化后端...

正在初始化提供程序插件...

  • 正在查找最新版本的 hashicorp/zabbix...

错误:无法查询可用的提供程序包

无法检索提供程序的可用版本列表 hashicorp/zabbix:提供者 registry.terraform.io/hashicorp/zabbix 是 在任何搜索位置均未找到

  • /root/.terraform.d/plugins

如何解决这个问题? 感谢您的帮助

马可

1 个答案:

答案 0 :(得分:2)

假设你有一个二进制文件

~/.terraform.d/plugins/terraform.local/local/zabbix/1.0.0/linux_amd64/terraform-provider-zabbix_v1.0.0

如下配置 Terraform

terraform {
  required_providers {
    zabbix = {
      source  = "terraform.local/local/zabbix"
      version = "1.0.0"
      # Other parameters...
    }
  }
}

工作原理如下

terraform init

Initializing the backend...

Initializing provider plugins...
- Finding terraform.local/local/zabbix versions matching "1.0.0"...
- Installing terraform.local/local/zabbix v1.0.0...
- Installed terraform.local/local/zabbix v1.0.0 (unauthenticated)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!