From 59ae5328a7f7c77c523310501222fc31d32a5491 Mon Sep 17 00:00:00 2001 From: spengreb Date: Sun, 13 Feb 2022 23:07:02 +0100 Subject: [PATCH] Server now pops up with ansible. Removed packer entirely --- .gitlab-ci.yml | 19 +++----------- aws_ubuntu20_jamulus.json | 46 ---------------------------------- dns.tf | 2 -- main.tf | 26 ++++++------------- payload/init.d/jamulus.service | 2 +- scripts/deps.sh | 22 ---------------- scripts/server-start.sh | 5 ---- 7 files changed, 11 insertions(+), 111 deletions(-) delete mode 100644 aws_ubuntu20_jamulus.json delete mode 100755 scripts/deps.sh delete mode 100644 scripts/server-start.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d762c3c..b936890 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,26 +1,13 @@ image: - name: hashicorp/packer:latest - entrypoint: - - '/usr/bin/env' - - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + name: hashicorp/terraform:latest before_script: - - packer --version + - terraform --version stages: - validate - - build validate: stage: validate script: - - find . -maxdepth 1 -name '*.json' -print0 | xargs -t0n1 packer validate - -build: - stage: build - environment: production - script: - - ./build.sh $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY - when: manual - only: - - master + - validate \ No newline at end of file diff --git a/aws_ubuntu20_jamulus.json b/aws_ubuntu20_jamulus.json deleted file mode 100644 index 6277cc8..0000000 --- a/aws_ubuntu20_jamulus.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "builders": [{ - "type": "amazon-ebs", - "access_key": "{{user `aws_access_key`}}", - "secret_key": "{{user `aws_secret_key`}}", - "region": "eu-central-1", - "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "name": "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*", - "root-device-type": "ebs" - }, - "owners": ["099720109477"], - "most_recent": true - }, - "instance_type": "t2.micro", - "ssh_username": "ubuntu", - "ami_name": "Jamulus-{{timestamp}}", - "launch_block_device_mappings": [{ - "device_name":"/dev/sda1", - "volume_size":100, - "volume_type":"gp2", - "encrypted":false, - "delete_on_termination":true - }], - "tags": { - "Name": "jamulus-{{timestamp}}" - } - }], - "provisioners": [ - { - "type": "file", - "source": "payload/init.d/node_exporter.service", - "destination": "/tmp/node_exporter.service" - }, - { - "type": "file", - "source": "payload/init.d/jamulus.service", - "destination": "/tmp/jamulus.service" - }, - { - "type": "shell", - "script": "scripts/deps.sh" - } - ] -} \ No newline at end of file diff --git a/dns.tf b/dns.tf index f7ed538..00d768e 100644 --- a/dns.tf +++ b/dns.tf @@ -7,8 +7,6 @@ terraform { } } -variable "do_token" {} - provider "digitalocean" { token = var.do_token } diff --git a/main.tf b/main.tf index 7f3766c..071b69f 100644 --- a/main.tf +++ b/main.tf @@ -13,14 +13,12 @@ terraform { resource "aws_instance" "jamulus" { ami = "${data.aws_ami.image.id}" - instance_type = "c5.large" + instance_type = "t3.small" key_name = "jamulus" security_groups = [ aws_security_group.ssh.name, aws_security_group.jamulus.name, aws_security_group.node-exporter.name ] # Add your own IP to this group - provisioner "file" { - source = "scripts/server-start.sh" - destination = "/tmp/server-start.sh" - + provisioner "remote-exec" { + inline = ["sudo apt update", "sudo apt install python3 -y", "echo Done!"] connection { type = "ssh" user = "ubuntu" @@ -29,18 +27,8 @@ resource "aws_instance" "jamulus" { } } - provisioner "remote-exec" { - inline = [ - "sleep 45", - "chmod +x /tmp/server-start.sh", - "/tmp/server-start.sh" - ] - connection { - type = "ssh" - user = "ubuntu" - host = self.public_ip - private_key = file("${path.module}/jamulus.pem") - } + provisioner "local-exec" { + command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u ubuntu -i '${self.public_ip},' --private-key ${"${path.module}/jamulus.pem"} jamulus-install.yml" } tags = { @@ -50,10 +38,10 @@ resource "aws_instance" "jamulus" { data "aws_ami" "image" { most_recent = true - owners = ["self"] + owners = ["099720109477"] filter { name = "name" - values = ["Jamulus-*"] + values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] } } diff --git a/payload/init.d/jamulus.service b/payload/init.d/jamulus.service index d4d0cfd..c5deebe 100644 --- a/payload/init.d/jamulus.service +++ b/payload/init.d/jamulus.service @@ -16,7 +16,7 @@ IOSchedulingPriority=0 #### Change this to publish this server, set genre, location and other parameters. #### See https://jamulus.io/wiki/Command-Line-Options #### -ExecStart=/bin/sh -c 'exec /usr/bin/jamulus-headless -s -n -o "VerethanE;Falkenstein;224" -w "Welcome to Vereto Private" -T -F' +ExecStart=/bin/sh -c 'exec /usr/bin/jamulus-headless -s -n -w "Welcome to Vereto Private" -T -F -o "VerethanE;Falkenstein;224"' Restart=on-failure diff --git a/scripts/deps.sh b/scripts/deps.sh deleted file mode 100755 index 89286fd..0000000 --- a/scripts/deps.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -ex - -# apt Deps -sudo apt-get update -y -sudo apt-get upgrade -y -sudo apt dist-upgrade -y -sudo apt-get install -y libqt5core5a libqt5network5 libqt5xml5 -# Prometheus Setup -wget -O /tmp/node_exporter.tar.gz https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz -tar xvzf /tmp/node_exporter.tar.gz -C /tmp/ -sudo cp /tmp/node_exporter-1.2.2.linux-amd64/node_exporter /usr/local/bin/ -sudo mv /tmp/node_exporter.service /lib/systemd/system/ - -# Jamulus Setup -sudo useradd -m -s /bin/bash jam -wget -O /tmp/jamulus_headless_3.8.0_ubuntu_amd64.deb https://github.com/jamulussoftware/jamulus/releases/download/r3_8_0/jamulus_headless_3.8.0_ubuntu_amd64.deb -sudo dpkg -i /tmp/jamulus_headless_3.8.0_ubuntu_amd64.deb -sudo mv /tmp/jamulus.service /lib/systemd/system/ -# Enable Services -sudo systemctl daemon-reload -sudo systemctl enable jamulus-headless.service -sudo systemctl enable node_exporter.service diff --git a/scripts/server-start.sh b/scripts/server-start.sh deleted file mode 100644 index 118b236..0000000 --- a/scripts/server-start.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -xe - -sudo systemctl start jamulus-headless.service - -sudo systemctl start node_exporter.service \ No newline at end of file