@task
def upload_saltstates():
    if env.host != env.master_server.public_ip:
        abort("tried to upload salttates on a non-master server")
    if not exists(settings.REMOTE_STATES_DIR, use_sudo=True):
        sudo("mkdir --parents {0}".format(settings.REMOTE_STATES_DIR))

    # catch rsync issue with emacs autosave files
    temp_files = []
    for path in (settings.LOCAL_STATES_DIR, settings.LOCAL_PILLARS_DIR):
        for match in ("#*#", ".#*"):
            temp_file = local('find {0} -name "{1}"'.format(path, match), capture=True)
            if temp_file:
                temp_files.append(temp_file)
    if temp_files:
        print(red("Temp files must not exist in the saltstates or pillars dirs."))
        for temp_file in temp_files:
            print(yellow("found: {0}".format(temp_file)))
        abort("Found temp files in the saltstates or pillars dirs.")

    # rsync pillar and salt files to the fabric users local directory
    local('rsync -a -e "ssh -p {0}" --rsync-path="sudo rsync" {1} {2}@{3}:{4}'.format(
        env.port, settings.LOCAL_STATES_DIR, env.user, env.host, settings.REMOTE_STATES_DIR))
    local('rsync -a -e "ssh -p {0}" --rsync-path="sudo rsync" {1} {2}@{3}:{4}'.format(
        env.port, settings.LOCAL_PILLARS_DIR, env.user, env.host, settings.REMOTE_PILLARS_DIR))
Upload the salt states to all servers.
dataset/ETHPy150Open rizumu/bootmachine/bootmachine/contrib/configurators/salt.py/upload_saltstates