Open daks opened 6 years ago
To broaden the discussion, I'm a bit surprised to see a specific state (servers
) to handle service reload: we use this formula since a while and never imagined it would not automatically reload the service.
What I had expected is:
service_reload
set to True by default (because is what you want when you change config) which can be set to False if neededHello @daks, I'm not experiencing this behaviour since when I'm doing changes in nginx.ng.servers
pillar, the nginx
service is correctly reloaded at the end of a state.apply
with the listen
requisite of nginx_service_reload
.
The reload: True
does not exists directly in the service.running
state function but is passed as a parameter to mod_watch
triggered by the listen
requisite (salt doc states mod_wait
in salt doc but it is mod_watch
in the code).
@waynew Is this same issue you describe at #191
@noelmcloughlin Yeah, looks like it - the problem is that when you have a state like this:
start something:
service.running:
- name: someservice
- enable: True
And you've manually started your service, but didn't enable it, like this:
systemctl start nginx
systemctl enable nginx # <-- don't run this line
Salt enables the service, which says, "Hey this state changed!" mod_watch
sees, "Oh, that state has changes, no need to fire off any kind of action"
The correct thing to do in a manual setup is to have two different states, like this:
start service:
service.running:
- name: someservice
- watch:
- file: some config state
enable service:
service.enabled:
- name: someservice
some config state:
file.managed:
- name: /path/to/file
- source: salt://path/to/file
(or, you know, quit fiddling with things manually and manage them via salt :trollface: )
Guys would this patch work for you? It gets triggered by watch
too.
+{%- if nginx.restart_cmd %}
+ cmd.run:
+ - name: {{ nginx.restart_cmd }}
+{%- else %}
service.running:
- enable: True
- restart: True
+{%- endif %}
- watch:
{% if use_upstart %}
- file: nginx
Hello,
we are using the nginx.ng part of this formula on Debian 9 with Salt 2018.3.1. We use a wrapper that include the following states
I recently added
nginx.ng.servers
which seems to handle service reload when configuration change (and pillarservice.enable
is not set to False).I think it does not work as expected because I don't see any reload of service when I change config, and running salt returns
This part of the code https://github.com/saltstack-formulas/nginx-formula/blob/master/nginx/ng/servers.sls#L23 uses
reload: True
in stateservice.running
but it seems that this parameter does not exist https://docs.saltstack.com/en/latest/ref/states/all/salt.states.service.html#salt.states.service.running on 2018.3 or 2017.7.