-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
48 lines (42 loc) · 1.27 KB
/
main.tf
File metadata and controls
48 lines (42 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
provider "digitalocean" {
token = var.do_token
}
data "digitalocean_project" "project" {
name = var.project_name
}
data "digitalocean_ssh_key" "ssh-key" {
name = "Pradeep Tarakar"
}
resource "digitalocean_droplet" "server-instance" {
name = var.instance_name
ssh_keys = [data.digitalocean_ssh_key.ssh-key.id]
image = var.image
size = var.instance_size
region = var.instance_region
}
# resource "digitalocean_project_resources" "project-allocation" {
# project = data.digitalocean_project.project.id
# resources = [ digitalocean_droplet.server-instance.urn ]
# }
resource "digitalocean_record" "nextcloud-domain-mapping" {
domain = "abc.com"
type = "A"
name = var.subdomain_name
value = digitalocean_droplet.server-instance.ipv4_address
ttl = 369
provisioner "local-exec" {
command = "sleep 20"
}
provisioner "local-exec" {
command = " ansible-playbook -i ${digitalocean_droplet.server-instance.ipv4_address}, --ssh-extra-args='-o StrictHostKeyChecking=no' -e 'droplet_id=${digitalocean_droplet.server-instance.id}' -e 'do_pat=${var.do_token}' site.yaml"
working_dir = "${path.module}/ansible"
}
}