tflint
tflint copied to clipboard
`tflint --version` fails to find plugins
I am running tflint (version 0.33.1) in an Azure DevOps Ubuntu agent. I run the following commands in the pipeline in a PowerShell step:
RunCLI "$($cliPath) --loglevel ${{ parameters.logLevel }} --config='$($configPath)' --init '${{ parameters.workingDirectory }}'"
RunCLI "$($cliPath) --loglevel ${{ parameters.logLevel }} --version '${{ parameters.workingDirectory }}'"
RunCLI "$($cliPath) --loglevel ${{ parameters.logLevel }} --config='$($configPath)' --force '${{ parameters.workingDirectory }}'"
RunCLI "$($cliPath) --format=junit --config='$($configPath)' --force '${{ parameters.workingDirectory }}'" | out-file $resultsPath -encoding utf8
Abbreviated, this runs
tflint --init
tflint --version
tflint
The build log contains the error Failed to initialize plugins: Plugin azurerm not found. Did you run tflint --init? when running --version after --init.
Starting: Run tflint
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Linux, macOS, or Windows
Version : 2.194.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/agent/_work/_temp/ae88d534-5fe0-4f8d-96cc-b3ca443173e8.ps1'
##[debug]Creating install directory /agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a
Agent OS is Linux. Installing tool to /agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a
sudo install -c -v /agent/_work/_tool/github-releases/terraform-linters/tflint/0.33.1/tools/tflint_linux_amd64.zip/tflint /agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a
'/agent/_work/_tool/github-releases/terraform-linters/tflint/0.33.1/tools/tflint_linux_amd64.zip/tflint' -> '/agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a/tflint'
/agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a/tflint --loglevel info --config='/agent/_work/_temp/c93b73a3-f975-4c2f-bffd-c85c0cae8752.tflint.hcl' --init '/agent/_work/3/s'
00:25:03 config.go:107: [INFO] Load config: /agent/_work/_temp/c93b73a3-f975-4c2f-bffd-c85c0cae8752.tflint.hcl
Installing `azurerm` plugin...
Installed `azurerm` (source: github.com/terraform-linters/tflint-ruleset-azurerm, version: 0.13.0)
/agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a/tflint --loglevel info --version '/agent/_work/3/s'
TFLint version 0.33.1
00:25:08 config.go:107: [INFO] Load config: .tflint.hcl
00:25:08 loader.go:57: [INFO] Initialize new loader
00:25:08 loader.go:82: [INFO] Load configurations under .
00:25:08 loader.go:90: [INFO] Module inspection is disabled. Building a root module without children...
00:25:08 loader.go:170: [INFO] Load values files
00:25:09 runner.go:50: [INFO] Initialize new runner for root
00:25:09 version.go:62: [ERROR] Failed to initialize plugins: Plugin `azurerm` not found. Did you run `tflint --init`?
/agent/_work/_temp/812ccad8-b1ef-4566-9c20-5a7d41b9295a/tflint --loglevel info --config='/agent/_work/_temp/c93b73a3-f975-4c2f-bffd-c85c0cae8752.tflint.hcl' --force '/agent/_work/3/s'
00:25:09 config.go:107: [INFO] Load config: /agent/_work/_temp/c93b73a3-f975-4c2f-bffd-c85c0cae8752.tflint.hcl
00:25:09 loader.go:57: [INFO] Initialize new loader
00:25:09 loader.go:82: [INFO] Load configurations under /agent/_work/3/s
00:25:09 loader.go:90: [INFO] Module inspection is disabled. Building a root module without children...
00:25:09 loader.go:170: [INFO] Load values files
00:25:09 runner.go:50: [INFO] Initialize new runner for root
00:25:09 discovery.go:54: [INFO] Plugin `azurerm` found
00:25:09 provider.go:63: [INFO] Prepare rules
00:25:09 provider.go:91: [INFO] 12 default rules enabled
00:25:09 runner_eval.go:123: [INFO] Unknown value found in /agent/_work/3/s/main.tf:15. TFLint can only evaluate provided variables and skips dynamic values.
4 issue(s) found:
plugin "azurerm" {
enabled = true
version = "0.13.0"
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}
rule "terraform_documented_outputs" {
enabled = true
}
rule "terraform_documented_outputs" {
enabled = true
}
rule "terraform_comment_syntax" {
enabled = true
}
rule "terraform_deprecated_index" {
enabled = false
}
rule "terraform_deprecated_interpolation" {
enabled = false
}
rule "terraform_documented_variables" {
enabled = true
}
rule "terraform_module_pinned_source" {
enabled = true
}
rule "terraform_module_version" {
enabled = true
}
rule "terraform_module_version" {
enabled = true
}
rule "terraform_naming_convention" {
enabled = true
}
rule "terraform_required_providers" {
enabled = true
}
rule "terraform_required_version" {
enabled = true
}
rule "terraform_standard_module_structure" {
enabled = true
}
rule "terraform_typed_variables" {
enabled = true
}
rule "terraform_unused_required_providers" {
enabled = true
}
rule "terraform_workspace_remote" {
enabled = true
}
Is this an actual problem or are you just getting this on --version? Are the plugins not installed/running correctly?
It isn't blocking anything as the tflint still runs on the following command. So this only happens on the --version call where it isn't picking up the installed plugins. So it isn't an operational problem but just emitting errors into the build log. You can see from the log that init is pulling down the plugins and running tflint is using them. It is just that version is freaking out that it can't find the plugins.
Ok cool, we can fix the issue with --version, just trying to make sure it's actually isolated there per the title and not affecting the bare command.
The original issue is solved by setting --config with --version:
$ tflint --config=path/to/file --init
$ tflint --config=path/to/file --version
$ tflint --config=path/to/file
It feels a bit odd that config is required to output the versions, but I don't see a good idea to get around this as the plugin is configured by a config file.
As for command option isolation, we'll work on that in #1618. Closing this issue. Thanks.