aipackage/ansible/roles/cezen-nginx/tasks/main.yml

60 lines
1.2 KiB
YAML

---
# cezen-nginx role: installs Nginx, deploys portal static files and site config
- name: Install Nginx
apt:
name: nginx
state: present
update_cache: yes
- name: Create portal directory
file:
path: /opt/cezen/portal
state: directory
owner: "{{ cezen_user }}"
group: www-data
mode: "0755"
- name: Sync portal static files
synchronize:
src: "{{ playbook_dir }}/../../../cezen-portal/"
dest: /opt/cezen/portal/
delete: yes
recursive: yes
rsync_opts:
- "--exclude=.DS_Store"
- "--exclude=*.sh"
notify: Reload nginx
- name: Deploy Nginx site config
copy:
src: cezen.conf
dest: /etc/nginx/sites-available/cezen
owner: root
group: root
mode: "0644"
notify: Reload nginx
- name: Enable Cezen site
file:
src: /etc/nginx/sites-available/cezen
dest: /etc/nginx/sites-enabled/cezen
state: link
notify: Reload nginx
- name: Disable default Nginx site
file:
path: /etc/nginx/sites-enabled/default
state: absent
notify: Reload nginx
- name: Validate Nginx config
command: nginx -t
changed_when: false
- name: Ensure Nginx is enabled and running
systemd:
name: nginx
enabled: yes
state: started