Add Terraform and Linux questions and exercises

Also updated the script that counts questions to actually update
the number in README.md
This commit is contained in:
abregman 2022-10-30 21:49:50 +02:00
parent a85e52e64e
commit e6a80309e0
16 changed files with 529 additions and 65 deletions

View File

@ -2,7 +2,7 @@
:information_source:  This repo contains questions and exercises on various technical topics, sometimes related to DevOps and SRE
:bar_chart:  There are currently **2538** exercises and questions
:bar_chart:  There are currently **2557** exercises and questions
:warning:  You can use these for preparing for an interview but most of the questions and exercises don't represent an actual interview. Please read [FAQ page](faq.md) for more details
@ -23,7 +23,7 @@
<td align="center"><a href="topics/git/README.md"><img src="images/git.png" width="75px;" height="75px;" alt="Git"/><br /><b>Git</b></a></td>
<td align="center"><a href="topics/ansible/README.md"><img src="images/ansible.png" width="75px;" height="75px;" alt="ansible"/><br /><b>Ansible</b></a></td>
<td align="center"><a href="#network"><img src="images/network.png" width="75px;" height="75px;" alt="Network"/><br /><b>Network</b></a></td>
<td align="center"><a href="topics/linux/README.md"><img src="images/logos/linux.png" width="75px;" height="75px;" alt="Linux"/><br /><b>Linux</b></a></td>
</tr>
<tr>
@ -32,7 +32,7 @@
<td align="center"><a href="https://github.com/bregman-arie/go-exercises"><img src="images/Go.png" width="75px;" height="75px;" alt="go"/><br /><b>Go</b></a></td>
<td align="center"><a href="topics/shell/README.md"><img src="images/bash.png" width="75px;" height="75px;" alt="Bash"/><br /><b>Shell Scripting</b></a></td>
<td align="center"><a href="topics/kubernetes/README.md"><img src="images/kubernetes.png" width="75px;" height="75px;" alt="kubernetes"/><br /><b>Kubernetes</b></a></td>
<td align="center"><a href="#prometheus"><img src="images/prometheus.png" width="75px;" height="75px;" alt="Prometheus"/><br /><b>Prometheus</b></a></td>
</tr>
<tr>
<td align="center"><a href="topics/cloud/README.md"><img src="images/cloud.png" width="75px;" height="75px;" alt="Cloud"/><br /><b>Cloud</b></a></td>
@ -40,7 +40,6 @@
<td align="center"><a href="topics/azure/README.md"><img src="images/azure.png" width="75px;" height="75px;" alt="azure"/><br /><b>Azure</b></a></td>
<td align="center"><a href="topics/gcp/README.md"><img src="images/googlecloud.png" width="70px;" height="70px;" alt="Google Cloud Platform"/><br /><b>Google Cloud Platform</b></a></td>
<td align="center"><a href="#openstack"><img src="images/openstack.png" width="75px;" height="75px;" alt="openstack"/><br /><b>OpenStack</b></a></td>
<td align="center"><a href="topics/security/README.md"><img src="images/security.png" width="75px;" height="75px;" alt="security"/><br /><b>Security</b></a></td>
</tr>
<tr>
<td align="center"><a href="#operating-system"><img src="images/os.png" width="75px;" height="75px;" alt="Operating System"/><br /><b>Operating System</b></a></td>
@ -48,7 +47,6 @@
<td align="center"><a href="#elastic"><img src="images/elastic.png" width="75px;" height="75px;" alt="Elastic"/><br /><b>Elastic</b></a></td>
<td align="center"><a href="#virtualization"><img src="images/virtualization.png" width="75px;" height="75px;" alt="Virtualization"/><br /><b>Virtualization</b></a></td>
<td align="center"><a href="topics/dns/README.md"><img src="images/dns.png" width="75px;" height="75px;" alt="DNS"/><br /><b>DNS</b></a></td>
<td align="center"><a href="#Misc"><img src="images/general.png" width="75px;" height="75px;" alt="Misc"/><br /><b>Misc</b></a></td>
</tr>
<tr>
<td align="center"><a href="#testing"><img src="images/testing.png" width="75px;" height="75px;" alt="Testing"/><br /><b>Testing</b></a></td>
@ -56,7 +54,6 @@
<td align="center"><a href="#regex"><img src="images/regex.png" width="75px;" height="75px;" alt="RegEx"/><br /><b>Regex</b></a></td>
<td align="center"><a href="#system-design"><img src="images/design.png" width="75px;" height="75px;" alt="Design"/><br /><b>System Design</b></a></td>
<td align="center"><a href="#hardware"><img src="images/hardware.png" width="75px;" height="75px;" alt="Hardware"/><br /><b>Hardware</b></a></td>
<td align="center"><a href="#big-data"><img src="images/big-data.png" width="75px;" height="75px;" alt="Big Data"/><br /><b>Big Data</b></a></td>
</tr>
<tr>
<td align="center"><a href="#certificates"><img src="images/certificates.png" width="75px;" height="75px;" alt="Certificates"/><br /><b>Certificates</b></a></td>
@ -64,7 +61,6 @@
<td align="center"><a href="#sql"><img src="images/sql.png" width="75px;" height="75px;" alt="sql"/><br /><b>SQL</b></a></td>
<td align="center"><a href="topics/openshift/README.md"><img src="images/openshift.png" width="75px;" height="75px;" alt="OpenShift"/><br /><b>OpenShift</b></a></td>
<td align="center"><a href="#storage"><img src="images/storage.png" width="75px;" height="75px;" alt="Storage"/><br /><b>Storage</b></a></td>
<td align="center"><a href="topics/soft_skills/README.md"><img src="images/HR.png" width="75px;" height="75px;" alt="HR"/><br /><b>Soft Skills</b></a></td>
</tr>
<tr>
<td align="center"><a href="topics/terraform/README.md"><img src="images/terraform.png" width="75px;" height="75px;" alt="Terraform"/><br /><b>Terraform</b></a></td>
@ -72,14 +68,26 @@
<td align="center"><a href="#puppet"><img src="images/puppet.png" width="75px;" height="75px;" alt="puppet"/><br /><b>Puppet</b></a></td>
<td align="center"><a href="#distributed"><img src="images/distributed.png" width="75px;" height="75px;" alt="Distributed"/><br /><b>Distributed</b></a></td>
<td align="center"><a href="#questions-you-ask"><img src="images/you.png" width="75px;" height="75px;" alt="you"/><br /><b>Questions you can ask</b></a></td>
<td align="center"><a href="topics/perl/README.md"><img src="images/perl.png" width="75px;" height="75px;" alt="perl"/><br /><b>Perl</b></a></td>
</tr>
<tr>
<td align="center"><a href="topics/circleci/README.md"><img src="images/logos/circleci.png" width="70px;" height="70px;" alt="Circle CI"/><br /><b>Circle CI</b></a></td>
<td align="center"><a href="topics/argo/README.md"><img src="images/logos/argo.png" width="80px;" height="80px;" alt="Argo"/><br /><b>Argo</b></a></td>
<td align="center"><a href="topics/kafka/README.md"><img src="images/logos/kafka.png" width="70px;" height="80px;" alt="Kafka"/><br /><b>Kafka</b></a></td>
<td align="center"><a href="topics/kafka/README.md"><img src="images/logos/kafka.png" width="85px;" height="80px;" alt="Kafka"/><br /><b>Kafka</b></a></td>
<td align="center"><a href="topics/datadog/README.md"><img src="images/logos/datadog.png" width="80px;" height="80px;" alt="DataDog"/><br /><b></b></a></td>
<td align="center"><a href="topics/perl/README.md"><img src="images/perl.png" width="75px;" height="75px;" alt="perl"/><br /><b>Perl</b></a></td>
</tr>
<tr>
<td align="center"><a href="topics/linux/README.md"><img src="images/logos/linux.png" width="75px;" height="75px;" alt="Linux"/><br /><b>Linux</b></a></td>
<td align="center"><a href="#prometheus"><img src="images/prometheus.png" width="75px;" height="75px;" alt="Prometheus"/><br /><b>Prometheus</b></a></td>
<td align="center"><a href="#big-data"><img src="images/big-data.png" width="75px;" height="75px;" alt="Big Data"/><br /><b>Big Data</b></a></td>
<td align="center"><a href="topics/soft_skills/README.md"><img src="images/HR.png" width="75px;" height="75px;" alt="HR"/><br /><b>Soft Skills</b></a></td>
<td align="center"><a href="topics/security/README.md"><img src="images/security.png" width="75px;" height="75px;" alt="security"/><br /><b>Security</b></a></td>
</tr>
<tr>
<td align="center"><a href="topics/chaos_engineering/README.md"><img src="images/logos/chaos_engineering.png" width="75px;" height="75px;" alt="Chaos Engineering"/><br /><b>Chaos Engineering</b></a></td>
<td align="center"><a href="#Misc"><img src="images/general.png" width="75px;" height="75px;" alt="Misc"/><br /><b>Misc</b></a></td>
</tr>
</table>
</center>
<!-- markdownlint-enable -->
@ -89,35 +97,28 @@
## Network
<details>
<summary>What do you need in order to communicate?</summary><br><b>
<summary>In general, what do you need in order to communicate?</summary><br><b>
- A common language (for the two ends to understand)
- A way to address who do you want to communicate with
- A Connection (so the content of the communication can reach the recipients)
</b></details>
<details>
<summary>What is TCP/IP?</summary><br><b>
A set of protocols that define how two or more devices can communicate with each other.
To learn more about TCP/IP, read [here](http://www.penguintutor.com/linux/basic-network-reference)
</b></details>
<details>
<summary>What is APIPA?</summary><br><b>
APIPA is a set of it addresses that devices are allocated
when the main DHCP server is not reachable
</b></details>
<details>
<summary>What ip range does APIPA use?</summary><br><b>
APIPA uses the ip range: 169.254.0.1 - 169.254.255.254.
</b></details>
<details>
<summary>What is Ethernet?</summary><br><b>
Ethernet simply refers to the most common type of Local Area Network (LAN) used today. A LAN—in contrast to a WAN (Wide Area Network), which spans a larger geographical area—is a connected network of computers in a small area, like your office, college campus, or even home.
</b></details>
<details>
@ -416,7 +417,22 @@ For example, your computer's private IP could be 192.168.1.100, but your router
<summary>Which factors affect network performances</summary><br><b>
</b></details>
#### Network - Data and Control planes
<details>
<summary>What is APIPA?</summary><br><b>
APIPA is a set of it addresses that devices are allocated
when the main DHCP server is not reachable
</b></details>
<details>
<summary>What ip range does APIPA use?</summary><br><b>
APIPA uses the ip range: 169.254.0.1 - 169.254.255.254.
</b></details>
#### Control Plane and Data Plane
<details>
<summary>What "control plane" refers to?</summary><br><b>
@ -2887,9 +2903,8 @@ Google Drive
<summary>Explain MBR</summary><br><b>
</b></details>
## Questions you CAN ask
<a name="questions-you-ask"></a>
## Questions you CAN ask
A list of questions you as a candidate can ask the interviewer during or after the interview.
These are only a suggestion, use them carefully. Not every interviewer will be able to answer these (or happy to) which should be perhaps a red flag warning for your regarding working in such place but that's really up to you.
@ -3679,7 +3694,9 @@ If you are looking for a way to prepare for a certain exam this is the section f
* [Certified Kubernetes Administrator (CKA)](topics/kubernetes/CKA.md) (Latest update: 2022)
## Other DevOps Projects
## Additional DevOps and SRE Projects
<p align="center"><a href="https://github.com/bregman-arie/sre-checklist"><img width="500px" src="images/sre_checklist.png"/></a></p>
<p align="center"><a href="https://github.com/bregman-arie/howtheydevops"><img src="images/how_they_devops.png"/></a></p>
<p align="center"><a href="https://github.com/bregman-arie/devops-resources"><img src="images/devops_resources.png"/></a></p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
images/sre_checklist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,3 +1,9 @@
#!/usr/bin/env bash
echo $(( $(grep -E "\[Exercise\]|</summary>" -c README.md topics/*/README.md | awk -F: '{ s+=$2 } END { print s }' )))
set -eu
count=$(echo $(( $(grep -E "\[Exercise\]|</summary>" -c README.md topics/*/README.md | awk -F: '{ s+=$2 } END { print s }' ))))
echo "There are $count questions and exercises"
sed -i "s/currently \*\*[0-9]*\*\*/currently \*\*$count\\**/" README.md

View File

@ -0,0 +1,31 @@
# Chaos Engineering
- [Chaos Engineering](#chaos-engineering)
- [Chaos Engineering Questions](#chaos-engineering-questions)
- [Basics](#basics)
## Chaos Engineering Questions
### Basics
<details>
<summary>What is Chaos Engineering?</summary><br><b>
[Wikipedia](https://en.wikipedia.org/wiki/Chaos_engineering): "Chaos Engineering is the discipline of experimenting on a system in order to build confidence in the system's capability to withstand turbulent conditions in production."
[TechTarget](https://www.techtarget.com/searchitoperations/definition/chaos-engineering): "Chaos engineering is the process of testing a distributed computing system to ensure that it can withstand unexpected disruptions."
</b></details>
<details>
<summary>What's a typical Chaos Engineering workflow?</summary><br><b>
According to [Gremlin](gremlin.com) there are three steps:
1. Planning an experiment where you design and choose a scenario in which your system should fail to operate properly
2. You execute the smallest possible experiment to test your theory
3. If nothing goes wrong, you scale your experiment and make the blast radius bigger. If your system breaks, you better understand why and start dealing with it
The process then repeats itself either with same scenario or a new one.
</b></details>

View File

@ -2,46 +2,69 @@
## Linux Master Application
A completely free application for testing your knowledge on Linux
A completely free application for testing your knowledge on Linux.
Desclaimer: developed by repository owner
<a href="https://play.google.com/store/apps/details?id=com.codingshell.linuxmaster"><img src="images/linux_master.jpeg"/></a>
<a href="https://play.google.com/store/apps/details?id=com.codingshell.linuxmaster"><img src="../../images/linux_master.jpeg"/></a>
## Linux Self Assessment
- [Linux](#linux)
- [Linux Master Application](#linux-master-application)
- [Linux Exercises](#linux-exercises)
- [Basics](#basics)
- [Misc](#misc)
- [Linux Questions](#linux-questions)
- [Linux 101](#linux-101)
- [I/O Redirection](#io-redirection)
- [Filesystem Hierarchy Standard](#filesystem-hierarchy-standard)
- [Permissions](#permissions)
- [Scenarios](#scenarios)
- [Systemd](#systemd)
- [Troubleshooting and Debugging](#troubleshooting-and-debugging)
- [Scenarios](#scenarios-1)
- [Kernel](#kernel)
- [SSH](#ssh)
- [Globbing & Wildcards](#globbing--wildcards)
- [Boot Process](#boot-process)
- [Disk and Filesystem](#disk-and-filesystem)
- [Performance Analysis](#performance-analysis)
- [Processes](#processes)
- [Security](#security)
- [Networking](#networking)
- [DNS](#dns)
- [Packaging](#packaging)
- [DNF](#dnf)
- [Applications and Services](#applications-and-services)
- [Users and Groups](#users-and-groups)
- [Hardware](#hardware)
- [Namespaces](#namespaces)
- [Virtualization](#virtualization)
- [AWK](#awk)
- [System Calls](#system-calls)
- [Filesystem & Files](#filesystem--files)
- [Advanced Networking](#advanced-networking)
- [Memory](#memory)
- [Distributions](#distributions)
- [Sed](#sed)
- [Misc](#misc-1)
* [Linux 101](#questions-linux-101)
* [Linux I/O Redirection](#questions-linux-redirection)
* [Linux Filesystem Hierarchy Standard](#questions-linux-fhs)
* [Linux Permissions](#questions-linux-permissions)
* [Linux Scenarios](#questions-linux-scenarios)
* [Linux Systemd](#questions-linux-systemd)
* [Linux Troubleshooting and Debugging](#questions-linux-troubleshooting)
* [Linux kernel](#questions-linux-kernel)
* [Linux SSH](#questions-linux-ssh)
* [Linux Globbing and Wildcards](#questions-linux-wildcards)
* [Linux Boot Process](#questions-linux-boot)
* [Linux Disk and Filesystem](#questions-linux-disk-fs)
* [Linux Performance Analysis](#questions-linux-performance-analysis)
* [Linux Processes](#questions-linux-processes)
* [Linux Security](#questions-linux-security)
* [Linux Networking](#questions-linux-networking)
* [Linux DNS](#questions-linux-dns)
* [Linux Packaging](#questions-linux-packaging)
* [Linux DNF](#questions-linux-dnf)
* [Linux Applications and Services](#questions-linux-apps-and-services)
* [Linux Users and Groups](#questions-linux-users-and-groups)
* [Linux Hardware](#questions-linux-hardware)
* [Linux Namepsaces](#questions-linux-namespaces)
* [Linux Virtualization](#questions-linux-virtualization)
* [Linux AWK](#questions-linux-awk)
* [Linux System Calls](#questions-linux-system-calls)
* [Linux Filesystem and Files](#questions-linux-fs-files)
* [Linux Advanced Networking](#questions-linux-advanced-networking)
* [Linux Memory](#questions-linux-memory)
* [Linux Distributions](#questions-linux-distributions)
* [Linux Sed](#questions-linux-sed)
* [Linux Misc](#questions-linux-misc)
## Linux Exercises
### Basics
|Name|Topic|Objective & Instructions|Solution|Comments|
|--------|--------|------|----|----|
| Navigation | cd, pwd | [Exercise](exercises/navigation/README.md) | [Solution](exercises/navigation/solution.md)
| Create and Destroy | touch, rm, mkdir | [Exercise](exercises/create_remove/README.md) | [Solution](exercises/create_remove/solution.md)
| Copy Time | touch, cp, ls | [Exercise](exercises/copy/README.md) | [Solution](exercises/copy/solution.md)
### Misc
|Name|Topic|Objective & Instructions|Solution|Comments|
|--------|--------|------|----|----|
| Unique Count | | [Exercise](exercises/uniqe_count/README.md) | [Solution](exercises/uniqe_count/solution.md)
## Linux Questions
<a name="questions-linux-101"></a>
### Linux 101
<details>
@ -50,6 +73,7 @@ A completely free application for testing your knowledge on Linux
[Wikipedia](https://en.wikipedia.org/wiki/Linux): "Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged in a Linux distribution."
[Red Hat](https://www.redhat.com/en/topics/linux/what-is-linux): "Linux® is an open source operating system (OS). An operating system is the software that directly manages a systems hardware and resources, like CPU, memory, and storage. The OS sits between applications and hardware and makes the connections between all of your software and the physical resources that do the work."
</b></details>
<details>
@ -479,8 +503,7 @@ To stop a service: `systemctl stop <service name>`
<summary>Describe how to make a certain process/app a service</summary><br><b>
</b></details>
<a name="questions-linux-troubleshooting"></a>
### Troubleshooting & Debugging
### Troubleshooting and Debugging
<details>
<summary>Where system logs are located?</summary><br><b>
@ -551,7 +574,16 @@ tail -f <file_name>
<summary>How you measure time execution of a program?</summary><br><b>
</b></details>
<a name="questions-linux-kernel"></a>
#### Scenarios
<details>
<summary>You have a process writing to a file. You don't know which process exactly, you just know the path of the file. You would like to kill the process as it's no longer needed. How would you achieve it?</summary><br><b>
1. Run `lsof <FILE_PATH>`
2. Use the pid (process ID) from the lsof command and run `kill <PID>`
</b></details>
### Kernel
<details>

View File

@ -0,0 +1,15 @@
# Copy Time
## Objectives
1. Create an empty file called `x` in `/tmp`
2. Copy the `x` file you created to your home directory
3. Create a copy of `x` file called `y`
4. Create a directory called `files` and move `x` and `y` there
5. Copy the directory "files" and name the copy `copy_of_files`
6. Rename `copy_of_files` directory to `files2`
7. Remove `files` and `files2` directories
## Solution
Click [here](solution.md) to view the solution.

View File

@ -0,0 +1,25 @@
# Copy Time
## Objectives
1. Create an empty file called `x` in `/tmp`
2. Copy the `x` file you created to your home directory
3. Create a copy of `x` file called `y`
4. Create a directory called `files` and move `x` and `y` there
5. Copy the directory "files" and name the copy `copy_of_files`
6. Rename `copy_of_files` directory to `files2`
7. Remove `files` and `files2` directories
## Solution
```
touch /tmp/x
cp x ~/
cp x y
mkdir files
cp x files
cp y files
cp -r files copy_of_files
mv copy_of_files files2
rm -rf files files2
```

View File

@ -0,0 +1,14 @@
# Create & Destroy
## Objectives
1. Create a file called `x`
2. Create a directory called `content`
3. Move `x` file to the `content` directory
4. Create a file insidethe `content` directory called `y`
5. Create the following directory structure in `content` directory: `dir1/dir2/dir3`
6. Remove the content directory
## Solution
Click [here](solution.md) to view the solution.

View File

@ -0,0 +1,21 @@
# Create & Destroy
## Objectives
1. Create a file called `x`
2. Create a directory called `content`
3. Move `x` file to the `content` directory
4. Create a file insidethe `content` directory called `y`
5. Create the following directory structure in `content` directory: `dir1/dir2/dir3`
6. Remove the content directory
## Solution
```
touch x
mkdir content
mv x content
touch content/y
mkdir -p content/dir1/dir2/dir3
rm -rf content
```

View File

@ -0,0 +1,19 @@
# Navigation
## Requirements
1. Linux :)
## Objectives
1. Change directory to `/tmp`
2. Move to parent directory
3. Change directory to home directory
4. Move to parent directory
5. Move again to parent directory
1. Where are you at? Verify with a command
6. Change to last visited directory
## Solution
Click [here](solution.md) to view the solution

View File

@ -0,0 +1,28 @@
# Navigation
## Requirements
1. Linux :)
## Objectives
1. Change directory to `/tmp`
2. Move to parent directory
3. Change directory to home directory
4. Move to parent directory
5. Move again to parent directory
1. Where are you at? Verify with a command
6. Change to last visited directory
## Solution
```
cd /tmp
cd ..
cd ~
cd ..
cd ..
# root (/)
pwd
cd -
```

View File

@ -0,0 +1,9 @@
# Unique Count
## Objectives
In this directory you have a file with list of IP addresses called `ip_list`. Using the file, determine which IP address is the most recurring (listed the most times).
# Solution
Click [here](solution.md) to view the solution

View File

@ -0,0 +1,115 @@
88.249.123.246 GET 200
204.14.121.43 GET 200
49.11.110.6 GET 200
137.126.109.160 GET 200
107.13.168.5 GET 200
232.136.91.101 GET 404
43.140.194.174 GET 200
137.126.109.160 GET 200
63.219.2.31 GET 200
17.86.6.109 GET 200
119.89.134.53 GET 404
137.126.109.160 GET 200
204.14.121.43 GET 200
238.183.3.55 GET 200
254.62.231.49 GET 200
250.1.145.213 POST 200
17.86.6.109 GET 404
119.89.134.53 POST 200
88.249.123.246 GET 200
49.11.110.61 GET 200
107.13.168.5 GET 504
232.136.91.101 GET 200
137.126.109.160 POST 200
63.219.2.31 GET 200
17.86.6.109 GET 200
119.89.134.53 GET 504
17.86.6.109 GET 200
197.1.166.141 GET 200
17.86.6.109 GET 200
87.21.188.245 GET 504
235.230.62.243 GET 200
246.3.48.149 GET 200
194.131.205.190 GET 504
222.129.41.212 POST 200
224.57.91.248 GET 504
238.183.3.55 GET 200
137.126.109.160 GET 504
254.62.231.49 POST 200
250.1.145.213 GET 504
185.80.235.15 GET 200
137.126.109.160 GET 200
63.219.2.31 GET 504
17.86.6.109 GET 200
119.89.134.53 POST 200
63.219.2.31 GET 504
17.86.6.109 GET 200
119.89.134.53 GET 504
88.249.123.246 GET 200
238.183.3.55 POST 200
224.57.91.248 GET 504
238.183.3.55 POST 200
254.62.231.49 GET 200
254.62.231.49 POST 404
250.1.145.213 GET 200
221.169.255.179 GET 200
220.35.213.247 GET 200
67.89.94.133 GET 200
77.192.163.242 POST 200
204.14.121.43 GET 200
22.244.145.46 GET 200
89.127.55.7 GET 200
137.126.109.160 GET 200
88.249.123.246 POST 200
238.183.3.55 GET 200
254.62.231.49 GET 200
250.1.145.213 GET 200
137.126.109.160 POST 200
221.169.255.179 GET 200
232.136.91.101 GET 200
197.1.166.141 GET 200
87.21.188.245 GET 200
235.230.62.243 GET 200
246.3.48.149 GET 200
194.131.205.190 GET 200
222.129.41.212 GET 200
137.126.109.160 GET 200
224.57.91.248 GET 200
185.80.235.15 GET 200
137.126.109.160 GET 200
63.219.2.31 GET 200
17.86.6.109 GET 200
119.89.134.53 GET 200
88.249.123.246 GET 200
238.183.3.55 GET 200
254.62.231.49 GET 200
250.1.145.213 GET 200
63.219.2.31 GET 200
17.86.6.109 GET 200
119.89.134.53 POST 200
88.249.123.246 GET 200
137.126.109.160 POST 200
238.183.3.55 GET 200
254.62.231.49 POST 200
250.1.145.213 GET 200
137.126.109.160 POST 200
63.219.2.31 GET 200
17.86.6.109 GET 404
107.13.168.5 POST 200
232.136.91.101 GET 200
137.126.109.160 POST 200
63.219.2.31 GET 200
17.86.6.109 GET 200
197.1.166.141 GET 200
87.21.188.245 POST 200
235.230.62.243 POST 200
246.3.48.149 GET 200
194.131.205.190 GET 200
224.57.91.248 GET 200
238.183.3.55 POST 200
254.62.231.49 GET 200
88.249.123.246 GET 200
49.11.110.61 GET 200
107.13.168.5 POST 200
232.136.91.101 GET 200
204.14.121.43 POST 200

View File

@ -0,0 +1,9 @@
# Unique Count
## Objectives
In this directory you have a file with list of IP addresses called `ip_list`. Using the file, determine which IP address is the most recurring (listed the most times).
# Solution
`sort ip_list | cut -d' ' -f1 | uniq -c | sort -n | tail -1`

View File

@ -26,6 +26,7 @@
- [AWS](#aws-1)
- [Validations](#validations)
- [Terraform Syntax](#terraform-syntax)
- [Production](#production)
## Exercises
@ -839,6 +840,7 @@ terraform {
<summary>How <code>terraform apply</code> workflow is different when a remote backend is used?</summary><br><b>
It starts with acquiring a state lock so others can't modify the state at the same time.
</b></details>
<details>
@ -846,6 +848,7 @@ It starts with acquiring a state lock so others can't modify the state at the sa
1. You remove the backend code and perform `terraform init` to switch back to `local` backend
2. You remove the resources that are the remote backend itself
</b></details>
<details>
@ -853,7 +856,16 @@ It starts with acquiring a state lock so others can't modify the state at the sa
That's true and quite a limitation as it means you'll have to go to the resources of the remote backend and copy some values to the backend configuration.
One way to deal with it is using partial configurations in a completel separate file from the backend itself and then load them with `terraform init -backend-config=some_backend_partial_conf.hcl`
One way to deal with it is using partial configurations in a completely separate file from the backend itself and then load them with `terraform init -backend-config=some_backend_partial_conf.hcl`
</b></details>
<details>
<summary>Is there a way to obtain information from a remote backend/state usign Terraform?</summary><br><b>
Yes, using the concept of data sources. There is a data source for a remote state called "terraform_remote_state".
You can use it the following syntax `data.terraform_remote_state.<NAME>.outputs.<ATTRIBUTE>`
</b></details>
@ -873,6 +885,12 @@ True
</b></details>
<details>
<summary>Why workspaces might not be the best solution for managing states for different environemnts? like staging and production</summary><br><b>
One reason is that all the workspaces are stored in one location (as in one backend) and usually you don't want to use the same access control and authentication for both staging and production for obvious reasons. Also working in workspaces is quite prone to human errors as you might accidently think you are in one workspace, while you are working a completely different one.
</b></details>
#### State Hands-On
@ -925,6 +943,8 @@ True
[Terraform.io](https://www.terraform.io/language/modules/develop): "A module is a container for multiple resources that are used together. Modules can be used to create lightweight abstractions, so that you can describe your infrastructure in terms of its architecture, rather than directly in terms of physical objects."
In addition, modules are great for creating reuable Terraform code that can be shared and used not only between different repositories but even within the same repo, between different environments (like staging and production).
</b></details>
<details>
@ -1045,4 +1065,107 @@ variable "some_var" {
<details>
<summary>Demonstrate using the ternary syntax</summary><br><b>
</b></details>
<details>
<summary>What <code>templatefile</code> function does?</summary><br><b>
Renders a template file and returns the result as string.
</b></details>
<details>
<summary>How do you test terraform syntax?</summary><br><b>
A valid answer could be "I write Terraform configuration and try to execute it" but this makes testing cumbersome and quite complex in general.
There is `terraform console` command which allows you to easily execute terraform functions and experiment with general syntax.
</b></details>
<details>
<summary>True or False? Terraform console should be used carefully as it may modify your resources</summary><br><b>
False. terraform console is ready-only.
</b></details>
<details>
<summary>You need to render a template and get it as string. Which function would you use?</summary><br><b>
`templatefile` function.
</b></details>
### Production
This section is about how Terraform is actually used in real-life scenarios and organizations.
<details>
<summary>What structure layout do you use for your projects?</summary><br><b>
There is no right or wrong answer, just what you personally adopted or your team, and being able to explain why.
One common approach is to have a separate directory for each environment.
```
terraform_project/
staging/
production/
```
Each environment has its own backend (as you don't want to use the same authentication and access controls for all environments)
Going further, under each environment you'll separate between comoponents, applications and services
```
terraform_project/
staging/
applications/
some-app-service-1/
some-app-service-2/
databases/
mongo/
postgres/
networking/
```
</b></details>
<details>
<summary>What files do you have you have in your Terraform projects?</summary><br><b>
Again, no right or wrong answer. Just your personal experience.
main.tf
providers.tf
outputs.tf
variables.tf
dependencies.tf
Each one of these files can be divided to smaller parts if needed (no reason to maintain VERY long files)
</b></details>
<details>
<summary>An engineer in your team complains about having to copy-paste quite a lot of code between different folders and files of Terraform. What would you do?</summary><br><b>
Suggest to use Terraform modules.
</b></details>
<details>
<summary>When working with nested layout of many directories, it can make it cumbresome to run terraform commands in many different folders. How to deal with it?</summary><br><b>
There are multiple ways to deal with it:
1. Write scripts that perform some commands recurisvely with different conditions
2. Use tools like Terragrunt where you commands like "run-all" that can run in parallel on multiple different paths
</b></details>
<details>
<summary>One of the engineers in your team complains the inline shell scripts are quite big and maintaining them in Terraform files seems like a bad idea. What would you do?</summary><br><b>
A good solution for not including shell scripts inline (as in inside terraform configuration files) is to keep them in a separate file and then use the terraform `templatefile` function to render and get them as a string
</b></details>
<details>
<summary>You noticed a lot of your Terraform code/configuration is duplicated, between repositories and also within the same repository between different directories. What one way you may adopt that will help handling with that?</summary><br><b>
Using Terraform modules can help greatly with duplicated code and so different environments for example (staging and production) can reuse the same code by using the same modules.
</b></details>