Basic beacons.present state is not working
Description of Issue
Trying to set up just a basic service beacon for a Windows application called Log Insight. I just need the service beacon to be running and enabled, but following the Salt docs exactly is giving me only errors.
I also need to add onchangeonly: True but the documentation doesn't say how to properly include it.
The service is called LogInsightAgentService.
Setup
/etc/salt/master.d/reactor.conf
reactor:
- 'salt/beacon/*/service/*':
- /srv/reactor/ez_service_reactor.sls
/srv/reactor/ez_service_reactor.sls
{% if data[data['service_name']]['running'] == False %}
start_{{data['service_name']}}:
local.service.start:
- tgt: {{data['id']}}
- args:
- name: {{data['service_name']}}
{% endif %}
/srv/salt/loginsight/beacons.sls
log_insight_test:
beacon.present:
- save: True
- enable: True
- services:
LogInsightAgentService: running
Steps to Reproduce Issue
master debug
[DEBUG ] return event: {u'mvs-minion': {u'jid': u'20191210105640641232', u'retcode': 2, u'ret': {u'beacon_|-log_insight_test_|-log_insight_test_|-present': {u'comment': u'Beacon "log_insight_test" is not available.', u'name': u'log_insight_test', u'start_time': u'10:56:50.595607', u'result': False, u'duration': 93.74, u'__run_num__': 0, u'__sls__': u'loginsight.beacons', u'changes': {}, u'__id__': u'log_insight_test'}}, u'out': u'highstate'}}
[DEBUG ] LazyLoaded highstate.output
mvs-minion:
----------
ID: log_insight_test
Function: beacon.present
Result: False
Comment: Beacon "log_insight_test" is not available.
Started: 10:56:50.595607
Duration: 93.74 ms
Changes:
Summary for mvs-minion
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 93.740 ms
Versions Report
salt-master
Salt Version:
Salt: 2018.3.4
Dependency Versions:
cffi: 1.6.0
cherrypy: unknown
dateutil: 1.5
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: 0.26.3
libnacl: Not Installed
M2Crypto: 0.31.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.14
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: 0.26.4
Python: 2.7.5 (default, Jun 11 2019, 14:33:56)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: redhat 7.7 Maipo
locale: UTF-8
machine: x86_64
release: 3.10.0-1062.el7.x86_64
system: Linux
version: Red Hat Enterprise Linux Server 7.7 Maipo
salt-minion
Salt Version:
Salt: 2018.3.4
Dependency Versions:
cffi: 1.10.0
cherrypy: 10.2.1
dateutil: 2.6.1
docker-py: Not Installed
gitdb: 2.0.5
gitpython: 2.1.3
ioflo: Not Installed
Jinja2: 2.9.6
libgit2: Not Installed
libnacl: 1.6.1
M2Crypto: Not Installed
Mako: 1.0.6
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: Not Installed
pycparser: 2.17
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]
python-gnupg: 0.4.1
PyYAML: 3.12
PyZMQ: 16.0.3
RAET: Not Installed
smmap: 2.0.5
timelib: 0.2.4
Tornado: 4.5.1
ZMQ: 4.1.6
System Versions:
dist:
locale: cp1252
machine: AMD64
release: 2016Server
system: Windows
version: 2016Server 10.0.14393 SP0 Multiprocessor Free
@evenyougreg Thanks for the report. Currently in the beacon module and state module you need to specify the name of the beacon in question, in this case the service beacon. You can also include additional arguments for the beacon, such as onchangeonly as additional arguments in the state file. For example, an updated version of your state file from above:
service:
beacon.present:
- save: True
- enable: True
- services:
LogInsightAgentService: running
- onchangeonly: True
@garethgreenaway Using that code I am now getting:
minion:
----------
ID: service
Function: beacon.present
Result: False
Comment: Beacon service configuration invalid, not adding.
Configuration for service beacon must be a list of dictionaries.
Started: 10:33:15.339996
Duration: 75.856 ms
Changes:
Summary for minion
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Any further help on this would be great, I'm still stuck.
On Sun, Jan 19, 2020, 10:34 AM stale[bot] [email protected] wrote:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/saltstack/salt/issues/55591?email_source=notifications&email_token=AKMJWSAG2HC2VNMPPPWS26LQ6SFJ7A5CNFSM4JZB6MU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJKXVWA#issuecomment-576027352, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKMJWSHSCULTMZXKQ5FR2A3Q6SFJ7ANCNFSM4JZB6MUQ .
Thank you for updating this issue. It is no longer marked as stale.
@evenyougreg Apologies for the delay in responding. Looks like I might have combined the configuration the ps beacon and the service beacon, the below configuration for the service beacon will work:
service:
beacon.present:
- save: True
- enable: True
- services:
LogInsightAgentService:
onchangeonly: True
Yup, this worked! Hazaa!
Thanks @garethgreenaway
@evenyougreg Great! I'll go ahead and close this one. Thanks!
I was having a similar problem but when I try the updated beacon you provided I get this output: ` [root@HOSTNAME minion]# salt '*' state.sls minion.beacons HOSTNAME:
ID: service
Function: beacon.present
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/state.py", line 1981, in call
**cdata['kwargs'])
File "/usr/lib/python3.6/site-packages/salt/loader.py", line 1977, in wrapper
return f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/states/beacon.py", line 130, in present
result = __salt__['beacons.add'](name, beacon_data, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/modules/beacons.py", line 181, in add
valid = event_ret['valid']
TypeError: 'NoneType' object is not subscriptable
Started: 16:40:41.768246
Duration: 60045.085 ms
Changes:
Summary for HOSTNAME
Succeeded: 0 Failed: 1
Total states run: 1 Total run time: 60.045 s `