Automate

swright_mm
New Contributor III

Is there a way you can replicate automatically to distros from the master share without having to go into casper admin and click replicate to all points one by one? We have our Master share on a windows environment but all of the other distro points are on Mac Minis.

5 REPLIES 5

mm2270
Legendary Contributor III

Yes, its possible. We have a process that does this. We also have our distros on Mac minis and our master is on a Windows VM.
What we did was created shell scripts that are run automatically a couple of times a day from the minis that mount the main/Master distribution point on the Mac and do a rsync operation back to the secondary DPs to sync everything up. So, if we add in a package to the master, at some point in the day, a sync automatically occurs to our other DPs. This happens via a LaunchDaemon that runs on a schedule. But I can also SSH into each Mac mini and simply call the script manually from Terminal to run it on each one if I need to make sure the sync happens quickly.

Since the Windows share is not always connected to our Mac minis, there isn't an effective way to trigger the sync to happen the moment it sees a change. IOW, we can't use something like a WatchPath or such to trigger it to occur, hence why the LaunchDaemon with the StartInterval on how often to run it.

swright_mm
New Contributor III

@mm2270 Do you have an example of that script that I can use, Where I can altar it myself to fit our environment? When you add a package to the master DP, it automatically replicates to the Mac Mini DPs? How are you creating the Launch Dameon?

donmontalvo
Esteemed Contributor III

If you're lucky enough to have your DPs on RHEL...

rsync-replication.sh script:

#!/bin/sh
/sbin/pidof rsync || /usr/bin/rsync --log-file=rsync-replication.log --archive --verbose --delete --progress -h -e ssh "casperwriteaccount@server.domain.com:/srv/samba/CasperShare/" "/srv/samba/CasperShare/"
exit 0

Drop this into /etc/crontab, or anacron it if you are using that:

*/15  *  *  *  * casperwriteaccount /path/to/rsync-replication.sh

See @bentoms's blog for SSH using passwordless RSA keys.

cron runs the script every 15 minutes. pidof is used to see if the rsync process is running, if so it exits...else it runs, keeping DP Replica in sync with DP Master.

Log file is created in same directory as script, for ongoing tracking/troubleshooting. At some point we plan to have a second script email us cumulative daily logs.

HTH,
Don

--
https://donmontalvo.com

rtrouton
Release Candidate Programs Tester

To follow up on @donmontalvo's post above, please see below for the relevant @bentoms blogpost:

https://macmule.com/2015/05/19/making-the-most-of-mac-mini-for-use-with-the-casper-suite/ (see the Keeping it all in Sync section.)

donmontalvo
Esteemed Contributor III

To follow up on @rtrouton's follow up to @donmontalvo's post pointing to @bentoms's blog, waiting with bated breath for a blog from either on how to email logs daily from our RHEL servers. :p

--
https://donmontalvo.com