saltstack-formulas / nginx-formula

Nginx Salt Formula
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
163 stars 421 forks source link

[FEATURE] Enable service without starting it #302

Open SkypLabs opened 1 year ago

SkypLabs commented 1 year ago

Is your feature request related to a problem?

It is not possible to enable the Nginx service without starting it as shown here:

{% set service_function = {True:'running', False:'dead'}.get(nginx.service.enable) %}

I would like to be able to enable the service without starting it (useful when creating VM images) or start the service without enabling it.

Describe the solution you'd like

I would suggest dissociating the Salt state function to use (e.g. running, dead) from the value of the enable pillar option:

nginx:
  service:
    enable: true
    start: true

By introducing the new pillar option start, it becomes possible to enable the service without starting it and vice versa:

{% set service_function = {True:'running', False:'dead'}.get(nginx.service.start) %}

...

nginx_service:
  service.{{ service_function }}:
    {{ sls_block(nginx.service.opts) }}
    - name: {{ nginx.lookup.service }}
    - enable: {{ nginx.service.enable }}
    ...

This is made possible because both running and dead functions have the same enable parameter to enable or not the service.

Describe alternatives you've considered

Nothing comes to my mind.

Additional context

Nothing to add.