terraform-provider-ansible
terraform-provider-ansible copied to clipboard
Update documentation to reflect Terraform 0.13 registry-based install
[SOLVED--see below]
@nbering I'm trying to update to terraform 0.13.1. Can you share any clues on how to switch to the registry?
I can see it here at https://registry.terraform.io/providers/nbering/ansible/latest I've added this block:
terraform {
[...]
required_providers {
ansible = {
source = "nbering/ansible"
version = "1.0.4"
}
}
}
but terraform is looking for -/ansible, even after installing bbering/ansible:
$ terraform init
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Using previously-installed nbering/ansible v1.0.4
- Using previously-installed hashicorp/aws v3.4.0
- Using previously-installed -/aws v3.4.0
- Finding latest version of hashicorp/ansible...
- Finding latest version of -/ansible...
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider -/ansible:
provider registry registry.terraform.io does not have a provider named
registry.terraform.io/-/ansible
Error: Failed to install provider
Error while installing hashicorp/ansible: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/ansible
$ terraform version
Terraform v0.13.1
+ provider registry.terraform.io/-/aws v3.4.0
+ provider registry.terraform.io/hashicorp/aws v3.4.0
+ provider registry.terraform.io/nbering/ansible v1.0.4
I figured out the upgrade procedure: 'terraforom replace-provider' will convert the resources defined locally in your project:
$ tf state replace-provider registry.terraform.io/-/ansible registry.terraform.io/nbering/ansible
Terraform will perform the following actions:
~ Updating provider:
- registry.terraform.io/-/ansible
+ registry.terraform.io/nbering/ansible
Changing 3 resources:
ansible_host.monitor
module.swarm_master.ansible_group.swarm_nodes
module.swarm_master.ansible_host.swarm_master
Do you want to make these changes?
Only 'yes' will be accepted to continue.
Enter a value: yes
Successfully replaced provider for 3 resources.
NOTE that any modules which use nbering/ansible also need a required_providers declaration for it.
Ah. I think I see what's going on there during the upgrade. It's stored a provider reference in your statefile and you need to upgrade that. That's good to note... it might happen the other-way-round too, if someone wants to fork the provider to make changes.
@nbering I don't think I totally solved this problem after all. I've upgraded my state with tf state replace-provider, added required_provider blocks in this project and all the modules it uses:
terraform {
required_providers {
ansible = {
source = "nbering/ansible"
version = "1.0.4"
}
aws = {
source = "hashicorp/aws"
}
}
}
and terraform is still looking for the obsolete hashicorp/ansible:
$ tf init
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Using previously-installed -/aws v3.5.0
- Using previously-installed nbering/ansible v1.0.4
- Using previously-installed hashicorp/aws v3.5.0
- Finding latest version of hashicorp/ansible...
Error: Failed to install provider
Error while installing hashicorp/ansible: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/ansible
@bdelvecchio Can you open a separate ticket for this? I had intended this one just to cover the documentation update, but it sounds like you need some troubleshooting. If you can find anything upstream from https://github.com/hashicorp/terraform, that might help you as well. In honesty, I haven't updated to 0.13 for my projects, yet... I usually wait a while because the early versions of Terraform major releases tend to be a little buggy.
sorry for taking over this issue! I'll open another one.