Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #34 from HubbleStack/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
basepi authored Sep 8, 2016
2 parents e6b2813 + 6887405 commit 5eb842c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
13 changes: 10 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ Pulsar to be flexible.
# pillar.example
beacons:
pulsar:
paths:
- salt://hubblestack_pulsar_config.yaml
pulsar:
paths:
- /var/cache/salt/minion/files/base/hubblestack_pulsar_config.yaml
schedule:
cache_nebula:
function: cp.cache_file
seconds: 86400
args:
- salt://hubblestack_pulsar_config.yaml
return_job: False
# hubblestack_pulsar_config.yaml
Expand Down
18 changes: 12 additions & 6 deletions _beacons/pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def beacon(config):
beacons:
pulsar:
paths:
- salt://hubblestack_pulsar_config.yaml
- /var/cache/salt/minion/files/base/hubblestack_pulsar_config.yaml
refresh_frequency: 60
verbose: False
Expand Down Expand Up @@ -174,17 +174,23 @@ def beacon(config):
new_config = config
if isinstance(config.get('paths'), list):
for path in config['paths']:
cpath = __salt__['cp.cache_file'](path)
if os.path.isfile(cpath):
with open(cpath, 'r') as f:
if 'salt://' in path:
log.error('Path {0} is not an absolute path. Please use a '
'scheduled cp.cache_file job to deliver the '
'config to the minion, then provide the '
'absolute path to the cached file on the minion '
'in the beacon config.'.format(path))
continue
if os.path.isfile(path):
with open(path, 'r') as f:
new_config = _dict_update(new_config,
yaml.safe_load(f),
recursive_update=True,
merge_lists=True)
else:
log.error('Path {0} does not exist or is not a file'.format(cpath))
log.error('Path {0} does not exist or is not a file'.format(path))
else:
log.error('Pulsar beacon \'paths\' data improperly formatted. Should be list of salt:// paths')
log.error('Pulsar beacon \'paths\' data improperly formatted. Should be list of paths')

new_config.update(config)
config = new_config
Expand Down
10 changes: 9 additions & 1 deletion pillar.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
beacons:
pulsar:
paths:
- salt://hubblestack_pulsar_config.yaml
- /var/cache/salt/minion/files/base/hubblestack_pulsar_config.yaml
disable_during_state_run: True

schedule:
cache_nebula:
function: cp.cache_file
seconds: 86400
args:
- salt://hubblestack_pulsar_config.yaml
return_job: False

0 comments on commit 5eb842c

Please sign in to comment.