Blame SOURCES/bz1759115-aws-vpc-route53-2-add-public-and-secondary-ip-support.patch

d42a06
From 9b77d06bfe3308692946b8ac08bc7ec3399a762b Mon Sep 17 00:00:00 2001
d42a06
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
d42a06
Date: Thu, 2 Apr 2020 13:38:30 +0200
d42a06
Subject: [PATCH 1/2] aws-vpc-route53: cleanup and improvements
d42a06
d42a06
---
d42a06
 heartbeat/aws-vpc-route53.in | 73 ++++++++++++++++++++----------------
d42a06
 1 file changed, 41 insertions(+), 32 deletions(-)
d42a06
d42a06
diff --git a/heartbeat/aws-vpc-route53.in b/heartbeat/aws-vpc-route53.in
d42a06
index b276dfb3c..1cfc2b01f 100644
d42a06
--- a/heartbeat/aws-vpc-route53.in
d42a06
+++ b/heartbeat/aws-vpc-route53.in
d42a06
@@ -43,8 +43,14 @@
d42a06
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
d42a06
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
d42a06
 
d42a06
+OCF_RESKEY_hostedzoneid_default=""
d42a06
+OCF_RESKEY_fullname_default=""
d42a06
+OCF_RESKEY_ip_default="local"
d42a06
 OCF_RESKEY_ttl_default=10
d42a06
 
d42a06
+: ${OCF_RESKEY_hostedzoneid:=${OCF_RESKEY_hostedzoneid_default}}
d42a06
+: ${OCF_RESKEY_fullname:=${OCF_RESKEY_fullname_default}}
d42a06
+: ${OCF_RESKEY_ip:=${OCF_RESKEY_ip_default}}
d42a06
 : ${OCF_RESKEY_ttl:=${OCF_RESKEY_ttl_default}}
d42a06
 
d42a06
 #######################################################################
d42a06
@@ -104,7 +110,7 @@ Hosted zone ID of Route 53. This is the table of
d42a06
 the Route 53 record.
d42a06
 </longdesc>
d42a06
 <shortdesc lang="en">AWS hosted zone ID</shortdesc>
d42a06
-<content type="string" default="" />
d42a06
+<content type="string" default="${OCF_RESKEY_hostedzoneid_default}" />
d42a06
 </parameter>
d42a06
 <parameter name="fullname" required="1">
d42a06
 <longdesc lang="en">
d42a06
@@ -113,7 +119,7 @@ Example: service.cloud.example.corp.
d42a06
 Note: The trailing dot is important to Route53!
d42a06
 </longdesc>
d42a06
 <shortdesc lang="en">Full service name</shortdesc>
d42a06
-<content type="string" default="" />
d42a06
+<content type="string" default="${OCF_RESKEY_fullname_default}" />
d42a06
 </parameter>
d42a06
 <parameter name="ttl" required="0">
d42a06
 <longdesc lang="en">
d42a06
@@ -189,6 +195,31 @@ r53_validate() {
d42a06
 	return $OCF_SUCCESS
d42a06
 }
d42a06
 
d42a06
+r53_start() {
d42a06
+	#
d42a06
+	# Start agent and config DNS in Route53
d42a06
+	#
d42a06
+	ocf_log info "Starting Route53 DNS update...."
d42a06
+	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
d42a06
+	r53_monitor
d42a06
+	if [ $? != $OCF_SUCCESS ]; then
d42a06
+		ocf_log info "Could not start agent - check configurations"
d42a06
+		return $OCF_ERR_GENERIC
d42a06
+	fi
d42a06
+	return $OCF_SUCCESS
d42a06
+}
d42a06
+
d42a06
+r53_stop() {
d42a06
+	#
d42a06
+	# Stop operation doesn't perform any API call or try to remove the DNS record
d42a06
+	# this mostly because this is not necessarily mandatory or desired
d42a06
+	# the start and monitor functions will take care of changing the DNS record
d42a06
+	# if the agent starts in a different cluster node
d42a06
+	#
d42a06
+	ocf_log info "Bringing down Route53 agent. (Will NOT remove Route53 DNS record)"
d42a06
+	return $OCF_SUCCESS
d42a06
+}
d42a06
+
d42a06
 r53_monitor() {
d42a06
 	#
d42a06
 	# For every start action the agent  will call Route53 API to check for DNS record
d42a06
@@ -339,31 +370,6 @@ _update_record() {
d42a06
 	done
d42a06
 }
d42a06
 
d42a06
-r53_stop() {
d42a06
-	#
d42a06
-	# Stop operation doesn't perform any API call or try to remove the DNS record
d42a06
-	# this mostly because this is not necessarily mandatory or desired
d42a06
-	# the start and monitor functions will take care of changing the DNS record
d42a06
-	# if the agent starts in a different cluster node
d42a06
-	#
d42a06
-	ocf_log info "Bringing down Route53 agent. (Will NOT remove Route53 DNS record)"
d42a06
-	return $OCF_SUCCESS
d42a06
-}
d42a06
-
d42a06
-r53_start() {
d42a06
-	#
d42a06
-	# Start agent and config DNS in Route53
d42a06
-	#
d42a06
-	ocf_log info "Starting Route53 DNS update...."
d42a06
-	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
d42a06
-	r53_monitor
d42a06
-	if [ $? != $OCF_SUCCESS ]; then
d42a06
-		ocf_log info "Could not start agent - check configurations"
d42a06
-		return $OCF_ERR_GENERIC
d42a06
-	fi
d42a06
-	return $OCF_SUCCESS
d42a06
-}
d42a06
-
d42a06
 ###############################################################################
d42a06
 
d42a06
 case $__OCF_ACTION in
d42a06
@@ -375,20 +381,23 @@ case $__OCF_ACTION in
d42a06
 		metadata
d42a06
 		exit $OCF_SUCCESS
d42a06
 		;;
d42a06
-	monitor)
d42a06
-		r53_monitor
d42a06
+	start)
d42a06
+		r53_validate || exit $?
d42a06
+		r53_start
d42a06
 		;;
d42a06
 	stop)
d42a06
 		r53_stop
d42a06
 		;;
d42a06
+	monitor)
d42a06
+		r53_monitor
d42a06
+		;;
d42a06
 	validate-all)
d42a06
 		r53_validate
d42a06
 		;;
d42a06
-	start)
d42a06
-		r53_start
d42a06
-		;;
d42a06
 	*)
d42a06
 		usage
d42a06
 		exit $OCF_ERR_UNIMPLEMENTED
d42a06
 		;;
d42a06
 esac
d42a06
+
d42a06
+exit $?
d42a06
d42a06
From 745c6b9b3e331ed3705a641f1ec03a2604de3a1d Mon Sep 17 00:00:00 2001
d42a06
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
d42a06
Date: Thu, 2 Apr 2020 13:40:33 +0200
d42a06
Subject: [PATCH 2/2] aws-vpc-route53: add support for public and secondary
d42a06
 private IPs
d42a06
d42a06
---
d42a06
 heartbeat/aws-vpc-route53.in | 31 +++++++++++++++++++++++++++++--
d42a06
 1 file changed, 29 insertions(+), 2 deletions(-)
d42a06
d42a06
diff --git a/heartbeat/aws-vpc-route53.in b/heartbeat/aws-vpc-route53.in
d42a06
index 1cfc2b01f..ca6556951 100644
d42a06
--- a/heartbeat/aws-vpc-route53.in
d42a06
+++ b/heartbeat/aws-vpc-route53.in
d42a06
@@ -121,6 +121,15 @@ Note: The trailing dot is important to Route53!
d42a06
 <shortdesc lang="en">Full service name</shortdesc>
d42a06
 <content type="string" default="${OCF_RESKEY_fullname_default}" />
d42a06
 </parameter>
d42a06
+<parameter name="ip" required="0">
d42a06
+<longdesc lang="en">
d42a06
+IP (local (default), public or secondary private IP address (e.g. 10.0.0.1).
d42a06
+
d42a06
+A secondary private IP can be setup with the awsvip agent.
d42a06
+</longdesc>
d42a06
+<shortdesc lang="en">Type of IP or secondary private IP address (local, public or e.g. 10.0.0.1)</shortdesc>
d42a06
+<content type="string" default="${OCF_RESKEY_ip_default}" />
d42a06
+</parameter>
d42a06
 <parameter name="ttl" required="0">
d42a06
 <longdesc lang="en">
d42a06
 Time to live for Route53 ARECORD
d42a06
@@ -173,6 +182,15 @@ r53_validate() {
d42a06
 	# Hosted Zone ID
d42a06
 	[[ -z "$OCF_RESKEY_hostedzoneid" ]] && ocf_log error "Hosted Zone ID parameter not set $OCF_RESKEY_hostedzoneid!" && exit $OCF_ERR_CONFIGURED
d42a06
 
d42a06
+	# Type of IP/secondary IP address
d42a06
+	case $OCF_RESKEY_ip in
d42a06
+		local|public|*.*.*.*)
d42a06
+			;;
d42a06
+		*)
d42a06
+			ocf_exit_reason "Invalid value for ip: ${OCF_RESKEY_ip}"
d42a06
+			exit $OCF_ERR_CONFIGURED
d42a06
+	esac
d42a06
+
d42a06
 	# profile
d42a06
 	[[ -z "$OCF_RESKEY_profile" ]] && ocf_log error "AWS CLI profile not set $OCF_RESKEY_profile!" && exit $OCF_ERR_CONFIGURED
d42a06
 
d42a06
@@ -200,7 +218,7 @@ r53_start() {
d42a06
 	# Start agent and config DNS in Route53
d42a06
 	#
d42a06
 	ocf_log info "Starting Route53 DNS update...."
d42a06
-	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
d42a06
+	_get_ip
d42a06
 	r53_monitor
d42a06
 	if [ $? != $OCF_SUCCESS ]; then
d42a06
 		ocf_log info "Could not start agent - check configurations"
d42a06
@@ -239,7 +257,7 @@ r53_monitor() {
d42a06
 	r53_validate
d42a06
 	ocf_log debug "Checking Route53 record sets"
d42a06
 	#
d42a06
-	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
d42a06
+	_get_ip
d42a06
 	#
d42a06
 	if [ "$__OCF_ACTION" = "start" ] || ocf_is_probe ; then
d42a06
 		#
d42a06
@@ -308,6 +326,15 @@ r53_monitor() {
d42a06
 	return $OCF_SUCCESS
d42a06
 }
d42a06
 
d42a06
+_get_ip() {
d42a06
+	case $OCF_RESKEY_ip in
d42a06
+		local|public)
d42a06
+			IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/${OCF_RESKEY_ip}-ipv4)";;
d42a06
+		*.*.*.*)
d42a06
+			IPADDRESS="${OCF_RESKEY_ip}";;
d42a06
+	esac
d42a06
+}
d42a06
+
d42a06
 _update_record() {
d42a06
 	#
d42a06
 	# This function is the one that will actually execute Route53's API call