Created
February 4, 2015 18:58
-
-
Save davidbitton/618ec77cc6b57fa6c96e to your computer and use it in GitHub Desktop.
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
-- | |
-- 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