Description
I have a salt state which enables then starts a service via the win_service module, which i understand to be mapped to the service state to be called via cli or via the state. I have a minion setup to use highstate on startup, and it errors out when trying to call service.enable and service.start saying "Reason: 'service.start' is not available." i can however do a salt-call from the cli and get the command to work correctly?
State
EnableStartInfraAgent:
service.enable:
- name: newrelic-infra
- start_type: auto
StartInfraAgent:
service.start:
- name: newrelic-infra
Verified on the minion host that both are available:
PS C:\Windows\system32> salt-call sys.list_functions 'service*'
local:
- service.available
- service.create
- service.create_win_salt_restart_task
- service.delete
- service.disable
- service.disabled
- service.enable
- service.enabled
- service.execute_salt_restart_task
- service.get_all
- service.get_disabled
- service.get_enabled
- service.get_service_name
- service.getsid
- service.info
- service.missing
- service.modify
- service.restart
- service.start
- service.status
- service.stop
When calling state.apply from the host:
PS C:\Windows\system32> salt-call state.apply
[ERROR ] State 'service.enable' was not found in SLS 'newrelic.windows'
Reason: 'service.enable' is not available.
[ERROR ] State 'service.start' was not found in SLS 'newrelic.windows'
Reason: 'service.start' is not available.
local:
----------
ID: C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml
Function: file.managed
Result: True
Comment: File C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml is in the correct state
Started: 15:19:16.363128
Duration: 158.555 ms
Changes:
----------
ID: EnableStartInfraAgent
Function: service.enable
Name: newrelic-infra
Result: False
Comment: State 'service.enable' was not found in SLS 'newrelic.windows'
Reason: 'service.enable' is not available.
Changes:
----------
ID: StartInfraAgent
Function: service.start
Name: newrelic-infra
Result: False
Comment: State 'service.start' was not found in SLS 'newrelic.windows'
Reason: 'service.start' is not available.
Changes:
----------
ID: C:\Program Files\New Relic\newrelic-infra\integrations.d\mssql-config.yml
Function: file.managed
Result: True
Comment: File C:\Program Files\New Relic\newrelic-infra\integrations.d\mssql-config.yml is in the correct state
Started: 15:19:23.708926
Duration: 15.622 ms
Changes:
----------
ID: salt://newrelic/scripts/Setup-SQLAgent.ps1
Function: cmd.script
Result: True
Comment: Command 'salt://newrelic/scripts/Setup-SQLAgent.ps1' run
Started: 15:19:23.724548
Duration: 2148.207 ms
Changes:
----------
pid:
3152
retcode:
0
stderr:
stdout:
Downloading NewRelic infrastructure mssql agent
Installing NewRelic infrastructure service
Restarting NewRelic infrastructure service
Summary for local
------------
Succeeded: 3 (changed=1)
Failed: 2
------------
Total states run: 5
Total run time: 2.322 s
When running with debug this is all i get for those states
[DEBUG ] Could not LazyLoad service.enable: 'service.enable' is not available.
[INFO ] Running state [newrelic-infra] at time 15:58:48.878047
[DEBUG ] Could not LazyLoad service.enable: 'service.enable' is not available.
[ERROR ] State 'service.enable' was not found in SLS 'newrelic.windows'
Reason: 'service.enable' is not available.
[DEBUG ] Could not LazyLoad service.start: 'service.start' is not available.
[INFO ] Running state [newrelic-infra] at time 15:58:48.919492
[DEBUG ] Could not LazyLoad service.start: 'service.start' is not available.
[ERROR ] State 'service.start' was not found in SLS 'newrelic.windows'
Reason: 'service.start' is not available.
When calling the command directly from the host i can run without any issues:
PS C:\Windows\system32> salt-call service.start newrelic-infra
local:
True
Versions Report
Minion
salt --versions-report
PS C:\Windows\system32> salt-minion --versions-report
Salt Version:
Salt: 3001.1
Dependency Versions:
cffi: 1.12.2
cherrypy: 17.4.1
dateutil: 2.8.0
docker-py: Not Installed
gitdb: 2.0.5
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: Not Installed
M2Crypto: Not Installed
Mako: 1.0.7
msgpack-pure: Not Installed
msgpack-python: 1.0.0
mysql-python: Not Installed
pycparser: 2.19
pycrypto: Not Installed
pycryptodome: 3.9.7
pygit2: Not Installed
Python: 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
python-gnupg: 0.4.4
PyYAML: 5.3.1
PyZMQ: 18.0.1
smmap: 2.0.5
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist:
locale: cp1252
machine: AMD64
release: 2016Server
system: Windows
version: 2016Server 10.0.14393 SP0
Master:
salt --versions-report
root@userundeck1b:/etc/salt/minion.d# salt --versions-report
Salt Version:
Salt: 3000.2
Dependency Versions:
cffi: Not Installed
cherrypy: 3.5.0
dateutil: 2.6.1
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
Jinja2: 2.8
libgit2: Not Installed
M2Crypto: Not Installed
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: 1.3.7
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.12 (default, Jul 21 2020, 15:19:50)
python-gnupg: 0.3.8
PyYAML: 3.12
PyZMQ: 15.2.0
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
locale: UTF-8
machine: x86_64
release: 4.4.0-178-generic
system: Linux
version: Ubuntu 16.04 xenial
Are you perhaps confusing states and execution modules here? States only have service.enabled as far as I can see.
i did some reading on state and execution module and i understand my mix up now. Thanks for the quick clarification! Closing this
Most helpful comment
Are you perhaps confusing states and execution modules here? States only have service.enabled as far as I can see.