coursework/ansible/roles/nginx_site/tasks/main.yml

86 lines
1.8 KiB
YAML
Raw Permalink Normal View History

2024-11-12 20:14:17 +00:00
- name: Install Nginx
zypper:
name: nginx
state: present
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx
2024-11-12 20:14:17 +00:00
2024-11-24 16:58:14 +00:00
- name: Deploy Main Nginx Configuration
template:
src: nginx.conf.j2
dest: /etc/nginx/nginx.conf
mode: '0644'
notify:
- Restart Nginx
- name: Deploy SiteA Configuration
template:
src: siteA.conf.j2
dest: /etc/nginx/conf.d/siteA.conf
when: "'SiteA' in group_names"
notify:
- Restart Nginx
- name: Deploy SiteB Configuration
template:
src: siteB.conf.j2
dest: /etc/nginx/conf.d/siteB.conf
when: "'SiteB' in group_names"
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx
2024-11-12 20:14:17 +00:00
- name: Create web root for SiteA
file:
path: /var/www/siteA
state: directory
owner: nginx
group: nginx
mode: '0755'
2024-11-17 16:02:14 +00:00
when: "'SiteA' in group_names"
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx
2024-11-12 20:14:17 +00:00
- name: Create web root for SiteB
file:
path: /var/www/siteB
state: directory
owner: nginx
group: nginx
mode: '0755'
2024-11-17 16:02:14 +00:00
when: "'SiteB' in group_names"
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx
2024-11-12 20:14:17 +00:00
- name: Deploy SiteA HTML
template:
src: index.html.j2
dest: /var/www/siteA/index.html
vars:
site_title: "{{ siteA.site_title }}"
site_h1: "{{ siteA.site_h1 }}"
site_h2: "{{ siteA.site_h2 }}"
site_p: "{{ siteA.site_p }}"
2024-11-17 16:02:14 +00:00
when: "'SiteA' in group_names"
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx
2024-11-12 20:14:17 +00:00
- name: Deploy SiteB HTML
template:
src: index.html.j2
dest: /var/www/siteB/index.html
vars:
site_title: "{{ siteB.site_title }}"
site_h1: "{{ siteB.site_h1 }}"
site_h2: "{{ siteB.site_h2 }}"
site_p: "{{ siteB.site_p }}"
2024-11-17 16:02:14 +00:00
when: "'SiteB' in group_names"
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx
2024-11-12 20:14:17 +00:00
2024-11-24 16:58:14 +00:00
- name: Ensure Nginx is enabled and started
systemd:
name: nginx
enabled: yes
state: started
2024-11-24 16:44:14 +00:00
notify:
- Restart Nginx