diff --git a/README.md b/README.md index d8f45db..e285571 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,11 @@ Configures Nginx's [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_mod (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. diff --git a/defaults/main.yml b/defaults/main.yml index cbce58a..0509dbe 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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" diff --git a/tasks/main.yml b/tasks/main.yml index fd523d9..bfb5fe4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -41,5 +41,8 @@ notify: - 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. + service: + name: nginx + state: "{{ nginx_service_state }}" + enabled: "{{ nginx_service_enabled }}"