added nginx role

This commit is contained in:
2024-12-04 15:38:14 +01:00
parent 996b0ce4ee
commit 9bbf0a37c0
10 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
---
- name: link nginx config to sites-enabled dir
ansible.builtin.file:
src: "{{ nginx_config_dir }}/{{ domain_name }}"
dest: "{{ nginx_sites_enabled }}/{{ domain_name }}"
owner: root
group: root
state: link
notify: Restart nginx

View File

@@ -0,0 +1,9 @@
---
- name: Install and enable nginx
include_tasks: nginx.yml
- name: Template config files into place
include_tasks: template.yml
- name: Enable site by linking to the dir "{{ nginx_sites_enabled }}"
include_tasks: link.yml

View File

@@ -0,0 +1,10 @@
- name: Install nginx
package:
name: nginx
state: present
- name: Enable nginx
service:
name: nginx
state: started
enabled: yes

View File

@@ -0,0 +1,39 @@
---
- name: ensure target dirs exists
file:
path: "{{ item }}"
state: directory
owner: root
group: root
loop:
- "{{ nginx_config_dir }}"
- name: ensure target dirs exists
file:
path: "{{ item }}"
state: directory
owner: "{{ main_username }}"
group: root
loop:
- "{{ nginx_root_path }}/{{ nginx_root }}"
- name: change hostname to domain_name
template:
src: ../templates/hostname.j2
dest: "/etc/hostname"
owner: root
group: root
- name: write homepage nginx config file
template:
src: ../templates/nginx-config.j2
dest: "{{ nginx_config_dir }}/{{ domain_name }}"
owner: root
group: root
- name: write simple homepage index.html file
template:
src: ../templates/index.html.j2
dest: "{{ nginx_root_path }}/{{ nginx_root }}/index.html"
owner: "{{ main_username }}"
group: root