-
Notifications
You must be signed in to change notification settings - Fork 0
/
files.tf
58 lines (50 loc) · 1.35 KB
/
files.tf
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
48
49
50
51
52
53
54
55
56
57
58
# resource "ssh_resource" "files" {
# host = var.server.host
# user = var.server.user
# # agent = true
# file {
# source = "files/crontab"
# destination = "/tmp/steled-crontab"
# permissions = "0755"
# owner = "steled"
# group = "steled"
# }
# # file {
# # source = "files/preparation.sh"
# # destination = "/tmp/preparation.sh"
# # permissions = "0755"
# # owner = "steled"
# # group = "steled"
# # }
# commands = [
# "crontab /tmp/steled-crontab",
# # "/tmp/preparation.sh"
# ]
# private_key = file(var.server.private_key)
# # timeout = "10m"
# }
resource "terraform_data" "files" {
triggers_replace = fileset("${path.module}/files", "**")
connection {
type = "ssh"
user = var.server.user
host = var.server.host
}
provisioner "file" {
source = "files"
destination = "/tmp"
}
provisioner "remote-exec" {
inline = [
"sudo mkdir --mode 0755 -p /ext/logs",
"sudo chown steled:steled /ext/logs",
"sudo mkdir --mode 0755 -p /ext/scripts",
"sudo chown steled:steled /ext/scripts",
"mv /tmp/files/ssh-keys/* ~/.ssh/",
"mv /tmp/files/* /ext/scripts",
"chmod 0600 -R ~/.ssh/*",
"crontab /ext/scripts/steled-crontab",
"chmod +x /ext/scripts/*.sh"
]
}
}