Compare commits
No commits in common. "c06a6872c386d369a12edafd24c0c507cb89d298" and "863244ad860e07ce0ee15e5a17118884e43fc667" have entirely different histories.
c06a6872c3
...
863244ad86
@ -1,7 +0,0 @@
|
|||||||
keepalived_script_user:
|
|
||||||
user.present:
|
|
||||||
- name: keepalived_script
|
|
||||||
- createhome: False
|
|
||||||
- home: /var/lib/keepalived
|
|
||||||
- shell: /usr/sbin/nologin
|
|
||||||
- system: True
|
|
@ -1,13 +0,0 @@
|
|||||||
This profile installs a script switching failover IP addresses between Netcup hosted VM's.
|
|
||||||
|
|
||||||
Required pillar:
|
|
||||||
|
|
||||||
```
|
|
||||||
profile:
|
|
||||||
netcup_failover:
|
|
||||||
scp_user: 12345
|
|
||||||
scp_pass: xxxx
|
|
||||||
scp_server: v9876
|
|
||||||
ip4_address: xx.xx.xx.xx/32
|
|
||||||
ip6_address: 'foo:bar::/64'
|
|
||||||
```
|
|
@ -1,109 +0,0 @@
|
|||||||
{%- set header = salt['pillar.get']('managed_header_pound') -%}
|
|
||||||
{%- set mypillar = salt['pillar.get']('profile:netcup_failover') -%}
|
|
||||||
#!/bin/sh
|
|
||||||
# Floating IP switching script utilizing the Netcup API
|
|
||||||
|
|
||||||
{{ header }}
|
|
||||||
|
|
||||||
SCP_USER='{{ mypillar['scp_user'] }}'
|
|
||||||
SCP_PASS='{{ mypillar['scp_pass'] }}'
|
|
||||||
SCP_SERVER='{{ mypillar['scp_server'] }}'
|
|
||||||
MAC='{{ mypillar['mac_address'] }}'
|
|
||||||
IP_v4='{{ mypillar['ip4_address'] }}'
|
|
||||||
IP_v6='{{ mypillar['ip6_address'] }}'
|
|
||||||
|
|
||||||
URL="https://www.servercontrolpanel.de/WSEndUser?xsd=1" ### ?xsd=1 ?wsdl
|
|
||||||
|
|
||||||
usage () {
|
|
||||||
echo "$0 [--ipv4 | --ipv6 | --all] [--debug]"
|
|
||||||
exit 2
|
|
||||||
}
|
|
||||||
|
|
||||||
init () {
|
|
||||||
construct "$1"
|
|
||||||
run
|
|
||||||
parse
|
|
||||||
}
|
|
||||||
|
|
||||||
construct () {
|
|
||||||
if [ "$1" = "ip4" ];
|
|
||||||
then
|
|
||||||
local IP="$IP_v4"
|
|
||||||
fi
|
|
||||||
if [ "$1" = "ip6" ];
|
|
||||||
then
|
|
||||||
local IP="$IP_v6"
|
|
||||||
fi
|
|
||||||
local CIDR="${IP#*/}"
|
|
||||||
local IP="`echo $IP | sed "s?/$CIDR??"`"
|
|
||||||
if [ "$DEBUG" = "true" ];
|
|
||||||
then
|
|
||||||
echo "[DEBUG] Initiating: $1"
|
|
||||||
echo "[DEBUG] IP Address: $IP"
|
|
||||||
echo "[DEBUG] CIDR Mask: $CIDR"
|
|
||||||
fi
|
|
||||||
XML_BODY="<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://enduser.service.web.vcp.netcup.de/'><SOAP-ENV:Body><ns1:changeIPRouting><loginName>$SCP_USER</loginName><password>$SCP_PASS</password><routedIP>$IP</routedIP><routedMask>$CIDR</routedMask><destinationVserverName>$SCP_SERVER</destinationVserverName><destinationInterfaceMAC>$MAC</destinationInterfaceMAC></ns1:changeIPRouting></SOAP-ENV:Body></SOAP-ENV:Envelope>"
|
|
||||||
if [ "$DEBUG" = "true" ];
|
|
||||||
then
|
|
||||||
echo "[DEBUG] Payload: $XML_BODY"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
request () {
|
|
||||||
curl -s -H 'Content-Type: text/xml' -H 'SOAPAction:' -d "$XML_BODY" -X POST "$URL"
|
|
||||||
}
|
|
||||||
|
|
||||||
run () {
|
|
||||||
RESPONSE=`request`
|
|
||||||
if [ "$DEBUG" = "true" ];
|
|
||||||
then
|
|
||||||
echo "[DEBUG] Response: $RESPONSE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
parse () {
|
|
||||||
local IFS='&'
|
|
||||||
local check_invalid="validation error&IP already assigned&true"
|
|
||||||
for check in $check_invalid;
|
|
||||||
do
|
|
||||||
if [ "$DEBUG" = "true" ];
|
|
||||||
then
|
|
||||||
echo "[DEBUG] Parsing: $check"
|
|
||||||
fi
|
|
||||||
if [ "${RESPONSE#*$check}" = "$RESPONSE" ];
|
|
||||||
then
|
|
||||||
result="Not found"
|
|
||||||
fi
|
|
||||||
if [ "${RESPONSE#*$check}" != "$RESPONSE" ];
|
|
||||||
then
|
|
||||||
result="Found"
|
|
||||||
fi
|
|
||||||
echo "Check for \"$check\": $result"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
MODE="$1"
|
|
||||||
|
|
||||||
if [ "$2" = "--debug" ];
|
|
||||||
then
|
|
||||||
DEBUG="true"
|
|
||||||
echo "[DEBUG] Script invoked at `date`"
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$MODE" in
|
|
||||||
"--ipv4" )
|
|
||||||
init ip4
|
|
||||||
;;
|
|
||||||
"--ipv6" )
|
|
||||||
init ip6
|
|
||||||
;;
|
|
||||||
"--all" )
|
|
||||||
init ip6
|
|
||||||
init ip4
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
include:
|
|
||||||
- profile.keepalived_script_user
|
|
||||||
|
|
||||||
/usr/local/bin/failover:
|
|
||||||
file.managed:
|
|
||||||
- user: keepalived_script
|
|
||||||
- group: wheel
|
|
||||||
- mode: 750
|
|
||||||
- template: jinja
|
|
||||||
- source: salt://{{ slspath }}/files/failover.sh.j2
|
|
@ -1,3 +0,0 @@
|
|||||||
include:
|
|
||||||
- profile.netcup_failover
|
|
||||||
- role.ha-node
|
|
Loading…
x
Reference in New Issue
Block a user