Skip to content

Commit 937ad0b

Browse files
committed
Merge branch 'lorcanrae/poc-main-corrections' of github.com:lewagon/data-engineering-setup into lorcanrae/poc-main-corrections
2 parents a2e8928 + b8ee1fc commit 937ad0b

File tree

3 files changed

+317
-140
lines changed

3 files changed

+317
-140
lines changed

LINUX.md

Lines changed: 103 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,29 @@ A part of the setup will be done on your **local machine** but most of the confi
66

77
Please **read instructions carefully and execute all commands in the following order**. If you get stuck, don't hesitate to ask a teacher for help :raising_hand:
88

9-
This setup is largely automated with **Terraform** and **Ansible**. There are three main components to the setup! **Terraform** and **ansible** are _Infrastructure as Code_ tools.
9+
This setup is largely automated with [**Terraform** 🔗](https://developer.hashicorp.com/terraform) and [**Ansible** 🔗](https://docs.ansible.com/). **Terraform** and **ansible** are [_Infrastructure as Code_ 🔗](https://en.wikipedia.org/wiki/Infrastructure_as_code) tools.
1010
- **Terraform** excels at creating and destroying cloud resources, like virtual machines, IP addresses, databases and more!
11-
- **Ansible** is used to configure linux machines with specific settings and software. Perfect for fine-tuning the Virtual Machine you will be creating!
11+
- **Ansible** is used to configure linux machines with specific settings and software. Perfect for fine-tuning the Virtual Machine you will be creating with Terraform!
12+
13+
There are three main components to the setup!
1214

1315
## Part 1: Setup your local computer
1416

15-
In this section you'll setup your local computer and create some accounts. It will include things like:
16-
1. Install some communication tools: Zoom, Slack
17+
In this section you'll setup your local computer and create some accounts. It will include:
18+
1. Installing the primary communication tool you'll use on the bootcamp: **Slack**!
1719
2. Create some accounts: Github, Google Cloud Platform (GCP)
18-
3. Install Visual Studio Code (VS Code)
20+
3. Install **Visual Studio Code (VS Code)**
1921
4. Install and authentication the GCP command line tool: `gcloud`
20-
5. Install **terraform** on your local computer
21-
6. Create your virtual machine with **terraform** and connect to it with **VS Code**!
22+
5. Install **Terraform** on your local computer
23+
6. Create your virtual machine with **Terraform** and connect to it with **VS Code**!
2224

2325
## Part 2: Configure your Virtual Machine Part 1
2426

2527
All parts of this section happen on your virtual machine.
2628

2729
This section includes:
2830
1. Authenticate your virtual machine with `gcloud`
29-
2. Download and run an **ansible** playbook to partially configure your virtual machine
31+
2. Download and run an **Ansible** playbook to partially configure your virtual machine
3032
3. Login to the Github command line tool on your virtual machine
3133
4. Copy the Le Wagon recommended **dotfiles**. **Dotfiles** are settings that will enhance your terminal and developer experience!
3234

@@ -35,15 +37,18 @@ This section includes:
3537
All parts of this section happen on your virtual machine.
3638

3739
In this section you will:
38-
1. Download and run a second **ansible** playbook for some more fine tuning
40+
1. Download and run a second **Ansible** playbook for some more VM fine tuning
3941
2. Test your set up to make sure that everything has installed correctly
4042
3. Create isolated python environments for all your challenges
4143

42-
4344
Don't worry, we'll go into more detail in each of the individual sections.
4445

4546
Let's start :rocket:
4647

48+
---
49+
50+
# Part 1: Local Setup
51+
4752

4853
## Slack
4954

@@ -225,24 +230,31 @@ Once the verification goes through, you should receive an email stating that "Yo
225230

226231
## GCP APIs
227232

228-
You will use different GCP services during the bootcamp which needs to be activated and configured.
233+
When you create a GCP Project, not every service is enabled by default. To enable a service (like using a VM or storing a Docker image in Artifact Registry) you have to enable the GCP API for that service.
229234

230235
### Default APIs
231236

232-
Go to your project [APIs dashboard](https://console.cloud.google.com/apis/dashboard), you can see a bunch of APIs are already enabled:
237+
Go to your project [APIs dashboard 🔗](https://console.cloud.google.com/apis/dashboard), you can see a bunch of APIs are already enabled:
233238

234239
<img alt='GCP APIs dashboard' src="images/gcp_apis_dashboard.png" width=200>
235240

236-
### Enable Compute Engine (virtual machines) API
241+
### Enable additional APIs
242+
243+
You'll need to enable some additional API's so that Terraform can create cloud resources on your behalf.
244+
245+
**Cloud Resource Manager**
237246

238-
**👌 Note: Skip to the next section if you already have Compute Engine enabled**
247+
On the [APIs dashboard 🔗](https://console.cloud.google.com/apis/dashboard) page, click on [Enable APIs and services 🔗](https://console.cloud.google.com/apis/library) and make sure your project is selected in the box in the top left.
239248

240-
- In the search bar, type _compute_ and click on the Compute Engine result
241-
<img alt='APIs search' src="images/gcp_apis_search.png" width=500>
242-
- Click on `ENABLE`
249+
In the search box, search for: _cloud resource manager api_ and select the **Cloud Resource Manager API**. On the next page, click on **Enable**.
243250

244-
<img alt='APIs enable' src="images/gcp_apis_enable.png" width=300>
245-
- Compute Engine is now enabled on your project
251+
**Service Usage**
252+
253+
Navigate back to the [APIs and Services 🔗](https://console.cloud.google.com/apis/library) page and search for: _service usage api_ and select the top result: **Service Usage API**. On the next page, click on **Enable**. ❗ This API might already enabled - not a problem if it is!
254+
255+
**Compute Engine**
256+
257+
Navigate back to the [APIs and Services 🔗](https://console.cloud.google.com/apis/library) page and search for: _compute engine api_ and select: **Compute Engine API**. On the next page, click on **Enable**. ❗ This API might already enabled - not a problem if it is!
246258

247259

248260
## Visual Studio Code
@@ -315,6 +327,9 @@ The `gcloud` Command Line Interface (CLI) is used to communicate with Google Clo
315327

316328
### Install gcloud
317329

330+
331+
332+
318333
Add the `APT` repository and install with:
319334

320335
```bash
@@ -333,6 +348,7 @@ gcloud --version
333348
👉 [Install documentation 🔗](https://cloud.google.com/sdk/docs/install#deb)
334349

335350

351+
336352
### Authenticate gcloud
337353

338354
We need to authenticate the `gcloud` CLI tool and set the project so it can interact with Google from the terminal.
@@ -388,6 +404,9 @@ And follow the prompts. It should open a web-page to login to your Google accoun
388404

389405
Terraform is a tool for infrastructure as code (IAC) to create (and destroy) resources to create in the cloud.
390406

407+
408+
409+
391410
Install some basic requirements:
392411
```bash
393412
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
@@ -418,12 +437,28 @@ sudo apt update
418437
sudo apt-get install terraform
419438
```
420439

440+
421441
Verify the installation with:
422442

423443
```bash
424444
terraform --version
425445
```
426446

447+
The output should look similar to:
448+
449+
```bash
450+
Terraform v1.14.3
451+
on <your_operating_system>_<your_cpu_architecture>
452+
453+
# Windows example
454+
# Terraform v1.14.3
455+
# on windows_amd64
456+
457+
# Linux example
458+
# Terraform v1.14.3
459+
# on linux_amd64
460+
```
461+
427462

428463
## Provisioning your Virtual Machine with Terraform
429464

@@ -445,37 +480,54 @@ The specifications of the Virtual Machine and Network Settings you'll use for th
445480

446481
### Cost 💸
447482

448-
Creating and running a Virtual Machine on Google Cloud Platform costs money!
483+
Creating and running a Virtual Machine on Google Cloud Platform costs money! 💸
449484

450485
If you have created a new Google Cloud Platform account, the cost of the Virtual machine will be covered by the $300 USD credit for the first 90 days if you are diligent with turning off your Virtual Machine (or finish the _Linux and Bash_ challenge today 😎).
451486

452487
**The cost of running a Virtual Machine with our configuration 24 hours a day, 7 days a week is ~$150 USD per month.**
453488

454-
You can massively reduce the cost by only running the Virtual Machine when you use it. You will _NOT_ be charged for the vCPU's and RAM while the Virtual Machine is off!
489+
You can massively reduce the cost by only running the Virtual Machine when you use it. You will **NOT** be charged for the vCPU's and RAM while the Virtual Machine is off!
455490

456491
You will always pay for the Storage (equivalent of your hard-drive on your local computer). It's ~$10 USD per month for 100 GB.
457492

458-
The rule of thumb is: if Google can rent the resource out to someone else when your not using it, you only pay for it when you are using the resource. That's why you don't pay for the CPU and RAM when you are not using it, Google can rent it out to someone else, but always pay for Storage, Google can't rent it out to someone else because it has your data on it.
493+
💡 A rule of thumb is: if a cloud provider can rent the resource out to someone else when your not using it, you only pay for it when you are using the resource. That's why you don't pay for the CPU and RAM when you are not using it, Google can rent it out to someone else - but will always pay for Storage, Google can't rent it out to someone else because it has your data on it.
459494

460495
### Download terraform files
461496

462497
We almost have all the necessary parts to create your VM using **terraform**. We need to download the terraform files and change a few values.
463498

464499
First we'll create a folder and download the terraform files with:
465500

501+
502+
503+
466504
```bash
467505
mkdir -p ~/code/wagon-de-bootcamp
468-
curl -L -o ~/wagon-de-bootcamp/main.tf https://raw.githubusercontent.com/lewagon/data-engineering-setup/lorcanrae/automated-setup/automation/infra/main.tf
469-
curl -L -o ~/wagon-de-bootcamp/provider.tf https://raw.githubusercontent.com/lewagon/data-engineering-setup/lorcanrae/automated-setup/automation/infra/provider.tf
470-
curl -L -o ~/wagon-de-bootcamp/variables.tf https://raw.githubusercontent.com/lewagon/data-engineering-setup/lorcanrae/automated-setup/automation/infra/variables.tf
471-
curl -L -o ~/wagon-de-bootcamp/terraform.tfvars https://raw.githubusercontent.com/lewagon/data-engineering-setup/lorcanrae/automated-setup/automation/infra/terraform.tfvars
472-
curl -L -o ~/wagon-de-bootcamp/.terraform.lock.hcl https://raw.githubusercontent.com/lewagon/data-engineering-setup/lorcanrae/automated-setup/automation/infra/.terraform.lock.hcl
506+
```
507+
```bash
508+
curl -L -o ~/code/wagon-de-bootcamp/main.tf https://raw.githubusercontent.com/lewagon/data-engineering-setup/main-automation/automation/infra/main.tf
509+
```
510+
```bash
511+
curl -L -o ~/code/wagon-de-bootcamp/provider.tf https://raw.githubusercontent.com/lewagon/data-engineering-setup/main-automation/automation/infra/provider.tf
512+
```
513+
```bash
514+
curl -L -o ~/code/wagon-de-bootcamp/variables.tf https://raw.githubusercontent.com/lewagon/data-engineering-setup/main-automation/automation/infra/variables.tf
515+
```
516+
```bash
517+
curl -L -o ~/code/wagon-de-bootcamp/terraform.tfvars https://raw.githubusercontent.com/lewagon/data-engineering-setup/main-automation/automation/infra/terraform.tfvars
518+
```
519+
```bash
520+
curl -L -o ~/code/wagon-de-bootcamp/.terraform.lock.hcl https://raw.githubusercontent.com/lewagon/data-engineering-setup/main-automation/automation/infra/.terraform.lock.hcl
473521
```
474522

475523

476524
### Set variables
477525

478-
Open up the file `~/wagon-de-bootcamp/terraform.tfvars` in VS Code or any other code editor.
526+
527+
528+
529+
Open up the file `~/code/wagon-de-bootcamp/terraform.tfvars` in VS Code or any other code editor.
530+
479531

480532
It should look like:
481533

@@ -494,7 +546,7 @@ We'll need to change some values in this file. Here's were you can find the requ
494546
- **instance_name:** we recommend naming your VM: `lw-de-vm-<YOUR_GITHUB_USERNAME>`. Replacing `<YOUR_GITHUB_USERNAME>` with your GitHub username.
495547
- **instance_user:** in your terminal, run `whoami`
496548

497-
After completing this file, it should look similar to:
549+
After completing this file, it might look similar to:
498550

499551
```bash
500552
project_id = "wagon-bootcamp"
@@ -504,31 +556,35 @@ instance_name = "lw-de-vm-tswift"
504556
instance_user = "taylorswift"
505557
```
506558

507-
Make sure to save the `terraform.tfvars` file, nagivate into the directory with the terraform files with:
559+
Make sure to save the `terraform.tfvars` file, navigate into the directory with the terraform files using your terminal with:
508560

509-
```
510-
cd ~/wagon-de-bootcamp
561+
```bash
562+
cd ~/code/wagon-de-bootcamp
511563
```
512564

513-
And initialise and test the files with:
565+
Initialise and test the terraform config files with:
514566

515567
```bash
516568
terraform init
569+
```
517570

571+
Then:
572+
573+
```bash
518574
terraform plan
519575
```
520576

521577
And check the output. Towards the bottom there should be a line:
522578

523-
```
579+
```bash
524580
Plan: 2 to add, 0 to change, 0 to destroy
525581
```
526582

527-
We'll be adding:
583+
Terraform is telling you what it will create:
528584
- A compute engine instance
529585
- A static external IP address
530586

531-
❗ If you have any errors, read the error and debug. If you need some help, raise a ticket with a teacher.
587+
**❗ If you have any errors, read the error and debug. If you need some help, raise a ticket with a teacher.**
532588

533589
If everything was successful, create your VM with:
534590

@@ -538,11 +594,11 @@ terraform apply -auto-approve
538594

539595
It might take a while for Terraform to create the cloud resources. Once you see:
540596

541-
```
597+
```bash
542598
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
543599
```
544600

545-
Your Virtual Machine should be up and running! Check the GCP Compute Engine console at this [link here](https://console.cloud.google.com/compute/instances) to confirm.
601+
Your Virtual Machine should be up and running! Check the GCP Compute Engine console at this [link here 🔗](https://console.cloud.google.com/compute/instances) to confirm.
546602

547603

548604
## Virtual Machine connection
@@ -592,8 +648,6 @@ And you are connected! It should look similar too:
592648

593649
Notice the connection in the very bottom-left corner of your VS Code window. It should have the Connection type (SSH), and the name of the host you are connected to.
594650

595-
**The setup of your local machine is over. All following commands will be run from within your 🚨 virtual machine**🚨 terminal (via VS Code)
596-
597651
<details>
598652
<summary markdown='span'>Viewing your SSH Configuration</summary>
599653

@@ -606,6 +660,12 @@ If you want to view your SSH configuration:
606660

607661
</details>
608662

663+
🚨🚨🚨 **The setup of your local machine is complete. All following terminal commands will be run from within your virtual machine terminal (via VS Code)** 🚨🚨🚨
664+
665+
---
666+
667+
# Part 2: Configure your Virtual Machine - Part 1
668+
609669

610670
## VM gcloud and Application Default Credentials
611671

@@ -676,7 +736,7 @@ ansible --version
676736
You should get an output similar to (some version numbers might change, that's fine):
677737

678738
```
679-
ansible [core 2.17.9]
739+
ansible [core 2.19.5]
680740
config file = /etc/ansible/ansible.cfg
681741
configured module search path = ['/home/tswift/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
682742
ansible python module location = /usr/lib/python3/dist-packages/ansible
@@ -687,7 +747,7 @@ ansible [core 2.17.9]
687747
libyaml = True
688748
```
689749

690-
❗ If not, raise a ticket with a teacher.
750+
❗ If not, raise a ticket with a teacher 🙋
691751

692752
### Ansible Playbook 1
693753

@@ -710,7 +770,7 @@ ansible-playbook playbooks/setup_vm_part1.yml
710770

711771
And the playbook should start running!
712772

713-
❗ If an errors occur, raise a ticket with a teacher. You can safely run the playbook again.
773+
❗ If an errors occur, raise a ticket with a teacher. You can safely run the ansible playbook again.
714774

715775
### What is the playbook installing?
716776

0 commit comments

Comments
 (0)