[global] appname = "infra-tusd" [global.ssh] key_dir = "./ssh" [global.ansiblecfg.privilege_escalation] become = true [global.ansiblecfg.defaults] 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.ip_all] default = "0.0.0.0/0" [infra.variable.ip_kevin] default = "62.163.187.106/32" [infra.variable.ip_marius] default = "84.146.0.0/16" [infra.variable.ip_tim] default = "24.134.75.132/32" [infra.variable.region] default = "us-east-1" [infra.output.public_address] value = "${aws_instance.infra-tusd-server.0.public_dns}" [infra.output.public_addresses] value = "${join(\"\n\", aws_instance.infra-tusd-server.*.public_dns)}" [infra.output.endpoint] value = "http://${aws_route53_record.www.name}:80/" [infra.resource.aws_instance.infra-tusd-server] ami = "${lookup(var.ami, var.region)}" instance_type = "c3.large" key_name = "infra-tusd" security_groups = ["fw-infra-tusd-main"] [infra.resource.aws_instance.infra-tusd-server.connection] key_file = "{{{config.global.ssh.privatekey_file}}}" user = "{{{config.global.ssh.user}}}" [infra.resource.aws_instance.infra-tusd-server.tags] Name = "${var.FREY_DOMAIN}" [infra.resource.aws_route53_record.www] name = "${var.FREY_DOMAIN}" records = ["${aws_instance.infra-tusd-server.public_dns}"] ttl = "300" type = "CNAME" zone_id = "${var.FREY_AWS_ZONE_ID}" [infra.resource.aws_security_group.fw-infra-tusd-main] description = "Infra tusd" name = "fw-infra-tusd-main" [[infra.resource.aws_security_group.fw-infra-tusd-main.ingress]] cidr_blocks = ["${var.ip_all}"] from_port = 8080 protocol = "tcp" to_port = 8080 [[infra.resource.aws_security_group.fw-infra-tusd-main.ingress]] cidr_blocks = ["${var.ip_all}"] from_port = 80 protocol = "tcp" to_port = 80 [[infra.resource.aws_security_group.fw-infra-tusd-main.ingress]] cidr_blocks = [ "${var.ip_kevin}", "${var.ip_marius}", "${var.ip_tim}", ] from_port = 22 protocol = "tcp" to_port = 22 [[install.playbooks]] hosts = "infra-tusd-server" name = "Install infra-tusd-server" roles = [ "{{{init.paths.roles_dir}}}/apt/v1.0.0", ] [install.playbooks.vars] apt_packages = [ "apg", "build-essential", "curl", "git-core", "htop", "iotop", "libpcre3", "logtail", "mlocate", "mtr", "psmisc", "telnet", "vim", "wget", ] [[install.playbooks.tasks]] action = "lineinfile dest=/home/ubuntu/.bashrc line=\"alias wtf='sudo tail -f /var/log/*{log,err} /var/log/{dmesg,messages,*{,/*}{log,err}}'\"" name = "Common | Add convenience shortcut wtf" [[setup.playbooks]] hosts = "infra-tusd-server" name = "Setup infra-tusd" [[setup.playbooks.tasks]] hostname = "name={{lookup('env', 'FREY_DOMAIN')}}" name = "infra-tusd | Set hostname" [[setup.playbooks.tasks]] file = "path=/srv/tusd/shared/logs state=directory owner=www-data group=www-data mode=0755 recurse=yes" name = "infra-tusd | Create shared log dir" [[setup.playbooks.tasks]] file = "path=/mnt/tusd-data state=directory owner=www-data group=www-data mode=0755 recurse=yes" name = "infra-tusd | Create tusd data dir" [[setup.playbooks.tasks]] action = "template src=templates/upstart-tusd.conf.j2 dest=/etc/init/tusd.conf" name = "infra-tusd | Install upstart file" [[deploy.playbooks]] hosts = "infra-tusd-server" name = "Deploy infra-tusd" roles = [ "{{{init.paths.roles_dir}}}/deploy/v1.4.0", ] [deploy.playbooks.vars] ansistrano_get_url = "https://github.com/tus/tusd/releases/download/0.1.2/tusd_linux_amd64.tar.gz" ansistrano_deploy_to = "/srv/tusd" ansistrano_deploy_via = "download_unarchive" ansistrano_npm = no ansistrano_owner = "www-data" ansistrano_group = "www-data" [[deploy.playbooks.tasks]] copy = "src=../env.sh dest=/srv/tusd/current/env.sh mode=0600 owner=root group=root" name = "infra-tusd | Upload environment" [[deploy.playbooks.tasks]] name = "tusd | Set file attributes" file = "path=/srv/tusd/current/tusd_linux_amd64/tusd mode=0755 owner=www-data group=www-data" [[restart.playbooks]] hosts = "infra-tusd-server" name = "Restart infra-tusd" [[restart.playbooks.tasks]] shell = "iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080" name = "infra-tusd | Redirect HTTP traffic to tusd" [[restart.playbooks.tasks]] action = "service name=tusd state=restarted" name = "infra-tusd | Restart"