Last active
August 29, 2015 13:57
-
-
Save peterfroehlich/9660897 to your computer and use it in GitHub Desktop.
Salt executor method to sync files to syndics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sync_syndic(): | |
''' | |
Sync defined folders and files from the salt master to the syndic fileserver | |
Looks for production specific top file to replace top.sls on syndics | |
''' | |
base_dir = "/srv/salt/" | |
dirs_to_sync = ["salt-cloud", "_modules", "_grains", "_runners", "scripts", "states"] | |
files_to_sync = [] | |
production_top = "top-prod.sls" | |
file_counter = 0 | |
dir_counter = 0 | |
output = [] | |
for dir in dirs_to_sync: | |
complete_path = base_dir #+ dir | |
dir_counter += 1 | |
output += __salt__["cp.get_dir"]("salt://"+dir, complete_path) | |
for file_ in files_to_sync: | |
complete_path = base_dir + file_ | |
file_counter += 1 | |
output += [__salt__["cp.get_file"]("salt://"+file_, complete_path)] | |
# copy production top.sls | |
complete_path = base_dir + "top.sls" | |
file_counter += 1 | |
output += [__salt__["cp.get_file"]("salt://" + production_top, complete_path)] | |
return "\n".join(output) + "\n\nCopied files %d, copied dirs %d" % (file_counter, dir_counter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment