diff --git a/README.md b/README.md index 28e1b6f..232842a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Instructions for Practice Project -======================================== +# 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](https://www.udacity.com/course/how-to-use-git-and-github--ud775) course before proceeding. @@ -18,7 +17,7 @@ After installing the required tools, you will need to ensure that your computer * Run `cd packer-templates` * 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: -``` +``` shell read: operation timed out ==> virtualbox-iso: ISO download failed. Build 'virtualbox-iso' errored: ISO download failed. @@ -28,7 +27,7 @@ checksums didn't match expected Build 'virtualbox-iso' errored: ISO download failed. ==> Some builds didn't complete successfully and had errors: ---> virtualbox-iso: ISO download failed. +==> virtualbox-iso: ISO download failed. ``` * Run `cd virtualbox` @@ -36,12 +35,11 @@ Build 'virtualbox-iso' errored: ISO download failed. * 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. +* Open 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. diff --git a/packer-templates/application-server.json b/packer-templates/application-server.json index 480d71b..47767b7 100644 --- a/packer-templates/application-server.json +++ b/packer-templates/application-server.json @@ -1,124 +1,139 @@ { - "variables": { - "PACKER_OS_FLAVOUR": "ubuntu", - "PACKER_BOX_NAME": "ubuntu-14.04.6-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": [ + { + "boot_command": [ + "", + "", + "", + "/install/vmlinuz", + " auto", + " console-setup/ask_detect=false", + " console-setup/layoutcode=us", + " console-setup/modelcode=pc105", + " debconf/frontend=noninteractive", + " debian-installer=en_US", + " fb=false", + " initrd=/install/initrd.gz", + " kbd-chooser/method=us", + " keyboard-configuration/layout=USA", + " keyboard-configuration/variant=USA", + " locale=en_US", + " netcfg/get_domain=vm", + " netcfg/get_hostname=vagrant", + " noapic", + " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", + " -- ", + "" + ], + "boot_wait": "10s", + "disk_size": 10140, + "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", + "guest_os_type": "Ubuntu_64", + "headless": false, + "http_directory": "http", + "iso_checksum": "sha256:b17d7c1e9d0321ad5810ba77b69aef43f0f29a5422b08120e6ee0576c4527c0e", + "iso_url": "http://releases.ubuntu.com/trusty/{{ user `PACKER_BOX_NAME` }}.iso", + "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "10000s", + "ssh_username": "vagrant", + "type": "virtualbox-iso", + "vboxmanage": [ + [ + "modifyvm", + "{{.Name}}", + "--memory", + "1024" + ], + [ + "modifyvm", + "{{.Name}}", + "--cpus", + "2" + ] + ], + "virtualbox_version_file": ".vbox_version", + "vm_name": "{{ user `PACKER_BOX_NAME` }}" + }, + { + "access_key": "{{ user `AWS_ACCESS_KEY_ID` }}", + "ami_name": "packer-app-server {{timestamp}}", + "instance_type": "t1.micro", + "region": "us-east-1", + "secret_key": "{{ user `AWS_SECRET_ACCESS_KEY` }}", + "source_ami": "ami-10b68a78", + "ssh_username": "ubuntu", + "type": "amazon-ebs", + "skip_create_ami": true + }, + { + "account_file": "account.json", + "image_name": "application-ubuntu-1404-{{timestamp}}", + "machine_type": "n1-standard-1", + "project_id": "udacity-devops-341410", + "source_image": "ubuntu-1404-trusty-v20150316", + "ssh_username": "ubuntu", + "type": "googlecompute", + "zone": "us-central1-a" }, - "builders": [ + { + "api_token": "{{ user `DIGITALOCEAN_API_TOKEN` }}", + "droplet_name": "udacity-devops", + "image": "ubuntu-14-04-x64", + "private_networking": true, + "region": "tor1", + "size": "512mb", + "type": "digitalocean" + } + ], + "post-processors": [ + [ { - "type": "virtualbox-iso", - "boot_command": [ - "", - "", - "", - "/install/vmlinuz", - " auto", - " console-setup/ask_detect=false", - " console-setup/layoutcode=us", - " console-setup/modelcode=pc105", - " debconf/frontend=noninteractive", - " debian-installer=en_US", - " fb=false", - " initrd=/install/initrd.gz", - " kbd-chooser/method=us", - " keyboard-configuration/layout=USA", - " keyboard-configuration/variant=USA", - " locale=en_US", - " netcfg/get_domain=vm", - " netcfg/get_hostname=vagrant", - " noapic", - " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg", - " -- ", - "" - ], - "boot_wait": "10s", - "headless": false, - "disk_size": 10140, - "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", - "guest_os_type": "Ubuntu_64", - "http_directory": "http", - "iso_checksum": "b17d7c1e9d0321ad5810ba77b69aef43f0f29a5422b08120e6ee0576c4527c0e", - "iso_checksum_type": "sha256", - "iso_url": "http://releases.ubuntu.com/trusty/{{ 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", - "vm_name": "{{ user `PACKER_BOX_NAME` }}", - "vboxmanage": [ - ["modifyvm", "{{.Name}}", "--memory", "1024"], - ["modifyvm", "{{.Name}}", "--cpus", "2"] + "compression_level": "9", + "except": [ + "googlecompute", + "digitalocean" ], - "virtualbox_version_file": ".vbox_version" - }, - { - "type": "amazon-ebs", - "access_key": "{{ user `AWS_ACCESS_KEY_ID` }}", - "secret_key": "{{ user `AWS_SECRET_ACCESS_KEY` }}", - "region": "us-east-1", - "source_ami": "ami-10b68a78", - "instance_type": "t1.micro", - "ssh_username": "ubuntu", - "ami_name": "packer-app-server {{timestamp}}" - }, - { - "type": "googlecompute", - "account_file": "account.json", - "project_id": "devops-intro-project", - "source_image": "ubuntu-1404-trusty-v20150316", - "zone": "us-central1-a", - "image_name": "application-ubuntu-1404-{{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 + "output": "{{.Provider}}/{{ user `PACKER_BOX_NAME` }}-appserver_{{.Provider}}.box", + "type": "vagrant" } + ] ], - "provisioners": [ { - "type": "shell", "execute_command": "echo 'vagrant'|{{.Vars}} sudo -S -E bash '{{.Path}}'", "scripts": [ "scripts/update.sh" - ] + ], + "type": "shell" }, { - "type": "shell", - "only": ["virtualbox-iso"], - "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'", - "scripts": [ + "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'", + "only": [ + "virtualbox-iso" + ], + "scripts": [ "scripts/virtualbox.sh", "scripts/vagrant.sh" - ] + ], + "type": "shell" }, { - "type": "shell", "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'", "scripts": [ "scripts/application.sh", "scripts/cleanup.sh" - ] + ], + "type": "shell" } ], - "post-processors": [ - [ - { - "type": "vagrant", - "except": ["googlecompute", "digitalocean"], - "compression_level": "9", - "output": "{{.Provider}}/{{ user `PACKER_BOX_NAME` }}-appserver_{{.Provider}}.box" - } - ] - ] + "variables": { + "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`}}", + "PACKER_BOX_NAME": "ubuntu-14.04.6-server-amd64", + "PACKER_OS_FLAVOUR": "ubuntu" + } } +