aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-03-04 01:59:43 -0500
committerMitch Riedstra <mitch@riedstra.us>2019-03-04 01:59:43 -0500
commit8747b45c5fcafa191db55d23988041f5ddc696d9 (patch)
tree42ead7b50b3156e27aa8afc3b69a96bd7df3f4c5
parentc06f286b6d7a6c1b63cbcd7289a0343564939ebe (diff)
downloadnginx-8747b45c5fcafa191db55d23988041f5ddc696d9.tar.gz
nginx-8747b45c5fcafa191db55d23988041f5ddc696d9.tar.xz
Add support for alternate configuration directories, Ubuntu, FreeBSD, etc.
-rw-r--r--defaults/main.yml2
-rw-r--r--handlers/main.yml10
-rw-r--r--tasks/enable.yml14
-rw-r--r--tasks/install.yml15
-rw-r--r--tasks/main.yml23
5 files changed, 48 insertions, 16 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index 7526a9c..8778182 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -11,3 +11,5 @@ nginx_conf_group: adm
# RFC 1918 addresses are already included. Inserted directly into
# nginx configuration with an `include`
nginx_acl_block: ""
+
+nginx_conf_dir: "/etc/nginx"
diff --git a/handlers/main.yml b/handlers/main.yml
index 01a6c2e..0b84e35 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -1,4 +1,12 @@
-- name: Restart Nginx
+- name: Restart Nginx
runit:
name: nginx
state: restarted
+ listen: Restart Nginx
+ when: ansible_facts['distribution'].lower() == "void"
+- name: Restart Nginx
+ systemd:
+ name: nginx
+ state: restarted
+ listen: Restart Nginx
+ when: ansible_facts['distribution'].lower() == "ubuntu"
diff --git a/tasks/enable.yml b/tasks/enable.yml
new file mode 100644
index 0000000..8d9fcd7
--- /dev/null
+++ b/tasks/enable.yml
@@ -0,0 +1,14 @@
+- name: 'Enable Nginx [Void]'
+ file:
+ src: /etc/sv/nginx
+ dest: /var/service/nginx
+ owner: root
+ group: root
+ state: link
+ when: ansible_facts['distribution'].lower() == "void"
+- name: 'Enable Nginx [Ubuntu]'
+ systemd:
+ enabled: yes
+ daemon_reload: yes
+ name: nginx
+ when: ansible_facts['distribution'].lower() == "ubuntu"
diff --git a/tasks/install.yml b/tasks/install.yml
new file mode 100644
index 0000000..72787c0
--- /dev/null
+++ b/tasks/install.yml
@@ -0,0 +1,15 @@
+- name: 'Install Nginx [Void}'
+ xbps:
+ name: nginx
+ state: present
+ when: ansible_facts['distribution'].lower() == "void"
+- name: 'Install Nginx [Alpine]'
+ apk:
+ name: nginx
+ state: present
+ when: ansible_facts['distribution'].lower() == "alpine"
+- name: 'Install Nginx [Ubuntu]'
+ apt:
+ name: nginx
+ state: present
+ when: ansible_facts['distribution'].lower() == "ubuntu"
diff --git a/tasks/main.yml b/tasks/main.yml
index 23a424b..ab06c87 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,15 +1,8 @@
---
-- name: Install Nginx
- xbps:
- name: nginx
- state: present
-- name: Enable Nginx
- file:
- src: /etc/sv/nginx
- dest: /var/service/nginx
- owner: root
- group: root
- state: link
+- name: Include install tasks
+ include_tasks: install.yml
+- name: Include enable tasks
+ include_tasks: enable.yml
- name: Lock down and setup configuration directories
file:
path: '{{item}}'
@@ -18,8 +11,8 @@
group: "{{nginx_conf_group}}"
mode: "{{nginx_conf_dir_mode}}"
loop:
- - /etc/nginx
- - /etc/nginx/conf.d
+ - "{{nginx_conf_dir}}"
+ - "{{nginx_conf_dir}}/conf.d"
- name: Create Acme Challenge directory
file:
path: /var/lib/acme-challenge
@@ -30,7 +23,7 @@
- name: Install Main 'nginx.conf'
template:
src: nginx/nginx.conf
- dest: /etc/nginx/nginx.conf
+ dest: "{{nginx_conf_dir}}/nginx.conf"
owner: "{{nginx_conf_owner}}"
group: "{{nginx_conf_group}}"
mode: "{{nginx_conf_file_mode}}"
@@ -39,7 +32,7 @@
- name: Install Other Nginx templates
template:
src: "nginx/{{item}}"
- dest: "/etc/nginx/{{item}}"
+ dest: "{{nginx_conf_dir}}/{{item}}"
owner: "{{nginx_conf_owner}}"
group: "{{nginx_conf_group}}"
mode: "{{nginx_conf_file_mode}}"