From c279aecf6e3087375e3f3e4f6729344d72b9a735 Mon Sep 17 00:00:00 2001 From: Osoraa Date: Mon, 14 Feb 2022 13:14:36 +0100 Subject: [PATCH 1/4] Fix the 'Deprecated configuration key: 'iso_checksum_type' error' --- packer-templates/application-server.json | 214 ++++++++++++----------- 1 file changed, 114 insertions(+), 100 deletions(-) diff --git a/packer-templates/application-server.json b/packer-templates/application-server.json index 480d71b..280687c 100644 --- a/packer-templates/application-server.json +++ b/packer-templates/application-server.json @@ -1,124 +1,138 @@ { - "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" + }, + { + "account_file": "account.json", + "image_name": "application-ubuntu-1404-{{timestamp}}", + "machine_type": "n1-standard-1", + "project_id": "devops-intro-project", + "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" + } } + From 032661c5a960f9f126fa04697f29c7cad05ccceb Mon Sep 17 00:00:00 2001 From: Osoraa Date: Mon, 14 Feb 2022 14:19:56 +0100 Subject: [PATCH 2/4] Fix markdown formatting error in README.md --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 28e1b6f..0fafe73 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. @@ -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. From 2fb61790d904b99147be6596b892b06ef9d14bc1 Mon Sep 17 00:00:00 2001 From: Osoraa Date: Wed, 16 Feb 2022 03:00:44 +0100 Subject: [PATCH 3/4] Modify required files to be able to run on gcloud and aws --- README.md | 2 +- packer-templates/account.json | 12 ++++++++++++ packer-templates/application-server.json | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 packer-templates/account.json diff --git a/README.md b/README.md index 0fafe73..232842a 100644 --- a/README.md +++ b/README.md @@ -27,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` diff --git a/packer-templates/account.json b/packer-templates/account.json new file mode 100644 index 0000000..647f2e1 --- /dev/null +++ b/packer-templates/account.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "udacity-devops-341410", + "private_key_id": "968c0c039fd75f199e48fc4a19e6d54679e8bd9c", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDNoh3XIzlrZb91\n1dS2AEJo3dzvdACiZ21Kp8dL9uvg/3zpxBRyfbbg5PVFacu22Xr2YlMjmrTNO2bo\nQlUP5uM0GMAZZo3CfFQsROlROUrJPA2j3w2/4vduJk1fZBcmJT+fen+3l1UBZmG0\nS/YA72hcplpUAjihpPM9/HiFD4SpqEd1xrG3X3sJMcU0QBMdN9lHwcMxE46faMki\nG5iUP8qmJnhivj2Bsd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bLMshU0+/0N0M47kuZVOL+nDm\nVSLFD2PnOduW84C9xYK9sHMj83q35rGL1pLrJxFzFp1c6x7D+nIE3lKDOrqpa/9k\n5RGyTbRcOl2KQU6DCtrTjwqU85rNhAeff+0X4vcCgYBn4DuarxTfmkpWqhrBSq0K\n6y+uG7Lo7hd5Jghyn3fr3MZw2AaYgnhxn3bCmrjf8DyGjtbsXDxrVHGrpAxvMrIx\nVhiF79PJ5uqaJtH46LVktismLBIea1a1Nl9KCI3d1ASZ55Vw5nhaZ4xzMWrKhbL3\nlfDBIobXegbCXa5Ex1yvcQ==\n-----END PRIVATE KEY-----\n", + "client_email": "udacity-devops@udacity-devops-341410.iam.gserviceaccount.com", + "client_id": "103244103713398041061", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/udacity-devops%40udacity-devops-341410.iam.gserviceaccount.com" +} diff --git a/packer-templates/application-server.json b/packer-templates/application-server.json index 280687c..47767b7 100644 --- a/packer-templates/application-server.json +++ b/packer-templates/application-server.json @@ -64,13 +64,14 @@ "secret_key": "{{ user `AWS_SECRET_ACCESS_KEY` }}", "source_ami": "ami-10b68a78", "ssh_username": "ubuntu", - "type": "amazon-ebs" + "type": "amazon-ebs", + "skip_create_ami": true }, { "account_file": "account.json", "image_name": "application-ubuntu-1404-{{timestamp}}", "machine_type": "n1-standard-1", - "project_id": "devops-intro-project", + "project_id": "udacity-devops-341410", "source_image": "ubuntu-1404-trusty-v20150316", "ssh_username": "ubuntu", "type": "googlecompute", From 62062140fe99d9cde3b298cebe1569ef7a609dc5 Mon Sep 17 00:00:00 2001 From: Osoraa Date: Wed, 16 Feb 2022 11:32:56 +0100 Subject: [PATCH 4/4] Delete account.json --- packer-templates/account.json | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 packer-templates/account.json diff --git a/packer-templates/account.json b/packer-templates/account.json deleted file mode 100644 index 647f2e1..0000000 --- a/packer-templates/account.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "udacity-devops-341410", - "private_key_id": "968c0c039fd75f199e48fc4a19e6d54679e8bd9c", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDNoh3XIzlrZb91\n1dS2AEJo3dzvdACiZ21Kp8dL9uvg/3zpxBRyfbbg5PVFacu22Xr2YlMjmrTNO2bo\nQlUP5uM0GMAZZo3CfFQsROlROUrJPA2j3w2/4vduJk1fZBcmJT+fen+3l1UBZmG0\nS/YA72hcplpUAjihpPM9/HiFD4SpqEd1xrG3X3sJMcU0QBMdN9lHwcMxE46faMki\nG5iUP8qmJnhivj2BsdAscLBsbWeZBRfckcUikEEswujplF9bsxfYcdfDH/Chl8+Q\ny2Sacg2b5j8vTffz3zJh2stWBu1gsgtUjCfzhD8xY1P4Ay+87+19wqsyqzfYgNpU\nWbVtSrj1AgMBAAECggEALy7DFRGmg6+JgmKpl4cwtboujxz5ZkpACBC+SH5kOjC1\nOzg8DtcspqayZpZzYUW+kpkWBYXidXLrVmCd/vOV72a8cTeYUGdRswSu2m3AbLMk\nWBT+pShRaMtOFpSzQRPr6M5lTr1hClyxD3sce7NzKUscT8lgsCpWi8MJ7lIUuQ6T\n20Sce6NIWgDQkNMaTfXHWlYoiFqHE8A0LxCXPaZu9T+ZQ+fTCJHvecN3mDm2QEwG\ngHIwPDd+tgjXY+hpTWTFgc8VpANPV2xOZ99eiepGnb+qgNiO/A0yuJ8bDpz0NQtX\nnBuzrmidTpZ86SJ9bpe5c9pbSGDycICiqr5QU8s/kwKBgQDsuUslVVs0mvdyU+hP\nt53zYQHfkblHSYnIQ/gAorwj2+ZTSsKWZXhw9w1LTWx5INt9nSVb6nnJdTWUuUhf\ny3pQ2JgAACFFdR1wKBkIjJqNKi/EachYonfycXGKHakR1bMgO3AJ5KAySdgoYSlX\nx/AbR8MRX+SwNUO11JMyMQXxuwKBgQDeYLb3fF2RFb4BB9POphQb2Uq0uInuKI6B\nijScyF0xNb+R8hyCpXtDT6hNb/KzI+Wg8n0BpWMaVtqwC+cXxDZPf1FAMcWBEbSB\nIXRkso2d2CrnNNdvP6CF0U+hZObJGOzGy4aSns69tqDb5+VZyjtpytFi+ebI/EyW\nzRCxqIg9DwKBgGxgWJr6/QqUd/0LlSwJ8HJgUy871AtjC4V4OK5x0pjIMCap73RT\neFSfhqKXC7ZY6KQVsejm7GLjGmjAevYAfjtNLimx5YmbGKMkeHGFjaxbSAswMt0B\nZNDGRyjoc2MK5zs2exDMbtsXG7NA6GCb1L1omVH3CQfzGtDARbOQ5hvJAoGAbdHb\nadssJhNTsxSXgE06Twp/P0KHM2sp/UUweGDmzP+bLMshU0+/0N0M47kuZVOL+nDm\nVSLFD2PnOduW84C9xYK9sHMj83q35rGL1pLrJxFzFp1c6x7D+nIE3lKDOrqpa/9k\n5RGyTbRcOl2KQU6DCtrTjwqU85rNhAeff+0X4vcCgYBn4DuarxTfmkpWqhrBSq0K\n6y+uG7Lo7hd5Jghyn3fr3MZw2AaYgnhxn3bCmrjf8DyGjtbsXDxrVHGrpAxvMrIx\nVhiF79PJ5uqaJtH46LVktismLBIea1a1Nl9KCI3d1ASZ55Vw5nhaZ4xzMWrKhbL3\nlfDBIobXegbCXa5Ex1yvcQ==\n-----END PRIVATE KEY-----\n", - "client_email": "udacity-devops@udacity-devops-341410.iam.gserviceaccount.com", - "client_id": "103244103713398041061", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/udacity-devops%40udacity-devops-341410.iam.gserviceaccount.com" -}