From 19b117c8cc7c4d015666badf42bb3507d36067f3 Mon Sep 17 00:00:00 2001 From: Flcable Date: Mon, 25 Nov 2019 13:39:51 +0000 Subject: [PATCH 1/2] Environment update for Ubunto 18 --- README.md | 66 ++++++++++-------------- packer-templates/application-server.json | 16 +++--- packer-templates/control-server.json | 58 ++++++++++----------- packer-templates/scripts/virtualbox.sh | 2 - 4 files changed, 60 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index 790a139..f47a1fb 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,18 @@ Instructions for Practice Project -======================================== +These instructions assume familiarity with Git and GitHub. If you are not comfortable with those tools, please complete Udacity's How to Use Git and GitHub course before proceeding. -These instructions assume familiarity with Git and GitHub. If you are not comfortable with those tools, please complete Udacity's [How to Use Git and GitHub](https://www.udacity.com/course/how-to-use-git-and-github--ud775) course before proceeding. - -After installing the required tools, you will need to ensure that your computer can find the executables to run them. For this, you might need to modify the PATH environment variable. A good overview is at [superuser.com](https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them). You may need to search the web for instructions on how to set the PATH variable for your specific operating system and version. - -## Setting up your local machine - -* Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) -* Install [Vagrant](https://www.vagrantup.com/downloads.html) -* Install [Packer](https://www.packer.io/downloads.html) -* Fork this repo to your own account -* Clone the forked repo to your local machine using this command: `git clone http://github.com//devops-intro-project devops`, replacing `` with your GitHub username. - -## Part I: Building a box with Packer +After installing the required tools, you will need to ensure that your computer can find the executables to run them. For this, you might need to modify the PATH environment variable. A good overview is at superuser.com. You may need to search the web for instructions on how to set the PATH variable for your specific operating system and version. +Setting up your local machine +Install VirtualBox +Install Vagrant +Install Packer +Fork this repo to your own account +Clone the forked repo to your local machine using this command: git clone http://github.com//devops-intro-project devops, replacing with your GitHub username. +Part I: Building a box with Packer From the packer-templates directory on your local machine: -* Run `packer build -only=virtualbox-iso application-server.json`. You may see various timeouts and errors, as shown below. If you do, retry the command until the ISO download succeeds: - -``` +Run packer build -only=virtualbox-iso application-server.json. You may see various timeouts and errors, as shown below. If you do, retry the command until the ISO download succeeds: read: operation timed out ==> virtualbox-iso: ISO download failed. Build 'virtualbox-iso' errored: ISO download failed. @@ -30,26 +23,19 @@ Build 'virtualbox-iso' errored: ISO download failed. ==> Some builds didn't complete successfully and had errors: --> virtualbox-iso: ISO download failed. -``` - -* Run `cd virtualbox` -* Run `vagrant box add ubuntu-14.04.4-server-amd64-appserver_virtualbox.box --name devops-appserver` -* Run `vagrant up` -* Run `vagrant ssh` to connect to the server - - -## Part II: Cloning, developing, and running the web application - -* On your local machine go to the root directory of the cloned repository -* Run `git clone https://github.com/chef/devops-kungfu.git devops-kungfu` -* Open http://localhost:8080 from your local machine to see the app running. -* In the VM, run `cd devops-kungfu` -* To install app specific node packages, run `sudo npm install`. You may see several errors; they can be ignored for now. -* Now you can run tests with the command `grunt -v`. The tests will run, then quit with an error. - -### Troubleshooting - -If you encounter errors with Ubuntu version numbers not being available or checksum errors on Ubuntu,it means that this repository has not yet been updated for the latest Ubuntu version. Feel free to mention this in the [forum](https://discussions.udacity.com/c/nd012-p1-intro-to-devops/nd012-the-devops-environment). Meanwhile, you can fix this error for yourself by editing the contents of the `application-server.json` and `control-server.json` template files inside the `packer-templates` folder. - -* Find the newest version number and checksum from the [Ubuntu website for this release](http://releases.ubuntu.com/trusty/) -* Edit `PACKER_BOX_NAME` and `iso_checksum` in the template files to match that version number and checksum. +Run cd virtualbox +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 +Part II: Cloning, developing, and running the web application +On your local machine go to the root directory of the cloned repository +Run git clone https://github.com/chef/devops-kungfu.git devops-kungfu +Open http://localhost:8080 from your local machine to see the app running. +In the VM, run cd devops-kungfu +To install app specific node packages, run sudo npm install. You may see several errors; they can be ignored for now. +Now you can run tests with the command grunt -v. The tests will run, then quit with an error. +Troubleshooting +If you encounter errors with Ubuntu version numbers not being available or checksum errors on Ubuntu,it means that this repository has not yet been updated for the latest Ubuntu version. Feel free to mention this in the forum. Meanwhile, you can fix this error for yourself by editing the contents of the application-server.json and control-server.json template files inside the packer-templates folder. + +Find the newest version number and checksum from the Ubuntu website for this release +Edit PACKER_BOX_NAME and iso_checksum in the template files to match that version number and checksum. \ No newline at end of file diff --git a/packer-templates/application-server.json b/packer-templates/application-server.json index f6e1b9c..d8f2500 100644 --- a/packer-templates/application-server.json +++ b/packer-templates/application-server.json @@ -1,7 +1,7 @@ { "variables": { "PACKER_OS_FLAVOUR": "ubuntu", - "PACKER_BOX_NAME": "ubuntu-14.04.4-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 +39,9 @@ "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", "guest_os_type": "Ubuntu_64", "http_directory": "http", - "iso_checksum": "07e4bb5569814eab41fafac882ba127893e3ff0bdb7ec931c9b2d040e3e94e7a", + "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, @@ -60,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}}" @@ -69,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", @@ -122,4 +122,4 @@ } ] ] -} +} \ No newline at end of file diff --git a/packer-templates/control-server.json b/packer-templates/control-server.json index 296281f..d8f2500 100644 --- a/packer-templates/control-server.json +++ b/packer-templates/control-server.json @@ -1,12 +1,12 @@ { "variables": { "PACKER_OS_FLAVOUR": "ubuntu", - "PACKER_BOX_NAME": "ubuntu-14.04.4-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,16 +39,16 @@ "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", "guest_os_type": "Ubuntu_64", "http_directory": "http", - "iso_checksum": "07e4bb5569814eab41fafac882ba127893e3ff0bdb7ec931c9b2d040e3e94e7a", + "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` }}", + "vm_name": "{{ user `PACKER_BOX_NAME` }}", "vboxmanage": [ ["modifyvm", "{{.Name}}", "--memory", "1024"], ["modifyvm", "{{.Name}}", "--cpus", "2"] @@ -60,35 +60,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" ] @@ -98,22 +99,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" ] } @@ -124,8 +118,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) From 5974b77c8ee48207ea6d49cf736615f09b607bcf Mon Sep 17 00:00:00 2001 From: Flavio Luiz Cruz Date: Mon, 25 Nov 2019 13:54:34 +0000 Subject: [PATCH 2/2] Update README.md --- README.md | 66 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index f47a1fb..e119401 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,25 @@ Instructions for Practice Project -These instructions assume familiarity with Git and GitHub. If you are not comfortable with those tools, please complete Udacity's How to Use Git and GitHub course before proceeding. +======================================== -After installing the required tools, you will need to ensure that your computer can find the executables to run them. For this, you might need to modify the PATH environment variable. A good overview is at superuser.com. You may need to search the web for instructions on how to set the PATH variable for your specific operating system and version. +These instructions assume familiarity with Git and GitHub. If you are not comfortable with those tools, please complete Udacity's [How to Use Git and GitHub](https://www.udacity.com/course/how-to-use-git-and-github--ud775) course before proceeding. + +After installing the required tools, you will need to ensure that your computer can find the executables to run them. For this, you might need to modify the PATH environment variable. A good overview is at [superuser.com](https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them). You may need to search the web for instructions on how to set the PATH variable for your specific operating system and version. + +## Setting up your local machine + +* Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) +* Install [Vagrant](https://www.vagrantup.com/downloads.html) +* Install [Packer](https://www.packer.io/downloads.html) +* Fork this repo to your own account +* Clone the forked repo to your local machine using this command: `git clone http://github.com//devops-intro-project devops`, replacing `` with your GitHub username. + +## Part I: Building a box with Packer -Setting up your local machine -Install VirtualBox -Install Vagrant -Install Packer -Fork this repo to your own account -Clone the forked repo to your local machine using this command: git clone http://github.com//devops-intro-project devops, replacing with your GitHub username. -Part I: Building a box with Packer From the packer-templates directory on your local machine: -Run packer build -only=virtualbox-iso application-server.json. You may see various timeouts and errors, as shown below. If you do, retry the command until the ISO download succeeds: +* Run `packer build -only=virtualbox-iso application-server.json`. You may see various timeouts and errors, as shown below. If you do, retry the command until the ISO download succeeds: + +``` read: operation timed out ==> virtualbox-iso: ISO download failed. Build 'virtualbox-iso' errored: ISO download failed. @@ -23,19 +30,26 @@ Build 'virtualbox-iso' errored: ISO download failed. ==> Some builds didn't complete successfully and had errors: --> virtualbox-iso: ISO download failed. -Run cd virtualbox -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 -Part II: Cloning, developing, and running the web application -On your local machine go to the root directory of the cloned repository -Run git clone https://github.com/chef/devops-kungfu.git devops-kungfu -Open http://localhost:8080 from your local machine to see the app running. -In the VM, run cd devops-kungfu -To install app specific node packages, run sudo npm install. You may see several errors; they can be ignored for now. -Now you can run tests with the command grunt -v. The tests will run, then quit with an error. -Troubleshooting -If you encounter errors with Ubuntu version numbers not being available or checksum errors on Ubuntu,it means that this repository has not yet been updated for the latest Ubuntu version. Feel free to mention this in the forum. Meanwhile, you can fix this error for yourself by editing the contents of the application-server.json and control-server.json template files inside the packer-templates folder. - -Find the newest version number and checksum from the Ubuntu website for this release -Edit PACKER_BOX_NAME and iso_checksum in the template files to match that version number and checksum. \ No newline at end of file +``` + +* Run `cd virtualbox` +* 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 + + +## Part II: Cloning, developing, and running the web application + +* On your local machine go to the root directory of the cloned repository +* Run `git clone https://github.com/chef/devops-kungfu.git devops-kungfu` +* Open http://localhost:8080 from your local machine to see the app running. +* In the VM, run `cd devops-kungfu` +* To install app specific node packages, run `sudo npm install`. You may see several errors; they can be ignored for now. +* Now you can run tests with the command `grunt -v`. The tests will run, then quit with an error. + +### Troubleshooting + +If you encounter errors with Ubuntu version numbers not being available or checksum errors on Ubuntu,it means that this repository has not yet been updated for the latest Ubuntu version. Feel free to mention this in the [forum](https://discussions.udacity.com/c/nd012-p1-intro-to-devops/nd012-the-devops-environment). Meanwhile, you can fix this error for yourself by editing the contents of the `application-server.json` and `control-server.json` template files inside the `packer-templates` folder. + +* Find the newest version number and checksum from the [Ubuntu website for this release](http://releases.ubuntu.com/trusty/) +* Edit `PACKER_BOX_NAME` and `iso_checksum` in the template files to match that version number and checksum.