yankev07 / BeyondMD_Interview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BeyondMD Interview Assessment

Topic

  • Make a simple page using HTML, CSS, and/or javascript that displays “Hello BeyondMD!“, and then dockerize it. It must run using docker compose.
  • Write a script that collects and reports various system health information, such as CPU, memory, disk usage, active users, and/or running processes for a debian server.
  • Create an idempotent Ansible playbook that automates the installation and configuration of Docker on a Debian bookworm host, ensuring it correctly handles repeated executions without unnecessary changes to the system state.
  • Bonus points if you use vagrant as a local testing environment for your ansible playbook. I personally really like the "debian-sandbox/bookworm64" vagrant image.

Step 1

Wrote a sample HTML5/CSS3 script which displays the message "Hello BeyondMD!" as pictured below

Img 1

After writing the HTML script and testing locally that the output is correct, the next step is to containerize our simple webpage For that, we write a Dockerfile which pulls the official image of https from docker hub We cna also use a docker-compose.yml file which will specify the ports mapping

Note: Our port 8080 was already busy during this exercise, so we used the port 3000 instead (Subtle ReactJS reference here!)

Once everything looks good, we build our docker image using the command below:

Img 2

We then run the generated docker image

Img 3

Now we can check at http://localhost:3000/ and see the webpage live from the browser window

Img 4

Step 2

By writing a short bash script, we can output various system health information from a Debian bookworm server as pictured below:

Img 5

Step 3

The installation of Docker can be automated on a Debian bookworm server using a ansible playbook. The playbook contains step-by-step commands and parameters detailing each step of the installation of Docker on Debian OS We can test our playbook by using the "ansible-playbook" command.

In our case, the remote server was secured using a private key for ssh connections, so we had to include an extra "--private-key" parameter in the command as pictured below:

Img 6

We can check that docker was successfully installed on the remote server by manually ssh-ing and testing the command "docker --version"

Step 4

We can use vagrant to provision a local Debian bookworm environment for the ansible playbook. For that, we need to write a Vagrant script which specifies details about the desired VM box as well as referrencing our previously written ansible playbook.

After everything looks good with the Vagrant script, we can now run the "vagrant run" and "vagrant ssh" commands to create and provision the vagrant VM as shown below:

Img 7

About


Languages

Language:HTML 37.2%Language:Shell 33.9%Language:CSS 23.8%Language:Dockerfile 5.2%