tusd/.infra/Freyfile.toml

176 lines
6.0 KiB
TOML
Raw Permalink Normal View History

[global]
2016-03-29 14:21:21 +00:00
appname = "tusd"
2016-03-29 13:49:46 +00:00
approot = "/srv/tusd"
[global.ssh]
key_dir = "./ssh"
[global.ansiblecfg.privilege_escalation]
become = true
[global.ansiblecfg.defaults]
2016-03-29 13:49:46 +00:00
host_key_checking = false
[infra.provider.aws]
access_key = "${var.FREY_AWS_ACCESS_KEY}"
region = "us-east-1"
secret_key = "${var.FREY_AWS_SECRET_KEY}"
[infra.variable.ami.default]
us-east-1 = "ami-9bce7af0"
[infra.variable.region]
default = "us-east-1"
[infra.output.public_address]
2016-03-29 14:21:21 +00:00
value = "${aws_instance.tusd.0.public_dns}"
[infra.output.public_addresses]
2016-03-29 14:21:21 +00:00
value = "${join(\"\n\", aws_instance.tusd.*.public_dns)}"
[infra.output.endpoint]
value = "http://${aws_route53_record.www.name}:80/"
2016-03-29 14:21:21 +00:00
[infra.resource.aws_instance.tusd]
2016-03-29 13:49:46 +00:00
ami = "${lookup(var.ami, var.region)}"
instance_type = "c3.large"
2016-03-29 14:43:12 +00:00
key_name = "infra-tusd"
2016-03-29 14:21:21 +00:00
security_groups = ["fw-tusd-main"]
[infra.resource.aws_instance.tusd.connection]
key_file = "{{{config.global.ssh.privatekey_file}}}"
2016-03-29 13:49:46 +00:00
user = "{{{config.global.ssh.user}}}"
2016-03-29 14:21:21 +00:00
[infra.resource.aws_instance.tusd.tags]
Name = "${var.FREY_DOMAIN}"
[infra.resource.aws_route53_record.www]
2016-03-29 13:49:46 +00:00
name = "${var.FREY_DOMAIN}"
2016-03-29 14:21:21 +00:00
records = ["${aws_instance.tusd.public_dns}"]
2016-03-29 13:49:46 +00:00
ttl = "300"
type = "CNAME"
zone_id = "${var.FREY_AWS_ZONE_ID}"
2016-03-29 14:21:21 +00:00
[infra.resource.aws_security_group.fw-tusd-main]
description = "Infra tusd"
2016-03-29 14:21:21 +00:00
name = "fw-tusd-main"
[[infra.resource.aws_security_group.fw-tusd-main.ingress]]
cidr_blocks = [ "0.0.0.0/0" ]
2016-03-29 13:49:46 +00:00
from_port = 8080
protocol = "tcp"
to_port = 8080
2016-03-29 14:21:21 +00:00
[[infra.resource.aws_security_group.fw-tusd-main.ingress]]
cidr_blocks = [ "0.0.0.0/0" ]
2016-03-29 13:49:46 +00:00
from_port = 80
protocol = "tcp"
to_port = 80
2016-03-29 14:21:21 +00:00
[[infra.resource.aws_security_group.fw-tusd-main.ingress]]
cidr_blocks = [ "0.0.0.0/0" ]
from_port = 22
2016-03-29 13:49:46 +00:00
protocol = "tcp"
to_port = 22
[[install.playbooks]]
2016-03-29 14:21:21 +00:00
hosts = "tusd"
name = "Install tusd"
2016-03-29 13:49:46 +00:00
[[install.playbooks.roles]]
role = "{{{init.paths.roles_dir}}}/apt/v1.0.0"
apt_packages = [
"apg",
"build-essential",
"curl",
"git-core",
"htop",
"iotop",
"libpcre3",
"logtail",
"mlocate",
"mtr",
"psmisc",
"telnet",
"vim",
"wget",
]
2016-03-31 13:38:16 +00:00
[[install.playbooks.roles]]
role = "{{{init.paths.roles_dir}}}/unattended-upgrades/v1.2.0"
[[install.playbooks.tasks]]
2016-03-29 13:49:46 +00:00
lineinfile = "dest=/home/{{{config.global.ssh.user}}}/.bashrc line=\"alias wtf='sudo tail -f /var/log/*{log,err} /var/log/{dmesg,messages,*{,/*}{log,err}}'\" owner={{{config.global.ssh.user}}} group={{{config.global.ssh.user}}} mode=0644 backup=yes"
name = "Common | Add convenience shortcut wtf"
[[install.playbooks.tasks]]
lineinfile = "dest=/home/{{{config.global.ssh.user}}}/.bashrc line=\"cd {{{config.global.approot}}}/current || true\" owner={{{config.global.ssh.user}}} group={{{config.global.ssh.user}}} mode=0644 backup=yes"
name = "Common | Install login"
[[install.playbooks.tasks]]
name = "Common | Set motd"
copy = "content='Welcome to {{lookup('env', 'FREY_DOMAIN')}}' dest=/etc/motd owner=root group=root mode=0644 backup=yes"
[[install.playbooks.tasks]]
name = "Common | Set timezone variables"
copy = "content='Etc/UTC' dest=/etc/timezone owner=root group=root mode=0644 backup=yes"
notify = [ "Common | Update timezone" ]
[[install.playbooks.handlers]]
name = "Common | Update timezone"
command = "dpkg-reconfigure --frontend noninteractive tzdata"
[[setup.playbooks]]
2016-03-29 14:21:21 +00:00
hosts = "tusd"
name = "Setup tusd"
[[setup.playbooks.roles]]
role = "{{{init.paths.roles_dir}}}/upstart/v1.0.0"
upstart_command = "./tusd -port=8080 -dir=/mnt/tusd-data -store-size=10737418240"
upstart_description = "tusd server"
upstart_name = "{{{config.global.appname}}}"
upstart_pidfile_path = "{{{config.global.approot}}}/shared/{{{config.global.appname}}}.pid"
upstart_respawn = true
upstart_respawn_limit = true
2016-03-30 14:13:20 +00:00
upstart_runtime_root = "{{{config.global.approot}}}/current/tusd_linux_amd64"
upstart_user = "www-data"
[[setup.playbooks.roles]]
role = "{{{init.paths.roles_dir}}}/rsyslog/v3.0.1"
[setup.playbooks.roles.rsyslog_rsyslog_d_files.49-tusd]
# Send {{{config.global.appname}}} messages to a dedicated logfile
2016-03-30 14:13:20 +00:00
directives = [ "& stop" ]
[[setup.playbooks.roles.rsyslog_rsyslog_d_files.49-tusd.rules]]
rule = ":programname, startswith, \"{{{config.global.appname}}}\""
logpath = "{{{config.global.approot}}}/shared/logs/{{{config.global.appname}}}.log"
2016-03-29 13:49:46 +00:00
[[setup.playbooks.roles]]
role = "{{{init.paths.roles_dir}}}/fqdn/v1.0.0"
fqdn = "{{lookup('env', 'FREY_DOMAIN')}}"
[[setup.playbooks.tasks]]
file = "path=/mnt/tusd-data state=directory owner=www-data group=www-data mode=0755 recurse=yes"
2016-03-29 14:21:21 +00:00
name = "tusd | Create tusd data dir"
[[deploy.playbooks]]
2016-03-29 14:21:21 +00:00
hosts = "tusd"
name = "Deploy tusd"
2016-03-29 13:49:46 +00:00
[[deploy.playbooks.roles]]
# @todo On travis, we could directly use the generated
# /home/travis/gopath/src/github.com/tus/tusd/snapshot/tusd_linux_amd64.tar.gz
2016-03-29 13:49:46 +00:00
role = "{{{init.paths.roles_dir}}}/deploy/v1.4.0"
ansistrano_get_url = "https://github.com/tus/tusd/releases/download/0.1.2/tusd_linux_amd64.tar.gz"
2016-03-29 13:49:46 +00:00
ansistrano_deploy_to = "{{{config.global.approot}}}"
ansistrano_deploy_via = "download_unarchive"
2016-03-29 13:59:15 +00:00
ansistrano_group = "ubuntu"
[[deploy.playbooks.tasks]]
name = "tusd | Set file attributes"
2016-03-29 13:49:46 +00:00
file = "path={{{config.global.approot}}}/current/tusd_linux_amd64/tusd mode=0755 owner=www-data group=www-data"
[[restart.playbooks]]
2016-03-29 14:21:21 +00:00
hosts = "tusd"
name = "Restart tusd"
[[restart.playbooks.tasks]]
shell = "iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080"
2016-03-29 14:21:21 +00:00
name = "tusd | Redirect HTTP traffic to tusd"
[[restart.playbooks.tasks]]
action = "service name=tusd state=restarted"
2016-03-29 14:21:21 +00:00
name = "tusd | Restart"