Comments (10)
Update.
I think the reason for this nor working is that remote-exec is trying execution a bit too early. I fixed this by adding a workaround local-exec provisioner to wait for a few more seconds.
provisioner "local-exec" {
command = "ping 127.0.0.1 -n 30 > nul"
on_failure = "continue"
}
from terraform-provider-digitalocean.
I'm getting this issue and the suggested workaround doesn't help
from terraform-provider-digitalocean.
@danreeves are you on Linux. In that case, you would need
provisioner "local-exec" {
command = "sleep 30"
on_failure = "continue"
}
@andrewsomething Do you think this should be closed without fixing? Although the workaround works but I think it needs to be fixed so that we don't have to add this.
from terraform-provider-digitalocean.
@atif089 I tried that but the sleep 30
doesn't seem to block at all. Maybe I've got my file structured incorrectly?
resource "digitalocean_droplet" "www-1" {
...digital ocean setup...
provisioner "local-exec" {
command = "sleep 30"
on_failure = "continue"
}
provisioner "remote-exec" {
...
}
connection {
...ssh stuff...
}
}
from terraform-provider-digitalocean.
@danreeves Looks good to me. You can try removing the on_failure
line. If there is any problem with the sleep command it should break before the remote-exec
You can also try adding a dummy remote-exec
with an echo
command or something which should timeout in 30 seconds.
from terraform-provider-digitalocean.
No difference. Here's what the output looks like for that part, as you can see sleep 30
doesn't block.
digitalocean_droplet.www-1: Still creating... (1m0s elapsed)
digitalocean_droplet.www-1: Provisioning with 'local-exec'...
digitalocean_droplet.www-1 (local-exec): Executing: ["/bin/sh" "-c" "sleep 30"]
digitalocean_droplet.www-1: Still creating... (1m10s elapsed)
digitalocean_droplet.www-1: Still creating... (1m20s elapsed)
digitalocean_droplet.www-1: Still creating... (1m30s elapsed)
digitalocean_droplet.www-1: Provisioning with 'remote-exec'...
from terraform-provider-digitalocean.
Try increasing the timeout. I'm assuming DO is taking more than 30 seconds to create the droplet. I can see sleep 30
executing fine
from terraform-provider-digitalocean.
Ah, you're totally right, I didn't understand the output. Upped the timeout and it worked. This really shouldn't be necessary though so I'd vote for re-opening the ticket.
Thanks for the help!
from terraform-provider-digitalocean.
Unfortunately, I don't think there is much we can do here from the provider side. All we do in the provider is set the IP address for use in the connection once the API reports the Droplet is ready:
The connection and provisioner are part of upstream Terraform core.
I think Still creating...
here is a bit misleading, as the resource is not considered "created" until the provisioner completes. So by the time you see Provisioning with 'remote-exec'...
in the output, the Droplet has been created on the DigitalOcean side. So the root issue is something with the SSH connection to the Droplet.
@danreeves Are you also trying to use this with a One-Click app like @atif089's example? If so, can you reproduce with a standard Ubuntu image? Please wait while we get your droplet ready...
leads me to believe that the One-Click is blocking SSH connections until it has completed its own internal provisioning scripts (e.g configuring Wordpress).
Another potential workaround for this that might be a bit more elegant is to provide the script you want to run in the Droplet's user_data
attribute. That way, an SSH connection is not needed. See: https://www.digitalocean.com/docs/droplets/resources/metadata/
There is probably also a feature request to Terraform itself to allow setting a number of retries on thee remote-exec provisioner.
from terraform-provider-digitalocean.
Yeah I was using a One-click App image. It works perfectly with the plain debian-9-x64
image. I guess I'll do the installs and setup I need myself which is a shame but not a big deal. Thanks again!
from terraform-provider-digitalocean.
Related Issues (20)
- App Platform image credentials set as required HOT 3
- Dedicated egress IP addresses support for App platform
- digitalocean_spaces_bucket NoSuchBucket while creating bucket HOT 3
- digitalocean_kubernetes_cluster. to support database operator HOT 2
- Consider adding GPG key to OpenTofu registry for the digitalocean provider HOT 2
- Support for database fork
- digitalocean_firewall blocks all ports
- digitalocean_ssh_key race condition (roduced an unexpected new value: Root object was present, but now absent) HOT 1
- digitalocean_database_cluster password is always empty HOT 5
- functions: feature: add resource, and data source for functions and namespaces
- Add OpenSearch Documentation HOT 1
- digitalocean_app panic HOT 1
- digitalocean_app: support private docker repositories HOT 2
- digitalocean_app: Service Autoscaling
- Error creating droplet: JSON unmarshal issue with large number into Go struct field type int HOT 2
- Imported database replica attempting to resize to current configuration HOT 1
- digitalocean_app.alert does not support DEPLOYMENT_STARTED and DEPLOYMENT_CANCELLED
- Certificate not found on import of digitalocean_certificate HOT 2
- `DEPLOYMENT_STARTED` and `DEPLOYMENT_CANCELLED` missing from docs
- Databases: Support Logsink
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-digitalocean.