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

LVS real server options - upper case not allowed by puppet but needed by keepalvied #77

Open
realpdm opened this issue Aug 6, 2015 · 6 comments

Comments

@realpdm
Copy link

realpdm commented Aug 6, 2015

When setting up a real server settings in the keepalived.conf file is which check to use for the server. All of these checks seem to be required to be upper case. Ie, HTTP_GET works but http_get does not work.

Due to the way options are passed in the module the template takes the options hash and translates that directly into keepalived.conf config.

It turns out that puppet does not want you to start variable names with a capital letter. ( https://docs.puppetlabs.com/puppet/3.8/reference/deprecated_language.html#variable-names-beginning-with-capital-letters ).

This works:
options => { weight => 1, http_get => { ....

This does not work
options => { weight => 1, HTTP_GET => { ....
The puppet parser says: Error: Could not parse for environment production: Syntax error at 'HTTP_GET'; expected '}' at...

I'm pondering ways to solve this and will send a PR if I figure it out. I wanted to raise the issue in case someone has already solved it or has a bright idea of how to do so.

The best ideas I have so far is to make the check be specially called out and not part of the options template or to have some sort of postfix to the variable name that says to upper case is when turned into config.

@arioch
Copy link
Contributor

arioch commented Aug 6, 2015

The easiest way I can think of is adding something among the lines of:

sorted_options.each_with_index do |(key, value), index|
  if value.is_a?(Hash)
    if key =~ /http_get/
      buffer << key.upcase
    else
      buffer << "\n" unless index == 0
      buffer << "\n#{indent}#{key} {"
      buffer << format_options(value, indent_level+1)
      buffer << "\n#{indent}}"
  elsif value === true
    ...
  end
end

@realpdm
Copy link
Author

realpdm commented Aug 6, 2015

I was hoping to have something more general purpose for all checks. Maybe in the main module store the possible checks from keepalived in an array and in the template match each against that array. If it matches key.upcase. I'll give this idea a try and see how it looks.

@realpdm
Copy link
Author

realpdm commented Aug 6, 2015

Ok that seems to work somewhat cleanly. Posted here just for FYI, I have some other ideas on how to re-use a common set of backends for multiple VIPs so I will send a PR through once I have that worked out. I'll do them separately though.

diff -r /home/pmoore/puppet-keepalived/manifests/lvs/real_server.pp ./manifests/lvs/real_server.pp
37a38
>   $valid_healthchecks = [ 'HTTP_GET','SSL_GET','TCP_CHECK','SMTP_CHECK','MISC_CHECK' ]
diff -r /home/pmoore/puppet-keepalived/templates/lvs_real_server.erb ./templates/lvs_real_server.erb
13c13,14
<         buffer << "\n#{indent}#{key} {"
---
>         format_key = key.upcase if @valid_healthchecks.any?{ |s| s.casecmp(key)==0 }
>         buffer << "\n#{indent}#{format_key || key } {"

@arioch
Copy link
Contributor

arioch commented Aug 6, 2015

That's an excellent idea. If you spec & doc it I'll merge it. 👍

@saz
Copy link
Sponsor Contributor

saz commented Sep 25, 2019

This is working without any problems:

options        => {
      'SSL_GET' => {
        url             => {
          path   => '/some/path',
          digest => '2f4e0fd321d2d5a573861afa6193d7db',
        },
        connect_timeout => 1,
        connect_port    => 443,
      },
    },

@saz
Copy link
Sponsor Contributor

saz commented Sep 25, 2019

I think this issue can be closed.

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

3 participants