voxpupuli / puppet-keepalived

Puppet Module to manage Keepalived
https://forge.puppet.com/puppet/keepalived
Apache License 2.0
49 stars 152 forks source link

Improve collect_unicast_peers feature #304

Closed frank-f closed 9 months ago

frank-f commented 11 months ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

During my code research for #303 I discovered collect_unicast_peers and gave it a try.

I have two servers with IPs 10.1.2.11/24 and 10.2.2.11/24 and I'm using the following (hiera) code:

  vrrp_instance:
    'PROJECT-DB':
      virtual_router_id:    10
      auth_pass:            '123'
      virtual_ipaddress:    "10.3.2.11"
      interface:            'eth0'
      auth_type:            'PASS'
      state:                'BACKUP'
      priority:             100
      track_script:         'check_db'
      collect_unicast_peers: true

Since both servers use different subnets, I need to use unicast_peers.

What are you seeing

Puppet will add the local IP address to the unicast_peer list. Also it removes unicast_src_ip which I prefer to set, since my systems have more than one IP, but just one of them works as Keepalived source. Most of the time it works automagically, sometimes it does not and I like to avoid surprises.

What behaviour did you expect instead

I want the resulting configuration file to look like this:

  unicast_src_ip 10.1.2.11
  unicast_peer {
    10.2.2.11
  }

Output log

Compared to my manual configuration the result will currently looks like this:

(/Stage[main]/Keepalived::Config/Concat[/etc/keepalived/keepalived.conf]/File[/etc/keepalived/keepalived.conf]/content) - (/Stage[main]/Keepalived::Config/Concat[/etc/keepalived/keepalived.conf]/File[/etc/keepalived/keepalived.conf]/content) - unicast_src_ip 10.1.2.11 (/Stage[main]/Keepalived::Config/Concat[/etc/keepalived/keepalived.conf]/File[/etc/keepalived/keepalived.conf]/content) unicast_peer { (/Stage[main]/Keepalived::Config/Concat[/etc/keepalived/keepalived.conf]/File[/etc/keepalived/keepalived.conf]/content) - 10.2.2.11 (/Stage[main]/Keepalived::Config/Concat[/etc/keepalived/keepalived.conf]/File[/etc/keepalived/keepalived.conf]/content) + 10.1.2.11 (/Stage[main]/Keepalived::Config/Concat[/etc/keepalived/keepalived.conf]/File[/etc/keepalived/keepalived.conf]/content) }

Any additional information you'd like to impart

I'll submit a PR that will fix this issue.