Skip to content

Instantly share code, notes, and snippets.

@abutcher
Created April 4, 2014 01:09
Show Gist options
  • Select an option

  • Save abutcher/9966083 to your computer and use it in GitHub Desktop.

Select an option

Save abutcher/9966083 to your computer and use it in GitHub Desktop.
Don't puke!
# Class: aws::failover::secondaryip
#
# Associate a secondary IP to the primary interface of a node.
#
# Parameters:
# service_ip - The ip address you've pre-allocated for the service
# aws_user - The system user who will be executing the aws call
#
# Sample Usage :
# class { 'aws::failover::secondaryip':
# service_ip => 'A REAL IP ADDRESS',
# aws_user => 'A REAL ACCOUNT YOU MADE',
# }
#
class aws::failover::secondaryip ( $service_ip, $aws_user ) {
exec { 'assign-private-ip-address' :
command => "su -c \'aws ec2 assign-private-ip-addresses --allow-reassignment --network-interface-id $(aws ec2 describe-instances --instance-ids ${::hostname} | grep NetworkInterfaceId | cut -d\\\" -f4) --private-ip-addresses ${service_ip}\' ${aws_user}",
unless => "ping -c 3 -W 1 ${service_ip}",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment