salt stack - Make minion wait until Master runner complete -
i'm trying have master send script minion backs database , files. want master rsync files have been created backup script fire event backup complete master. master handles event in reactor , starts runner performs rsync.
i want minion wait runner complete , return before reports state 'backup-complete' successful. minion reports state executed without waiting response of runner.
my current setup works this:
run backup script on minion the master
salt 'minion' state.sls backup
the minion triggers event backup complete (and returns immedieately)
backup-complete: module.run: - name: 'event.fire_master' - fun: fire_master - tag: backup/complete - data: {"status":"backup complete"}
the master has reactor catches event , calls runner
backup_complete: runner.sync-backup.sync: - status: {{ data['data']['status'] }}
the runner executes rsync command sync files , directories , returns exit code
def sync(status): command = "myrsyncscript.sh arg0 arg1" result = os.system(command) >> 8 return result
i've been thinking having minion wait , listen 'rsync/complete' event triggered master can't find how create eventlisteners on minion nor how make wait. solution i've looked @ 'salt.modules.cp.push' although documentation warns agains using security reasons.
the solution seems overly complicated me perhaps approaching wrong way. thoughts welcome.
you can run reactor on minion, i'm pretty sure listens on own event bus. don't believe there command send message master minion on event bus.
i think best bet have runner on master execute call on minion through salt's normal execution modules.
Comments
Post a Comment