Repository navigation
Expand file tree
/
Copy pathtranscodernode.tf
More file actions
119 lines (102 loc) · 2.83 KB
/
Copy pathtranscodernode.tf
File metadata and controls
119 lines (102 loc) · 2.83 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "2.5.2"
}
}
}
variable "linodeapikey" {
description = "Linode API token"
type = string
}
provider "linode" {
token = var.linodeapikey
}
variable "videofile" {
description = "Video filename"
type = string
}
variable "machinetype" {
description = "Machinetype"
type = string
default = "g6-dedicated-8"
}
variable "machinecount" {
description = "Number of machines"
type = string
default = "10"
}
variable "region" {
description = "Region to run in, make sure you can access storage"
type = string
default = "se-sto"
}
variable "public_key" {
description = "Public key for admin access to the ffmpeg machines"
type = string
}
variable "random" {
description = "A random string for naming machines"
type = string
}
variable "objectkeys" {
description = "Keys for object storage"
type = string
}
variable "storagebaseurl" {
description = "Base region for storage"
type = string
default = "https://se-sto-1.linodeobjects.com"
}
variable "rootpassword" {
description = "Password for root on the transcoder machines"
type = string
}
variable "logfile" {
description = "Location of logfile"
type = string
}
resource "linode_instance" "ffmpeg_instance" {
count = var.machinecount
label = "ffmpeg-instance-${var.random}-${count.index + 1}"
image = "linode/ubuntu22.04"
region = var.region
type = var.machinetype
root_pass = var.rootpassword
private_ip = false
authorized_keys = [ var.public_key ]
tags = ["transcode"]
provisioner "file" {
source = "ffmpeg_script.sh"
destination = "/tmp/ffmpeg_script.sh"
}
connection {
type = "ssh"
user = "root"
password = var.rootpassword
host = self.ip_address
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/ffmpeg_script.sh",
"apt-get update",
"sudo apt install -y s3fs",
"sudo mkdir -p /mnt/transcoding",
"echo ${var.objectkeys} > ~/.passwd-s3fs",
"sudo chmod 600 ~/.passwd-s3fs",
"echo 'transcoding /mnt/transcoding fuse.s3fs _netdev,allow_other,use_path_request_style,nonempty,url=${var.storagebaseurl} 0 0' | sudo tee -a /etc/fstab",
"sudo mount -a",
"echo '$(date +'%Y-%m-%d %H:%M:%S') : mounted' > '${var.logfile}'",
"apt-get install -y ffmpeg",
"echo Hello > /mnt/transcoding/output/logfile.log",
"/tmp/ffmpeg_script.sh /mnt/transcoding/intake/${var.random} ${var.videofile}_${count.index + 1}.txt",
]
connection {
type = "ssh"
user = "root"
password = var.rootpassword
host = self.ip_address
}
}
}