fire off a provisioner with terraform

I'm trying to create nodes with terraform, and I'm experimenting with invoking provisioners once the node is there.

I can't find how to set the IP address of the resource that was just created.

I'm trying to follow the process from This example in GCP

resource "linode_instance" "my_linode" {
label = "my_linode"
image = "linode/debian10"
region = var.region
type = "g6-nanode-1"
root_pass = var.root-password
authorized_keys = [ "ssh-rsa key" ]

provisioner "remote-exec" {
inline = ["echo 'Hello World'"]

connection {
type = "ssh"
user = "${var.ssh_user}"
private_key = "${file("${var.private_key_path}")}"

But that returns an error

The argument "host" is required, but no definition was found.

So, my best guess would be

connection {
host = self.ipv4_address
type = "ssh"
user = "${var.ssh_user}"
private_key = "${file("${var.private_key_path}")}"

Based on some Googling, but the Docs are not clear how this is done.

1 Reply

Hey @michield - if I'm understanding correctly, the example you linked initially seems to be using Terraform to provision your environment and Ansible to configure things after-the-fact.

After looking at Terraform's Linode documentation a little closer, it looks like you need to adjust the host IP variable from ipv4_address to ip_address. For reference, it's located under the "Attributes" section of the guide: Terraform: linode_instance

Our Terraform guide has some good provider config examples as well: Use Terraform to Provision Linode Environments

And our Ansible guide has some good examples on how to define your destination IP in your playbook: How to use the Linode Ansible Module to Deploy Linodes

Hope this helps!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct