【问题标题】:Terraform use local provider/pluginTerraform 使用本地提供程序/插件
【发布时间】:2021-09-11 21:30:11
【问题描述】:

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

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

# 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

这是我的 vim /root/.terraformrc

provider_installation {
  filesystem_mirror {
    path    = "/root/.terraform.d/plugins"
  }
  direct {
    exclude = ["registry.terraform.io/*/*"]
  }
}

这是我的 ma​​in.tf

terraform {
    required_version    = ">= 0.12.6"
}
provider "zabbix" {
    username            = local.provider_vars.zabbix.username
    password            = local.provider_vars.zabbix.password
    url                 = local.provider_vars.zabbix.endpoint
    tls_insecure        = true
}

但是当我跑步时:terraform init

正在初始化后端...

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

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

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

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

  • /root/.terraform.d/plugins

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

马可

【问题讨论】:

    标签: terraform


    【解决方案1】:

    假设你有一个二进制文件

    ~/.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!
    

    【讨论】:

      猜你喜欢
      • 2020-12-05
      • 2020-08-28
      • 2021-11-13
      • 2021-07-24
      • 2020-08-31
      • 2020-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多