aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/nginx
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/nginx')
-rw-r--r--ansible/roles/nginx/defaults/main.yml2
-rw-r--r--ansible/roles/nginx/handlers/main.yml11
-rw-r--r--ansible/roles/nginx/tasks/main.yml32
3 files changed, 45 insertions, 0 deletions
diff --git a/ansible/roles/nginx/defaults/main.yml b/ansible/roles/nginx/defaults/main.yml
new file mode 100644
index 0000000..fe42c1b
--- /dev/null
+++ b/ansible/roles/nginx/defaults/main.yml
@@ -0,0 +1,2 @@
+nginx__copy:
+nginx__template:
diff --git a/ansible/roles/nginx/handlers/main.yml b/ansible/roles/nginx/handlers/main.yml
new file mode 100644
index 0000000..039e72b
--- /dev/null
+++ b/ansible/roles/nginx/handlers/main.yml
@@ -0,0 +1,11 @@
+- name: systemctl reload nginx
+ become: yes
+ systemd:
+ name: nginx
+ state: reloaded
+
+- name: systemctl restart nginx
+ become: yes
+ systemd:
+ name: nginx
+ state: restarted
diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml
new file mode 100644
index 0000000..bbe6da7
--- /dev/null
+++ b/ansible/roles/nginx/tasks/main.yml
@@ -0,0 +1,32 @@
+- become: yes
+ tags:
+ - nginx
+ block:
+ - name: packages
+ vars:
+ items:
+ - nginx
+ apt:
+ name: "{{ items }}"
+ install_recommends: no
+
+- become: yes
+ tags:
+ - nginx
+ - nginx-config
+ block:
+ - name: "fill /etc/nginx"
+ with_items: "{{ nginx__copy }}"
+ when: item is defined and item
+ notify: systemctl reload nginx
+ copy:
+ dest: "/etc/nginx/{{ item }}"
+ src: "nginx/{{ ansible_hostname }}/{{ item }}"
+
+ - name: "fill /etc/nginx"
+ with_items: "{{ nginx__template }}"
+ when: item is defined and item
+ notify: systemctl reload nginx
+ template:
+ dest: "/etc/nginx/{{ item }}"
+ src: "nginx/{{ ansible_hostname }}/{{ item }}"