Merge pull request #156 from spreedly/restart_via_handler

Don't start service in tasks. Defer to handlers to allow further configuration outside of role.
pull/193/head 2.7.0
Jeff Geerling 5 years ago committed by GitHub
commit 79650c5886
No known key found for this signature in database
  1. 5
  2. 3
  3. 7

@ -150,6 +150,11 @@ Configures Nginx's [`log_format`](
(For RedHat/CentOS only) Set this to `false` to disable the installation of the `nginx` yum repository. This could be necessary if you want the default OS stable packages, or if you use Satellite.
nginx_service_state: started
nginx_service_enabled: yes
By default, this role will ensure Nginx is running and enabled at boot after Nginx is configured. You can use these variables to override this behavior if installing in a container or further control over the service state is required.
## Overriding configuration templates
If you can't customize via variables because an option isn't exposed, you can override the template used to generate the virtualhost configuration files or the `nginx.conf` file.

@ -12,6 +12,9 @@ nginx_ppa_version: stable
# The name of the nginx package to install.
nginx_package_name: "nginx"
nginx_service_state: started
nginx_service_enabled: true
nginx_conf_template: "nginx.conf.j2"
nginx_vhost_template: "vhost.j2"

@ -41,5 +41,8 @@
- reload nginx
- name: Ensure nginx is started and enabled to start at boot.
service: name=nginx state=started enabled=yes
- name: Ensure nginx service is running as configured.
name: nginx
state: "{{ nginx_service_state }}"
enabled: "{{ nginx_service_enabled }}"