From 58a81dc2ea748cf769d88b7515a39c6587d37ce2 Mon Sep 17 00:00:00 2001 From: binary Date: Fri, 15 Jan 2021 15:48:42 +0100 Subject: Add nginx and sourcehut role --- roles/nginx/tasks/main.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 roles/nginx/tasks/main.yml (limited to 'roles/nginx/tasks') diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml new file mode 100644 index 0000000..dda2c98 --- /dev/null +++ b/roles/nginx/tasks/main.yml @@ -0,0 +1,42 @@ + +# nginx ~~ roles/nginx/tasks/main.yml +# Linux nginx webserver + +--- + +- name: ensure role is run on linux hosts + fail: + msg: nginx role can only be run on linux host + when: ansible_system != "Linux" + +- name: ensure nginx is installed + package: name=nginx state=present + +- name: ensure nginx group exists + group: name="{{ nginx_group }}" state=present + +- name: ensure nginx user exists + user: name="{{ nginx_user }}" group="{{ nginx_group }}" state=present + +- name: generate nginx configuration + template: + src: nginx.conf.j2 + dest: /etc/nginx/nginx.conf + owner: "{{ user_root }}" + group: "{{ group_root }}" + mode: 0644 + +- name: ensure nginx sub-configuration directory exists + file: + path: "{{ nginx_subconf_dir }}" + owner: "{{ user_root }}" + group: "{{ group_root }}" + state: directory + mode: 0744 + +- name: enable and restart nginx + service: + name: nginx + state: restarted + enabled: true + -- cgit v1.2.3