Allow other service names besides 'nginx' and give the option to not include OS variables

pull/127/head
Kelvin Jasperson 7 years ago
parent 7aa2ea4779
commit 14eb6bc298
  1. 6
      defaults/main.yml
  2. 6
      handlers/main.yml
  3. 3
      tasks/main.yml

@ -12,6 +12,9 @@ nginx_ppa_version: stable
# The name of the nginx package to install.
nginx_package_name: "nginx"
# If the name of the service is not nginx, it can be customized
nginx_service_name: nginx
nginx_conf_template: "nginx.conf.j2"
nginx_vhost_template: "vhost.j2"
@ -84,3 +87,6 @@ nginx_log_format: |
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
# If one does not desire to include the OS-specific variables (vars/{{ ansible_os_family }}.yaml)
nginx_include_os_vars: true

@ -1,10 +1,10 @@
---
- name: restart nginx
service: name=nginx state=restarted
service: name={{ nginx_service_name }} state=restarted
- name: validate nginx configuration
command: nginx -t -c /etc/nginx/nginx.conf
command: nginx -t -c {{ nginx_conf_file_path }}
changed_when: False
- name: reload nginx
service: name=nginx state=reloaded
service: name={{ nginx_service_name }} state=reloaded

@ -2,6 +2,7 @@
# Variable setup.
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
when: nginx_include_os_vars
- name: Define nginx_user.
set_fact:
@ -42,4 +43,4 @@
- reload nginx
- name: Ensure nginx is started and enabled to start at boot.
service: name=nginx state=started enabled=yes
service: name={{ nginx_service_name }} state=started enabled=yes