diff options
author | binary <me@rgoncalves.se> | 2021-01-15 15:48:42 +0100 |
---|---|---|
committer | binary <me@rgoncalves.se> | 2021-01-15 15:49:36 +0100 |
commit | 58a81dc2ea748cf769d88b7515a39c6587d37ce2 (patch) | |
tree | c7664528dba83bc4ddc341137c53ec4acf072f15 /roles/nginx/tasks | |
parent | dd2e7cf9113349b9515a27a076f2e45a8a34684e (diff) | |
download | infrastructure-58a81dc2ea748cf769d88b7515a39c6587d37ce2.tar.gz |
Add nginx and sourcehut role
Diffstat (limited to 'roles/nginx/tasks')
-rw-r--r-- | roles/nginx/tasks/main.yml | 42 |
1 files changed, 42 insertions, 0 deletions
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 + |