Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNS failover #122

Open
wants to merge 11 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion data/nodes/alpha.theclarkhome.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ profile::platform::baseline::debian::netplan::ethernets:
dhcp4: no
addresses:
- "%{lookup('defaults::subnet')}.21/%{lookup('defaults::bits')}"
gateway4: "%{lookup('defaults::gateway')}"
routes:
- to: 'default'
via: "%{lookup('defaults::gateway')}"
nameservers:
search: "%{alias('defaults::dns::search')}"
addresses:
Expand Down
4 changes: 3 additions & 1 deletion data/nodes/bravo.theclarkhome.com.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ profile::platform::baseline::debian::netplan::ethernets:
dhcp4: no
addresses:
- "%{lookup('defaults::subnet')}.22/%{lookup('defaults::bits')}"
gateway4: "%{lookup('defaults::gateway')}"
routes:
- to: 'default'
via: "%{lookup('defaults::gateway')}"
nameservers:
search: "%{alias('defaults::dns::search')}"
addresses:
Expand Down
8 changes: 7 additions & 1 deletion site-modules/profile/manifests/app/dhcpd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class profile::app::dhcpd (
Optional[Enum['primary','secondary']] $role = undef,
Optional[Stdlib::IP::Address] $peer_address = undef,
Boolean $use_dns_vip = false,
) {
$owner = 'dhcpd'
$group = 'dhcpd'
Expand All @@ -13,9 +14,14 @@
# Core dhcpd configuration
$domain = $trusted['domain']

$nameservers = $use_dns_vip ? {
true => lookup('defaults::dns::vip'),
default => lookup('defaults::dns::nameservers'),
}

class { 'dhcp':
interfaces => [ $facts['networking']['primary'] ],
nameservers => lookup('defaults::dns::nameservers'),
nameservers => $nameservers,
ntpservers => [ "foxtrot.${domain}", "golf.${domain}" ],
dnssearchdomains => lookup('defaults::dns::search'),
default_lease_time => 28800,
Expand Down
45 changes: 24 additions & 21 deletions site-modules/profile/manifests/app/keepalived/dns.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,51 @@

include profile::app::keepalived::notify

keepalived::vrrp::script { 'check_dns':
script => '/usr/bin/killall -0 nginx',
}
# keepalived::vrrp::script { 'check_dns':
# script => '/usr/bin/killall -0 nginx',
# }

# VRRP
# keepalived::vrrp::instance { 'VI_DNS':
# interface => $lan,
# lvs_interface => 'veth-dns',
# state => 'BACKUP',
# virtual_router_id => 51,
# priority => 150,
# auth_type => 'PASS',
# auth_pass => lookup('secrets::keepalived'),
# virtual_ipaddress => [ $v_ip ],
## track_interface => [ $wan, "${vpn} weight 5"], # optional, monitor these interfaces.
# #track_script => 'check_dns',
# }
keepalived::vrrp::instance { 'VI_50':
interface => $lan,
#lvs_interface => 'veth-dns',
state => 'BACKUP',
virtual_router_id => 51,
priority => 150,
auth_type => 'PASS',
auth_pass => lookup('secrets::keepalived'),
virtual_ipaddress => [ "${$v_ip}/${lookup('defaults::bits')}" ],
# track_interface => [ $wan, "${vpn} weight 5"], # optional, monitor these interfaces.
#track_script => 'check_dns',
}

# Add virtual server for DNS
keepalived::lvs::virtual_server { 'VPN_DNS':
keepalived::lvs::virtual_server { 'VIP_DNS':
ip_address => $v_ip,
port => 53,
delay_loop => 6,
ha_suspend => true,
lb_algo => 'wrr',
lb_kind => 'DR',
# TODO remove? persistence_timeout => 0,
protocol => 'TCP'
}

$nameservers.each |Integer $index, String $real_ip| {
keepalived::lvs::real_server { "VPN_DNS_${index}":
virtual_server => 'VPN_DNS',
keepalived::lvs::real_server { "VIP_DNS_${index}":
virtual_server => 'VIP_DNS',
ip_address => $real_ip,
port => 53,
options => {
weight => 1,
weight => $index,
notify_down => "'/sbin/ipvsadm -d -u ${v_ip}:53 -r ${real_ip}:53'",
notify_up => "'/sbin/ipvsadm -a -u ${v_ip}:53 -r ${real_ip}:53 -g -w 1'",
'TCP_CHECK' => {
connect_timeout => '3',
}
},
'DNS_CHECK' => {
type => 'A',
name => 'google.com',
},
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion site-modules/role/manifests/domain_controller.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
include profile::app::samba::dc
include profile::app::zabbix::agent
include profile::app::backuppc::client
#include profile::app::keepalived::dns
include profile::app::keepalived::dns
}
Loading