diff --git a/README.md b/README.md index 28e1b6f..123c19c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Build 'virtualbox-iso' errored: ISO download failed. ``` * Run `cd virtualbox` -* Run `vagrant box add ubuntu-14.04.6-server-amd64-appserver_virtualbox.box --name devops-appserver` +* Run `vagrant box add ubuntu-18.04.3-live-server-amd64-appserver_virtualbox.box --name devops-appserver` * Run `vagrant up` * Run `vagrant ssh` to connect to the server diff --git a/packer-templates/application-server.json b/packer-templates/application-server.json index 480d71b..dd1fb12 100644 --- a/packer-templates/application-server.json +++ b/packer-templates/application-server.json @@ -1,7 +1,8 @@ { "variables": { "PACKER_OS_FLAVOUR": "ubuntu", - "PACKER_BOX_NAME": "ubuntu-14.04.6-server-amd64", +[ + "PACKER_BOX_NAME": "ubuntu-18.04.3-live-server-amd64", "AWS_ACCESS_KEY_ID": "{{env `AWS_ACCESS_KEY_ID`}}", "AWS_SECRET_ACCESS_KEY": "{{env `AWS_SECRET_ACCESS_KEY`}}", "DIGITALOCEAN_API_TOKEN": "{{env `DIGITALOCEAN_API_TOKEN`}}" @@ -39,9 +40,9 @@ "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", "guest_os_type": "Ubuntu_64", "http_directory": "http", - "iso_checksum": "b17d7c1e9d0321ad5810ba77b69aef43f0f29a5422b08120e6ee0576c4527c0e", + "iso_checksum": "b9beac143e36226aa8a0b03fc1cbb5921cff80123866e718aaeba4edb81cfa63", "iso_checksum_type": "sha256", - "iso_url": "http://releases.ubuntu.com/trusty/{{ user `PACKER_BOX_NAME` }}.iso", + "iso_url": "http://releases.ubuntu.com/18.04/{{ user `PACKER_BOX_NAME` }}.iso", "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now", "ssh_password": "vagrant", "ssh_port": 22, @@ -59,7 +60,7 @@ "access_key": "{{ user `AWS_ACCESS_KEY_ID` }}", "secret_key": "{{ user `AWS_SECRET_ACCESS_KEY` }}", "region": "us-east-1", - "source_ami": "ami-10b68a78", + "source_ami": "ami-0ac019f4fcb7cb7e6s", "instance_type": "t1.micro", "ssh_username": "ubuntu", "ami_name": "packer-app-server {{timestamp}}" @@ -68,16 +69,16 @@ "type": "googlecompute", "account_file": "account.json", "project_id": "devops-intro-project", - "source_image": "ubuntu-1404-trusty-v20150316", + "source_image": "ubuntu-1804-bionic-v20181222", "zone": "us-central1-a", - "image_name": "application-ubuntu-1404-{{timestamp}}", + "image_name": "application-ubuntu-1804-{{timestamp}}", "machine_type": "n1-standard-1", "ssh_username": "ubuntu" }, { "type": "digitalocean", "api_token": "{{ user `DIGITALOCEAN_API_TOKEN` }}", - "image": "ubuntu-14-04-x64", + "image": "ubuntu-18.04.3-live-server-amd64", "region": "tor1", "size": "512mb", "droplet_name": "udacity-devops", @@ -121,4 +122,4 @@ } ] ] -} +} \ No newline at end of file diff --git a/packer-templates/control-server.json b/packer-templates/control-server.json index 99b32c8..d802a34 100644 --- a/packer-templates/control-server.json +++ b/packer-templates/control-server.json @@ -1,12 +1,13 @@ { "variables": { "PACKER_OS_FLAVOUR": "ubuntu", - "PACKER_BOX_NAME": "ubuntu-14.04.6-server-amd64", + + "PACKER_BOX_NAME": "ubuntu-18.04.3-live-server-amd64", "AWS_ACCESS_KEY_ID": "{{env `AWS_ACCESS_KEY_ID`}}", "AWS_SECRET_ACCESS_KEY": "{{env `AWS_SECRET_ACCESS_KEY`}}", "DIGITALOCEAN_API_TOKEN": "{{env `DIGITALOCEAN_API_TOKEN`}}" - }, - "builders": [ + }, + "builders": [ { "type": "virtualbox-iso", "boot_command": [ @@ -39,14 +40,16 @@ "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", "guest_os_type": "Ubuntu_64", "http_directory": "http", - "iso_checksum": "b17d7c1e9d0321ad5810ba77b69aef43f0f29a5422b08120e6ee0576c4527c0e", + + "iso_checksum": "b9beac143e36226aa8a0b03fc1cbb5921cff80123866e718aaeba4edb81cfa63", "iso_checksum_type": "sha256", - "iso_url": "http://releases.ubuntu.com/trusty/{{ user `PACKER_BOX_NAME` }}.iso", + "iso_url": "http://releases.ubuntu.com/18.04/{{ user `PACKER_BOX_NAME` }}.iso", "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", "ssh_wait_timeout": "10000s", + "type": "virtualbox-iso", "vm_name": "control-{{ user `PACKER_BOX_NAME` }}", "vboxmanage": [ ["modifyvm", "{{.Name}}", "--memory", "1024"], @@ -59,35 +62,36 @@ "access_key": "{{ user `AWS_ACCESS_KEY_ID` }}", "secret_key": "{{ user `AWS_SECRET_ACCESS_KEY` }}", "region": "us-east-1", - "source_ami": "ami-10b68a78", + "source_ami": "ami-0ac019f4fcb7cb7e6s", "instance_type": "t1.micro", "ssh_username": "ubuntu", - "ami_name": "control-{{ user `PACKER_BOX_NAME` }}-{{timestamp}}" + "ami_name": "packer-app-server {{timestamp}}" }, { "type": "googlecompute", "account_file": "account.json", "project_id": "devops-intro-project", - "source_image": "ubuntu-1404-trusty-v20150316", + "source_image": "ubuntu-1804-bionic-v20181222", "zone": "us-central1-a", - "image_name": "control-ubuntu-1404-{{timestamp}}", + "image_name": "application-ubuntu-1804-{{timestamp}}", "machine_type": "n1-standard-1", "ssh_username": "ubuntu" }, { - "type": "digitalocean", - "api_token": "{{ user `DIGITALOCEAN_API_TOKEN` }}", - "image": "ubuntu-14-04-x64", - "region": "tor1", - "size": "512mb", - "droplet_name": "udacity-devops", - "private_networking": true - } + "type": "digitalocean", + "api_token": "{{ user `DIGITALOCEAN_API_TOKEN` }}", + "image": "ubuntu-18.04.3-live-server-amd64", + "region": "tor1", + "size": "512mb", + "droplet_name": "udacity-devops", + "private_networking": true + } ], + "provisioners": [ { "type": "shell", - "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'", + "execute_command": "echo 'vagrant'|{{.Vars}} sudo -S -E bash '{{.Path}}'", "scripts": [ "scripts/update.sh" ] @@ -97,22 +101,15 @@ "only": ["virtualbox-iso"], "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'", "scripts": [ - "scripts/virtualbox.sh", - "scripts/vagrant.sh" - ] - }, - { - "type": "file", - "source": "../jenkins-config", - "destination": "/tmp" + "scripts/virtualbox.sh", + "scripts/vagrant.sh" + ] }, { "type": "shell", "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'", "scripts": [ - "scripts/jenkins.sh", - "scripts/graphite.sh", - "scripts/nginx.sh", + "scripts/application.sh", "scripts/cleanup.sh" ] } @@ -123,8 +120,8 @@ "type": "vagrant", "except": ["googlecompute", "digitalocean"], "compression_level": "9", - "output": "../output/{{.Provider}}/control-{{ user `PACKER_BOX_NAME` }}.box" + "output": "{{.Provider}}/{{ user `PACKER_BOX_NAME` }}-appserver_{{.Provider}}.box" } ] ] -} +} \ No newline at end of file diff --git a/packer-templates/scripts/virtualbox.sh b/packer-templates/scripts/virtualbox.sh index 3babe26..af60a47 100644 --- a/packer-templates/scripts/virtualbox.sh +++ b/packer-templates/scripts/virtualbox.sh @@ -1,5 +1,3 @@ -#!/bin/bash -eux - echo "Installing Virtualbox Guest Utils" apt-get -y install dkms VBOX_VERSION=$(cat /home/vagrant/.vbox_version)