1
votes

I'm using self-hosted agent in Azure Pipelines and I installed Terraform 0.13 there. When I use Terraform tasks in Azure Devops, as commandOptions I chose '-plugin-dir=/usr/local/bin/.terraform.d/plugins' to skip plugin downloading. Unfortunately, Terraform downloads it to artifact and makes it much heavier than it should be. Also next stage (deployment stage) uses only plugins from artifact, not from our agent. We do not have much space on our virtual machine that's why we want to avoid unnecessary downloads. In addition, we defined .terraformrc in home directory with plugin directory. Also we added environment variable as written there: https://www.terraform.io/docs/commands/cli-config.html#provider-installation

Thank you in advance!

enter image description here

enter image description here

2
Does the Devops process definitely have read permissions on the specified folder? Is there anything in the output that suggests a reason for the option to be ignored?T.H.
Do you have the option of working around this by instead using the plugin_cache_dir configuration detailed on the doc page you reference?T.H.
Actually I find another way to manage with plugins - it is caching.Bater55

2 Answers

0
votes

You can try to set -get-plugins=false option.

-get-plugins=false — Skips plugin installation. Terraform will use plugins installed in the user plugins directory, and any plugins already installed for the current working directory. If the installed plugins aren't sufficient for the configuration, init fails.

This is stated in this document.

0
votes

Eventually I did it another way - I used Cache task from Azure Pipelines. Here's a solution from ITNext: https://itnext.io/infrastructure-as-code-iac-with-terraform-azure-devops-f8cd022a3341

This is how I described Cache task: enter image description here

Describe keys well and choose right path.