def cluster_changed(): CONFIGS.write_all() if relation_ids('cluster'): peer_echo(includes=['dbsync_state']) dbsync_state = peer_retrieve('dbsync_state') if dbsync_state == 'complete': enable_services() cmd_all_services('start') else: log('Database sync not ready. Shutting down services') disable_services() cmd_all_services('stop')