Skip to content

Instantly share code, notes, and snippets.

@robmorgan
Created August 19, 2015 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robmorgan/c05405befb6f6df5cd45 to your computer and use it in GitHub Desktop.
Save robmorgan/c05405befb6f6df5cd45 to your computer and use it in GitHub Desktop.
Use Terraform to create a droplet on Digital Ocean
variable "do_token" {}
variable "pub_key" {}
variable "pvt_key" {}
variable "ssh_fingerprint" {}
provider "digitalocean" {
token = "${var.do_token}"
}
resource "digitalocean_droplet" "www-1" {
image = "ubuntu-14-04-x64"
name = "www-1"
region = "fra1"
size = "512mb"
private_networking = true
ssh_keys = [
"${var.ssh_fingerprint}"
]
provisioner "remote-exec" {
connection {
user = "root"
type = "ssh"
key_file = "${var.pvt_key}"
timeout = "2m"
}
inline = [
"export PATH=$PATH:/usr/bin",
# install nginx
"sudo apt-get update",
"sudo apt-get -y install nginx"
# install php
"sudo apt-get install php5-fpm",
# cgi.fix_pathinfo=0
"sudo sed -i 's/HAPROXY_PUBLIC_IP/${digitalocean_droplet.haproxy-www.ipv4_address}/g' /etc/haproxy/haproxy.cfg",
# install composer
service nginx restart
# restart nginx to load changes
# restart php5-fpm
]
}
}
@jonesthoma
Copy link

add comma after this command "sudo apt-get -y install nginx",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment