ansible-web-wm

MIT License Last Updated Build GitHub Pages

Automated deployment and security of a web server using Ansible


Project information

This project serves for automated installation and configuration of a web server using Ansible. It includes:

Deployment scheme


Project: Ansible Web Server ansible-web-wm

Comprehensive automation of Linux servers using Ansible, focused on:


Requirements for the environment


Project launch

  1. Optional: Cloning the repository If you haven’t downloaded the repository yet:
    git clone https://github.com/Miska296/ansible-web-wm.git
    cd ansible-web-wm
    
  2. Setting the paths to roles (already prepared in provision.sh):
    export ANSIBLE_ROLES_PATH="./roles"
    
  3. Starting the provisioning:
    ./provision.sh
    
  4. After launching, enter the password for the Vault when prompted.
  5. Check the functionality of the web server: Open in your browser http://localhost or the corresponding IP address — a page with the text should be displayed: Hello from GitHub! This file was uploaded by Michaela for Ansible testing.

Ansible Vault — Safe storage of password


Additional safety features


Project structure

Root directory ansible-web-wm:

Structure of folders Project structure in Codespace

cz For the Czech version of this documentation, see README.md


Bonus features


Project status

Live demo: View the project on GitHub Pages


Testing and verification of functionality

After completing the provisioning, please perform the following checks:

Provisioning output Successful completion of provisioning (failed=0)

The web page has been successfully deployed and is available at the public address in GitHub Codespace: glowing-barnacle-q7xw5pvxvv4jhx6jg-80.app.github.dev

Warning: The public URL works only after the successful provisioning and publication of port 80 in the Codespace.

Website preview The displayed page after deploying NGINX

If the page displays “Hello from GitHub!”, the deployment was successful.


Video presentation of the project

It shows the complete run of the script provision.sh, deploying the web server using Ansible and verifying its functionality.

Project presentation ansible-web-wm


This project is based on the original repository static-web-test, where a static web application was created using the Replit platform. The project ansible-web-wm has been supplemented with automation, security features, and extensive testing.


Troubleshooting

1. No port has opened

If ports 22 (SSH) or 80 (HTTP) are not open after provisioning, please check the following:

  1. Firewall (UFW)
    Check the status of the firewall:
    sudo ufw status
    
    • If active, allow the necessary ports:
      sudo ufw allow 22
      sudo ufw allow 80
      sudo ufw reload
      

2. Ports are not available in Codespace

If ports 22 or 80 are not visible in the ‘Ports’ tab:

  1. Open the Ports tab in Codespace
  2. Click on “Add port”
  3. Enter 80 and check ‘Public’
  4. After saving, a public URL will be displayed, e.g. https://username-repo-80.app.github.dev
  5. Open it in the browser and verify that the page loads
  6. Check that NGINX is listening on all interfaces (listen 80, listen [::]:80)

3. NGINX is running but is not accessible.

Check the status of the service:

   systemctl status nginx

Check if it is listening on port 80:

   ss -tuln | grep :80

Tip: Always verify that the port is marked as ‘Public’ in Codespace, otherwise the page won’t be accessible externally.

4. SSH access restricted

If you have disabled login using a password or root user, make sure you have the SSH key properly set in sshd_config.

5. Provisioning has been completed, but the changes have not been applied

Try to run the provisioning again:

   ./provision.sh

6. The web is not available from the outside

If the webpage does not display through a public URL (e.g., in Codespace), check:

  1. NGINX configuration
    • Make sure that in the template nginx.conf.j2 there is:
      server_name _;
      listen 80;
      listen [::]:80;
      
    • This ensures that the server listens on all interfaces and is not limited to localhost.
  2. Restart the service
    • In an environment without systemd, use:
      service nginx restart
      
  3. Port publication
    • Manually add port 80 in the tab in Codespace „Ports“ and set it as „Public“.
  4. Firewall
    • Check that ports 22 and 80 are allowed:
      sudo ufw status
      

Best Practices


Future improvements


Author

The project was developed by Michaela Kučerová
Version: 1.0
Date: July 2025
Last updated: September 2025
Build: OK


License

This project is available under the MIT license. See the file LICENSE.