Advertisement
foonix

Untitled

Jul 28th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1.  
  2. # Keepalived installer.
  3. # Only supports one VRRP instance per server currently
  4. # (Although keepalived supports multiple)
  5.  
  6. # Requires module: https://github.com/arioch/puppet-keepalived
  7.  
  8. # Settings for the vrrp instance.
  9.  
  10. # Note a vrrp instance refers to the behavior between two servers
  11. # that allows the floating IP to be moved around.
  12.  
  13. # The ID to use for vrrp instance.
  14. # Only need to change this if running more than
  15. # one failover IP on the same network.
  16. # Should be different for each failover IP on the same network,
  17. # but the same for every server with the same IP.
  18. # "1" is used by our core routers, so best to avoid it.
  19. $vrrp_id = '10'
  20.  
  21. # What interface the instance runs on.
  22. # (currently used for both the floating address and control multicast)
  23. # Note multicast must be enabled on this interface!
  24. $interface = 'eth1'
  25.  
  26. # The floating IP/CIDR to use for failvover.
  27. $ip = '192.168.232.97/24'
  28.  
  29. # This should be MASTER on one server and BACKUP on the other.
  30. # Unless you are running nopreempt, in which case both shoulde be BACKUP.
  31. #$state = 'MASTER'
  32. $state = 'BACKUP'
  33.  
  34. # This should usually be 101 on the MASTER and 100 on BACKUP
  35. $priority = '101'
  36. #$priority = '100'
  37.  
  38. # Set this true if the failback process is disruptive to applications
  39. # and should be done manually.
  40. # Probably should be true for databases.
  41. # Should be false if there is some reason to prefer a specific machine be active.
  42. # To failback, just restart keepalived on the machine with the IP.
  43. # See: http://article.gmane.org/gmane.linux.keepalived.devel/1537%22
  44. $nopreempt = true
  45.  
  46. # This should be set to a random password.
  47. # It needs to be the same on every instance with the same $vrrp_id.
  48. $password = 'RANDOM_PASSWORD'
  49.  
  50. # A simple bash command to check of the process that will use
  51. # the floating IP is running.
  52. # If this goes down, the IP should go to the other server in
  53. # the same vrrp isntance.
  54. $check_command = 'kill -0 `cat /var/run/mysqld/mysqld.pid`'
  55.  
  56.  
  57.  
  58. # end of config #
  59. # There are lots of advanced settings if you want to muck around.
  60. # See: https://github.com/arioch/puppet-keepalived
  61.  
  62.  
  63. include keepalived
  64.  
  65. keepalived::vrrp::instance { "VRID_${vrrp_id}":
  66. interface => $interface,
  67. state => $state,
  68. virtual_router_id => $vrrp_id,
  69. priority => $priority,
  70. auth_type => 'PASS',
  71. auth_pass => $password,
  72. virtual_ipaddress => [ $ip ],
  73. #track_interface => ['eth1','tun0'], # optional, monitor these interfaces.
  74. track_script => "VRID_${vrrp_id}_check",
  75. }
  76.  
  77.  
  78. keepalived::vrrp::script { "VRID_${vrrp_id}_check":
  79. script => $check_command,
  80. }
  81.  
  82.  
  83.  
  84. # For RHEL, redhat makes it difficult to install keepalived.
  85. # The package is burried in a paid add-on, so we use a 3rd party repo.
  86. # CentOS is fine.
  87. if($operatingsystem == 'RedHat' and $operatingsystemmajrelease == 6) {
  88. package { 'powerstack-release':
  89. ensure => 'latest',
  90. provider => 'rpm',
  91. source => 'http://powerstack.org/powerstack-release.rpm',
  92. }
  93.  
  94. # Ignore: "Warning: Augeas[powerstack-repo-augeas](provider=augeas): Loading failed for one or more files, see debug for /augeas//error output"
  95. # The warning is fixed in puppet 3.5.0.
  96. # https://tickets.puppetlabs.com/browse/PUP-1158
  97. augeas { 'powerstack-repo-augeas':
  98. require => Package['powerstack-release'],
  99. before => Package['keepalived'],
  100. context => '/files/etc/yum.repos.d/powerstack.repo',
  101. changes => [
  102. # This will eventually break. See: https://fedorahosted.org/augeas/ticket/275
  103. 'set powerstack/includepkgs keepalived',
  104. 'set powerstack/baseurl http://download.powerstack.org/6/$basearch/',
  105. ],
  106. }
  107. }
  108.  
  109. #package { 'keepalived': ensure => 'latest' }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement