From 6b1c582ca67a01e09941b1d9b479e848817b95d5 Mon Sep 17 00:00:00 2001 From: Vezpi Date: Fri, 5 Dec 2025 19:50:22 +0000 Subject: [PATCH] add: install_nginx.yml --- ansible/playbooks/install_nginx.yml | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ansible/playbooks/install_nginx.yml diff --git a/ansible/playbooks/install_nginx.yml b/ansible/playbooks/install_nginx.yml new file mode 100644 index 0000000..dd297f3 --- /dev/null +++ b/ansible/playbooks/install_nginx.yml @@ -0,0 +1,46 @@ +--- +- name: Demo Playbook - Install Nginx and Serve Hostname Page + hosts: all + become: true + + tasks: + - name: Ensure apt cache is updated + ansible.builtin.apt: + update_cache: true + cache_valid_time: 3600 + + - name: Install nginx + ansible.builtin.apt: + name: nginx + state: present + + - name: Create index.html with hostname + ansible.builtin.copy: + dest: /var/www/html/index.html + content: | + + Demo + +

Hostname: {{ inventory_hostname }}

+ + + owner: www-data + group: www-data + mode: "0644" + + - name: Allow HTTP through firewall + community.general.ufw: + rule: allow + port: "80" + proto: tcp + + - name: Enable ufw + community.general.ufw: + state: enabled + enabled: true + + - name: Ensure nginx is running + ansible.builtin.service: + name: nginx + state: started + enabled: true