aboutsummaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-06-14 23:24:36 +0800
committerAaron LI <aly@aaronly.me>2017-06-14 23:24:36 +0800
commit147a93b2f08d1bb62ca6946a8ddff2974e418401 (patch)
treea2454e913f15a9c1a283995e91520d0edd81efe2 /roles
parentd9bfda6c292c6b90eb7ba295425a74679e6d9c13 (diff)
downloaddebian-hpc-147a93b2f08d1bb62ca6946a8ddff2974e418401.tar.bz2
Add basic nginx role
Diffstat (limited to 'roles')
-rw-r--r--roles/nginx/files/nginx.conf33
-rw-r--r--roles/nginx/handlers/main.yml7
-rw-r--r--roles/nginx/tasks/main.yml30
-rw-r--r--roles/nginx/vars/main.yml13
4 files changed, 83 insertions, 0 deletions
diff --git a/roles/nginx/files/nginx.conf b/roles/nginx/files/nginx.conf
new file mode 100644
index 0000000..1ec0ea6
--- /dev/null
+++ b/roles/nginx/files/nginx.conf
@@ -0,0 +1,33 @@
+#
+# /etc/nginx/nginx.conf
+#
+
+user www-data;
+worker_processes auto;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+
+ server_names_hash_bucket_size 64;
+ types_hash_max_size 2048;
+ client_max_body_size 10M;
+
+ keepalive_timeout 65;
+
+ gzip on;
+ gzip_types text/css text/xml text/plain application/x-javascript application/atom+xml application/rss+xml;
+
+ autoindex on;
+ index index.html index.htm;
+
+ include /etc/nginx/sites-enabled/*;
+}
diff --git a/roles/nginx/handlers/main.yml b/roles/nginx/handlers/main.yml
new file mode 100644
index 0000000..43d8eb7
--- /dev/null
+++ b/roles/nginx/handlers/main.yml
@@ -0,0 +1,7 @@
+---
+- name: Restart Nginx
+ service:
+ name: nginx
+ state: restarted
+
+# vim: set ft=yaml sw=2:
diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml
new file mode 100644
index 0000000..d3a6204
--- /dev/null
+++ b/roles/nginx/tasks/main.yml
@@ -0,0 +1,30 @@
+---
+- name: Ensure that the Apache web server is not installed
+ apt:
+ name: "{{ item }}"
+ state: absent
+ with_items: "{{ apache_packages_to_remove }}"
+
+- name: Install Nginx
+ apt:
+ name: nginx
+ state: present
+
+- name: Update Nginx configuration
+ copy:
+ src: nginx.conf
+ dest: /etc/nginx/nginx.conf
+ owner: root
+ group: root
+ mode: 0644
+ notify: Restart Nginx
+
+- name: Set up Nginx sites
+ file:
+ path: /etc/nginx/{{ item }}
+ state: directory
+ with_items:
+ - sites-available
+ - sites-enabled
+
+# vim: set ft=yaml sw=2:
diff --git a/roles/nginx/vars/main.yml b/roles/nginx/vars/main.yml
new file mode 100644
index 0000000..898d908
--- /dev/null
+++ b/roles/nginx/vars/main.yml
@@ -0,0 +1,13 @@
+---
+
+# Apache web server packages to be removed to avoid conflicts
+apache_packages_to_remove:
+ - apache2
+ - apache2.2-bin
+ - apache2.2-common
+ - apache2-mpm-event
+ - apache2-mpm-itk
+ - apache2-mpm-prefork
+ - apache2-mpm-worker
+
+# vim: set ft=yaml sw=2: