Create a windows service in a salt state

1.4k Views Asked by At

I know how to create a windows service by doing,

salt service.create "servicename" "c:\executable.exe" display="serviceIcreated"

How can I incorportate this into a state?

c:\temp\somedir:
  file.recurse:
    -source: salt:/d/ser
1

There are 1 best solutions below

1
On BEST ANSWER

As the service.create is not available in Salt States you will need to run the execution module from within your own state or sls file.

You could do it this way:

create_executable:
  module.run:
    - name: service.create
    - m_name: servicename
    - bin_path: c:\executable.exe
    - display: serviceIcreated

About the piece of code in your question I did not understand how it adds value to your question.

c:\temp\somedir:   
   file.recurse:
    -source: salt:/d/ser

If it is relevant, please make an edit in order to make it easier to understand.