saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.13k stars 5.47k forks source link

[FEATURE REQUEST] Allow starting not enabled services on Windows minions #59518

Open adcpdk opened 3 years ago

adcpdk commented 3 years ago

Hi,

I have a case where service MUST be started manually and 'enable: True' is not a solution.

As a temporary workaround I used modules:

{# Waiting for investigation. Stopped working as of update to salt version 3002.2 on Windows hosts
Receiving error message:
'set enabled to true to successfully start the service'
start_service_{{ service_name }}:
  service.running:
  - name: {{ service_name }}
#}

{% if salt['service.start'](service_name) == True %}
start_service_{{ service_name }}:
  test.show_notification:
    - text: {{ service_name }} started
{% else %}
failed_to_start_service_{{ service_name }}:
  test.fail_without_changes:
    - text: {{ service_name }} failed to start
{% endif %}

My final Windows service should look the following way: Manual (Service should not be started at the boot time) Running (service.running state)

If I try to set 'enable: True' and run service.disabled, service becomes: Disabled Running

Ideally we should have three types of 'enable' state that is:

I am wondering what was the reason reason behind this implementation, is there any Microsoft article that explicitly says that the service MUST be enabled in order to run?

Reference commit by @weswhet @dwoz : https://github.com/saltstack/salt/commit/4798babaef859ac39c1499bba12680580cf3e5c4#diff-2f7c8c335ccacbfa84a72e52f66a67fd926e52f221ca9807ad7f7ed3814d0962R517

welcome[bot] commented 3 years ago

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. If you have additional questions, email us at core@saltstack.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

xeacott commented 3 years ago

Hmm @adcpdk that's a great question. Personally not familiar with any specifics like that but @twangboy would probably have an answer...

twangboy commented 3 years ago

You can't start a disabled service on Windows. You can start a service that is set to manual. Salt should support that behavior. We should investigate this further to see how the service module works exactly with services on Windows. Document and make it work correctly.

xeacott commented 3 years ago

Yeah just off first glance, we may need to add that ability to the service itself as a "Startup type". Typically there's

Automatic
Automatic (Delayed Start)
Manual
Disabled

and then offer the feature to set the service startup type to manual and have that be apart of of the state.

adcpdk commented 3 years ago

You can't start a disabled service on Windows. You can start a service that is set to manual. Salt should support that behavior. We should investigate this further to see how the service module works exactly with services on Windows. Document and make it work correctly.

Hi @twangboy my initial request stated exactly the following:

Manual (Service should not be started at the boot time)
Running (service.running state)

thanks for looking into this. FYI it worked perfectly fine before the following commit was merged: https://github.com/saltstack/salt/commit/4798babaef859ac39c1499bba12680580cf3e5c4#diff-2f7c8c335ccacbfa84a72e52f66a67fd926e52f221ca9807ad7f7ed3814d0962R517