nginx/tasks/main.yaml
changeset 47 3f1771bb0d79
parent 40 b42b417751e5
child 118 56bffa9ef826
--- a/nginx/tasks/main.yaml	Sun Jun 14 15:22:25 2020 -0500
+++ b/nginx/tasks/main.yaml	Mon Jun 15 23:25:16 2020 -0500
@@ -1,39 +1,44 @@
 ---
 
-- name: install nginx packages
+- name: apt install nginx
   become: yes
   apt: name="nginx"
 
-- name: install site
-  become: yes
-  template: src="{{nginx_conf_src}}" dest="/etc/nginx/sites-available/{{nginx_conf_dst}}"
-  notify: restart nginx
-
-- name: install nginx packages
-  become: yes
-  apt: name="python-certbot-nginx"
-  notify: restart nginx
-  when: nginx_enable_certbot
-
-- name: install certbot in nginx
-  become: yes
-  command: "certbot certonly --nginx -n --agree-tos -d {{nginx_server_name}} -m {{nginx_admin_email}}"
-  changed_when: false
-  when: nginx_enable_certbot
-
 - name: disable default site
   become: yes
   file: path="/etc/nginx/sites-enabled/default" state="absent"
+
+- name: install base config
+  become: yes
+  copy: src="nginx.conf" dest="/etc/nginx/nginx.conf"
   notify: restart nginx
 
-- name: enable site
+- name: make stream dirs
+  become: yes
+  file: path="/etc/nginx/streams-{{item}}" state="directory"
+  loop: ["available", "enabled"]
+
+- name: make config available
+  become: yes
+  template:
+    src:  "{{nginx_conf_src}}"
+    dest: "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
+  notify: restart nginx
+
+- name: enable config
   become: yes
   file:
-    src:  "/etc/nginx/sites-available/{{nginx_conf_dst}}"
-    dest: "/etc/nginx/sites-enabled/{{nginx_conf_dst}}"
+    src:  "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
+    dest: "/etc/nginx/{{nginx_server_type}}s-enabled/{{nginx_server_name}}.conf"
     state: "link"
   notify: restart nginx
 
+- name: copy root files
+  become: yes
+  copy: src="{{nginx_root_src}}" dest="{{nginx_root_dest}}/"
+  when: nginx_root
+  notify: restart nginx
+
 - name: enable nginx service
   become: yes
   systemd: name="nginx" enabled="yes" state="started"