docs: week 2 docs
This commit is contained in:
111
week-2/opdracht-2/README.md
Normal file
111
week-2/opdracht-2/README.md
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
# Terraform Deployment – Week 2 Assignment
|
||||||
|
|
||||||
|
This repository contains Terraform configurations for provisioning infrastructure on ESXi and Azure.
|
||||||
|
|
||||||
|
All sensitive information (e.g. SSH key files, passwords) and custom values are handled using Terraform variables stored in a separate file.
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph TD
|
||||||
|
subgraph ESXi omgeving
|
||||||
|
ESXiNIC[NIC]:::existing
|
||||||
|
ESXivSwitch[vSwitch]
|
||||||
|
Portgroup[Portgroup]
|
||||||
|
ESXivSwitch --> ESXiNIC
|
||||||
|
ESXiNIC --> Portgroup
|
||||||
|
|
||||||
|
Web1[Webserver 1]
|
||||||
|
Web2[Webserver 2]
|
||||||
|
DB[Databaseserver]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Portgroup --> Web1
|
||||||
|
Portgroup --> Web2
|
||||||
|
Portgroup --> DB
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph Azure
|
||||||
|
VNet[Virtual Network]
|
||||||
|
Subnet[Subnet]
|
||||||
|
NIC[NIC]
|
||||||
|
NSG["NSG (SSH open)"]
|
||||||
|
VM[Linux VM]
|
||||||
|
PIP[Public IP]
|
||||||
|
|
||||||
|
VNet --> Subnet
|
||||||
|
Subnet --> NIC
|
||||||
|
NIC --> VM
|
||||||
|
NSG --> NIC
|
||||||
|
VM --> PIP
|
||||||
|
end
|
||||||
|
|
||||||
|
subgraph Data
|
||||||
|
AzurePublicKey["SSH Public Key (azure.pub)"]
|
||||||
|
AzurePrivateKey["SSH Private Key (azure)"]
|
||||||
|
SkylabPublicKey["SSH Public Key (skylab.pub)"]
|
||||||
|
Userdata[Userdata]
|
||||||
|
AzureCloudInit[Azure Cloudinit]
|
||||||
|
VMinfo["Output file: vm_info.txt"]
|
||||||
|
end
|
||||||
|
|
||||||
|
SkylabPublicKey --> Userdata
|
||||||
|
AzurePrivateKey --> Userdata
|
||||||
|
AzurePublicKey --> AzureCloudInit
|
||||||
|
Userdata --> Web1
|
||||||
|
Userdata --> Web2
|
||||||
|
Userdata --> DB
|
||||||
|
AzureCloudInit --> VM
|
||||||
|
|
||||||
|
Web1 --> VMinfo
|
||||||
|
Web2 --> VMinfo
|
||||||
|
DB --> VMinfo
|
||||||
|
VM --> VMinfo
|
||||||
|
|
||||||
|
classDef existing stroke:#268b26
|
||||||
|
```
|
||||||
|
|
||||||
|
## Azure
|
||||||
|
|
||||||
|
- Complete network setup:
|
||||||
|
- Virtual Network
|
||||||
|
- Subnet
|
||||||
|
- Network Security Group
|
||||||
|
- NIC
|
||||||
|
- One Ubuntu 24.04 VM.
|
||||||
|
- VM type: `Standard_B2ats_v2`
|
||||||
|
- Public IP address enabled
|
||||||
|
- The `iac` user is created using cloud-init
|
||||||
|
- `azure.pub` is uploaded as public key.
|
||||||
|
- A file `/home/iac/hello.txt` containing `Hello World` is created using cloud-init
|
||||||
|
- VM public and private IP address is stored in the `vm_info.txt` file.
|
||||||
|
|
||||||
|
## ESXi
|
||||||
|
|
||||||
|
- Creates three Ubuntu 24.04 VMs.
|
||||||
|
- 2 `webserver`
|
||||||
|
- 1 `databaseserver`
|
||||||
|
- Each VM is provisioned with 1 vCPU and 2 GB RAM.
|
||||||
|
- The `skylab` user is created using cloud-init
|
||||||
|
- `skylab.pub` is uploaded as public key.
|
||||||
|
- `azure` private key us uploaded to access the Azure VM.
|
||||||
|
- A SSH config file is created with info for connecting to the Azure VM.
|
||||||
|
- sudo access.
|
||||||
|
- no password prompt.
|
||||||
|
- The packages `wget` and `ntpdate` are installed with cloud-init.
|
||||||
|
- VM private IP addresses are stored in the `vm_info.txt` file.
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This demo shows:
|
||||||
|
|
||||||
|
1. Applying the Terraform plan
|
||||||
|
- `terraform apply --auto-approve`
|
||||||
|
- This shows the ip addresses of the VM's in the output.
|
||||||
|
2. Opening an SSH session to one of the ESXi VMs
|
||||||
|
- `ssh -i /home/student/.ssh/skylab skylab@192.168.1.115`
|
||||||
|
3. Opening an SSH session to one of the Azure VMs
|
||||||
|
- `ssh azurevm` (using SSH config file)
|
||||||
|
4. Showing the content of the `hello.txt` file.
|
||||||
|
- `cat hello.txt`
|
BIN
week-2/opdracht-2/iac-week-2.gif
Normal file
BIN
week-2/opdracht-2/iac-week-2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 MiB |
Reference in New Issue
Block a user