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

misplaced curly brace #75

Closed
rotulet opened this issue Jun 29, 2015 · 5 comments
Closed

misplaced curly brace #75

rotulet opened this issue Jun 29, 2015 · 5 comments

Comments

@rotulet
Copy link
Contributor

rotulet commented Jun 29, 2015

Hi,
(sorry for the long post...) I am using the following version:

# puppet --version
3.8.1
# puppet module list
/etc/puppet/modules
├── arioch-keepalived (v1.2.0)
├── puppetlabs-apt (v1.8.0)
├── puppetlabs-concat (v1.2.3)
├── puppetlabs-stdlib (v4.6.0)

I am building keepalived::lvs::real_server for keepalived::lvs::virtual_server with this puppet script:

define keepalived_tools::build_virtual_server ($lvs_state, $vrid, $vip, $vservers, $notify_script=undef, $track_script=undef) {
  if $lvs_state == 'MASTER' {
    $prio = 101
  }
  else {
    $prio = 100
  }

  keepalived::vrrp::instance { $name:
    interface         => 'eth1',
    state             => $lvs_state,
    virtual_router_id => $vrid,
    priority          => $prio,
    auth_type         => 'PASS',
    auth_pass         => 'secret',
    virtual_ipaddress => $vip,
    notify_script     => $notify_script,
    track_script      => $track_script,
    #track_interface   => ['eth1','tun0'], # optional, monitor these interfaces.
  }

  each($vservers) |$vserver| {

    keepalived::lvs::virtual_server { $vserver['name']:
      ip_address => $vip,
      port => $vserver['port'],
      lb_algo => 'wlc',
      lb_kind => 'DR',
      persistence_timeout => '300',
      real_servers => $rss,
      collect_exported => false,
      delay_loop => '10',
    }

    if ($vserver['misc_check'] == undef) {
      each($vserver['rservers']) |$r_ip| {
        keepalived::lvs::real_server { "${vserver['name']}_${r_ip}_${vserver['port']}":
          ip_address => $r_ip,
          virtual_server => $vserver['name'],
          port => $vserver['port'],
          options => {
            'TCP_CHECK' => {
              connect_timeout => 5,
              connect_port => $vserver['port'],
            },
            #inhibit_on_failure => true,
          }
        }
      }
    } else {   
      each($vserver['rservers']) |$r_ip| {
        keepalived::lvs::real_server { "${vserver['name']}_${r_ip}_${vserver['port']}":
          ip_address => $r_ip,
          virtual_server => $vserver['name'],
          port => $vserver['port'],
          options => {
            'MISC_CHECK' => {
              connect_timeout => 5,
              misc_path => $vserver['misc_check'],
              warmup => 10
            },
            #            inhibit_on_failure => true,
            weight => 2,
          }
        }
      }
    }
  }

}

This script is called with the following parameters:

build_virtual_server ('geoserver':
  lvs_state => 'MASTER',
  vrid => 50, 
  vip => '192.168.5.111',
  vservers => [{name => "LVS_geoserver_80", port => "80", rservers => [192.168.5.116, 192.168.5.118]},
                      {name => "LVS_geoserver_22", port => "22", rservers => [192.168.5.116, 192.168.5.118]},
                      {name => "LVS_geoserver_8080", port => "8080", rservers => [192.168.5.116, 192.168.5.118]}]
)

The generated keepalived.conf has a misplaced curly brace between the group definition for port 80 and port 8080 (line 103 instead of line 84):

vrrp_instance VI_50 {
  interface                 eth1
  state                     MASTER
  virtual_router_id         50
  priority                  101
  advert_int                1
  garp_master_delay         5



  # notify scripts and alerts are optional                                                                                             
  #                                                                                                                                    
  # filenames of scripts to run on transitions                                                                                         
  # can be unquoted (if just filename)                                                                                                 
  # or quoted (if has parameters)                                                                                                      




  authentication {
    auth_type PASS
    auth_pass secret
  }


  virtual_ipaddress {
    192.168.5.111 dev eth1
  }





}
group LVS_geoserver_22 {

  virtual_server 192.168.5.111 22

  delay_loop 10
  lb_algo wlc
  lb_kind DR

  persistence_timeout 300
  protocol TCP


  real_server 192.168.5.116 22 {
    TCP_CHECK {
      connect_port 22
      connect_timeout 5
    }
  }
  real_server 192.168.5.118 22 {
    TCP_CHECK {
      connect_port 22
      connect_timeout 5
    }
  }
}
group LVS_geoserver_80 {

  virtual_server 192.168.5.111 80

  delay_loop 10
  lb_algo wlc
  lb_kind DR

  persistence_timeout 300
  protocol TCP


  real_server 192.168.5.116 80 {
    TCP_CHECK {
      connect_port 80
      connect_timeout 5
    }
  }
  real_server 192.168.5.118 80 {
    TCP_CHECK {
      connect_port 80
      connect_timeout 5
    }
  }
group LVS_geoserver_8080 {

  virtual_server 192.168.5.111 8080

  delay_loop 10
  lb_algo wlc
  lb_kind DR

  persistence_timeout 300
  protocol TCP


  real_server 192.168.5.116 8080 {
    TCP_CHECK {
      connect_port 8080
      connect_timeout 5
    }
  }
}
}

The keepalived.conf is just an extract of the real one as I call my script many times and the only issue I have got is with this specific call.

Am I doing something wrong ?

As a wrap-around I change the line 154 of virtual_server.pp from order => "250-${name}" to order => "250-${name}-zzzzzzzzzzzzzzzzzzzzz" to be sure this } will be added at end of the group.

Thanks,
Rot.

@rotulet
Copy link
Contributor Author

rotulet commented Feb 1, 2016

Up ! I still have the pbm! Do you prefer a pull request than an issue?

Thanks,
Rot.

gattebury added a commit to gattebury/puppet-keepalived that referenced this issue Feb 23, 2016
@arioch
Copy link
Contributor

arioch commented Feb 24, 2016

@rotulet could you confirm 1fc34dd fixes this issue?
Credits to @gattebury.

@rotulet
Copy link
Contributor Author

rotulet commented Feb 25, 2016

It is kinda fun to see my awkward fix being validated :)
I am currently on vacations, I'll check the fix on next Thursday.

Thanks,
Rot.

@arioch
Copy link
Contributor

arioch commented Feb 25, 2016

If it works it's a valid interim solution until we find a cleaner way to accomplish this.
Enjoy your vacation!

@rotulet
Copy link
Contributor Author

rotulet commented Mar 7, 2016

I just test it : it works as expected.

Thanks,
Rot.

@rotulet rotulet closed this as completed Mar 7, 2016
cegeka-jenkins pushed a commit to cegeka/puppet-keepalived that referenced this issue Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants