Ansible Sandbox

Web Server Deployment

Basic

Deploy a Nginx web server with a sample website in a controlled environment.

Runtime: ~3 min
1 VM

Docker Compose Stack

Intermediate

Deploy a multi-container application using Docker Compose with automatic configuration.

Runtime: ~5 min
1 VM

K3s Kubernetes Cluster

Advanced

Deploy a lightweight Kubernetes cluster with basic services and sample application.

Runtime: ~8 min
3 VMs

LAMP Stack

Intermediate

Deploy a Linux, Apache, MySQL, and PHP stack with a sample application.

Runtime: ~4 min
1 VM

Security Hardening

Advanced

Apply security best practices to a Linux server including firewall, SSH hardening, and more.

Runtime: ~6 min
1 VM
Web Server Deployment
Playbook
Configuration
Output
VM Status
1 ---
2 # Web Server Deployment Playbook
3 # This playbook installs and configures a basic Nginx web server
4
5 - name: Deploy Web Server
6 hosts: all
7 become: yes
8 vars:
9 web_domain: example.local
10 web_root: /var/www/html
11 enable_https: false
12 web_color: blue
13
14 tasks:
15 - name: Update apt cache
16 apt:
17 update_cache: yes
18 cache_valid_time: 3600
19
20 - name: Install Nginx and required packages
21 apt:
22 name:
23 - nginx
24 - curl
25 state: present
26
27 - name: Create web root directory
28 file:
29 path: "{{ web_root }}"
30 state: directory
31 mode: '0755'
32
33 - name: Create sample website
34 template:
35 src: templates/index.html.j2
36 dest: "{{ web_root }}/index.html"
37 mode: '0644'
38
39 - name: Configure Nginx virtual host
40 template:
41 src: templates/nginx.conf.j2
42 dest: /etc/nginx/sites-available/{{ web_domain }}
43 notify: restart nginx
44
45 - name: Enable Nginx virtual host
46 file:
47 src: /etc/nginx/sites-available/{{ web_domain }}
48 dest: /etc/nginx/sites-enabled/{{ web_domain }}
49 state: link
50 notify: restart nginx
51
52 - name: Start Nginx
53 service:
54 name: nginx
55 state: started
56 enabled: yes
57
58 handlers:
59 - name: restart nginx
60 service:
61 name: nginx
62 state: restarted
Domain name for the Nginx virtual host.
Directory path where website files will be stored.
Color theme for the sample website.
Operating system for the virtual machine.
Resource allocation for the virtual machine.
PLAY [Deploy Web Server] *************************************************** TASK [Gathering Facts] ***************************************************** ok: [webserver] TASK [Update apt cache] **************************************************** ok: [webserver] TASK [Install Nginx and required packages] ******************************** ok: [webserver] TASK [Create web root directory] ******************************************* ok: [webserver] TASK [Create sample website] *********************************************** changed: [webserver] TASK [Configure Nginx virtual host] **************************************** changed: [webserver] TASK [Enable Nginx virtual host] ******************************************* changed: [webserver] TASK [Start Nginx] ********************************************************* ok: [webserver] RUNNING HANDLER [restart nginx] ******************************************** changed: [webserver] PLAY RECAP ***************************************************************** webserver : ok=9 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 VERIFICATION ************************************************************** Testing website availability... Website is accessible at: http://192.168.122.10 Website deployed successfully!
webserver (Ubuntu 22.04 LTS)
1 vCPU, 1GB RAM, 20GB Storage
Running
Sandbox environment active for 15 more minutes
Ready to deploy