make vhosts on Debian symlinked

pull/159/head
Toni Mueller 6 years ago
parent 0010b7e06c
commit 5c61b567a3
  1. 2
      defaults/main.yml
  2. 4
      tasks/main.yml
  3. 65
      tasks/vhosts-Debian.yml
  4. 3
      vars/Debian.yml

@ -22,6 +22,8 @@ nginx_multi_accept: "off"
nginx_error_log: "/var/log/nginx/error.log warn"
nginx_access_log: "/var/log/nginx/access.log main buffer=16k flush=2m"
nginx_vhost_enabled: true
nginx_sendfile: "on"
nginx_tcp_nopush: "on"
nginx_tcp_nodelay: "on"

@ -29,6 +29,10 @@
# Vhost configuration.
- import_tasks: vhosts.yml
when: ansible_os_family != 'Debian'
- import_tasks: vhosts-Debian.yml
when: ansible_os_family == 'Debian'
# Nginx setup.
- name: Copy nginx configuration in place.

@ -0,0 +1,65 @@
---
- name: Remove default nginx vhost config file (if configured).
file:
path: "{{ nginx_default_vhost_path }}"
state: absent
when: nginx_remove_default_vhost
notify: restart nginx
- name: Ensure nginx_vhost_path exists.
file:
path: "{{ nginx_vhost_path }}"
state: directory
notify: reload nginx
- name: Ensure nginx_vhost_enabled_path exists.
file:
path: "{{ nginx_vhost_enabled_path }}"
state: directory
notify: reload nginx
- name: Add managed vhost config files.
template:
src: "{{ item.template|default(nginx_vhost_template) }}"
dest: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
force: yes
owner: root
group: root
mode: 0644
when: item.state|default('present') != 'absent'
with_items: "{{ nginx_vhosts }}"
notify: reload nginx
- name: Remove managed vhost config files.
file:
path: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
state: absent
when: item.state|default('present') == 'absent'
with_items: "{{ nginx_vhosts }}"
notify: reload nginx
- name: Remove legacy vhosts.conf file.
file:
path: "{{ nginx_vhost_path }}/vhosts.conf"
state: absent
notify: reload nginx
- name: manage the symlink in sites-enabled, enable
file:
path: "{{ nginx_vhost_enabled_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
src: "{{ nginx_vhost_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
state: link
when: item.enabled|default('true') == 'true'
with_items: "{{ nginx_vhosts }}"
notify: reload nginx
- name: manage the symlink in sites-enabled, disable
file:
path: "{{ nginx_vhost_enabled_path }}/{{ item.filename|default(item.server_name.split(' ')[0] ~ '.conf') }}"
state: absent
when: item.enabled|default('true') == 'false'
with_items: "{{ nginx_vhosts }}"
notify: reload nginx

@ -4,6 +4,7 @@ nginx_conf_path: /etc/nginx/conf.d
nginx_conf_file_path: /etc/nginx/nginx.conf
nginx_mime_file_path: /etc/nginx/mime.types
nginx_pidfile: /run/nginx.pid
nginx_vhost_path: /etc/nginx/sites-enabled
nginx_vhost_path: /etc/nginx/sites-available
nginx_vhost_enabled_path: /etc/nginx/sites-enabled
nginx_default_vhost_path: /etc/nginx/sites-enabled/default
__nginx_user: "www-data"