Beginning-Ansible-Concepts-.../chapter05/webservers.yml
2022-04-23 08:57:49 +01:00

41 lines
892 B
YAML

---
- hosts: webservers
become: true
tasks:
- name: Ensure nginx is installed
apt:
name: nginx
state: present
- name: Push website content to the web root
copy:
src: index.html
dest: /var/www/html/
mode: u=rw,g=r,o=r
- name: index.html also known as main.html
file:
state: link
src: /var/www/html/index.html
dest: /var/www/html/main.html
- name: Update the website content
lineinfile:
path: /var/www/html/index.html
line: "Just re-decorating a little!"
- name: Firewall - Allow SSH connections
ufw:
rule: allow
name: OpenSSH
- name: Firewall - Allow website connections
ufw:
rule: allow
name: "Nginx Full"
- name: Firewall - Deny everything else
ufw:
state: enabled
policy: deny