Skip to content

Instantly share code, notes, and snippets.

@davidbitton
Created February 4, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbitton/618ec77cc6b57fa6c96e to your computer and use it in GitHub Desktop.
Save davidbitton/618ec77cc6b57fa6c96e to your computer and use it in GitHub Desktop.
--
-- lsyncd conf file
--
settings {
delay = 1,
maxProcesses = 5,
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd-status.log",
}
-- iterate InSerrvice EC2 instances
local instances_command = "aws elb describe-instance-health --load-balancer-name default-load-balancer --region `ec2-metadata -z | grep -Po '(us|sa|eu|ap)-(north|south)?(east|west)?-[0-9]+'` --output text --query 'InstanceStates[*].[State, InstanceId]' | awk '$1 ~ /^InService$/{print $2}'"
local handle = io.popen(instances_command)
for line in handle:lines() do
address_command = "aws ec2 describe-instances --instance-ids " .. line .. " --region `ec2-metadata -z | grep -Po '(us|sa|eu|ap)-(north|south)?(east|west)?-[0-9]+'` --query 'Reservations[0].Instances[0].[PrivateDnsName]' --output text"
local address_handle = io.popen(address_command)
local address = address_handle:read("*l")
address_handle:close()
print(address)
sync {
default.rsyncssh,
source = "/tmp/lsyncd",
host = address,
targetdir = "/tmp/lsyncd",
rsync = {
archive = true,
compress = true
},
ssh = {
options = {
StrictHostKeyChecking="no",
UserKnownHostsFile="/dev/null"
}
}
}
end
handle:close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment