Ask Your Question
0

how create many balancermembers using hiera?

asked 2015-10-26 15:15:38 -0500

Willian gravatar image

updated 2015-10-27 14:00:36 -0500

Hellow everyone,

How I resolve this problems:

Common.yaml

---
serpro::apache::balancer:
  "VIP00":
     stickysession:           "JSESSIONID"

serpro::apache::balancermembers:
  balancermember00:
    name_balancer:  "VIP00"
      url:            "ajp://127.0.0.1:8009"
      options:
        - "ping=5"
        - "keepalive=On"
  balancermember00:
       name_balancer:  "VIP00"
      url:            "ajp://127.0.0.2:8009"
      options:
        - "ping=5"
        - "keepalive=On"

manifest.pp

  $hash_balancer          = hiera("serpro::apache::balancer", {})
  $hash_balancermembers   = hiera("serpro::apache::balancermembers", {})

  create_resources('apache_wrapper::balancer', $hash_balancer)
  create_resources('apache_wrapper::balancermember', $hash_balancermembers)

define

  define apache_wrapper::balancermember (
         $url            = "ajp://127.0.0.1:8009",
          $options        = [],
         $name_balancer  = "default",
 ){
         apache::balancermember { "${::fqdn}-00":
                 balancer_cluster => $name_balancer,
                 url              => $url,
                 options          => $options,
         }
  }

I'm reveice the following error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Apache::Balancermember[xxxxxx.prcddom0001.serpro-00] is already declared in file /etc/puppet/environments/lab/modules/apachewrapper/manifests/balancermember.pp:11; cannot redeclare at /etc/puppet/environments/lab/modules/apachewrapper/manifests/balancermember.pp:11 on node xxxxx.prcddom0001.serpro

My common.yaml need to be able to declare several balancermembers. I don't know to how resolve this problem.

cheers!!!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-10-27 13:39:29 -0500

Willian gravatar image

Oh... sorry! There are things wrong in my post. The correct is...

Common.ymal

---
serpro::apache::balancer:
  "VIP00":
     stickysession:           "JSESSIONID"

serpro::apache::balancermembers:
  balancermember00:        # balancermember 1
    name_balancer:  "VIP00"
      url:            "ajp://127.0.0.1:8009"
      options:
        - "ping=5"
        - "keepalive=On"
  balancermember01:       # balancermember 2
       name_balancer:  "VIP00"
      url:            "ajp://127.0.0.2:8009"
      options:
        - "ping=5"
        - "keepalive=On"

Manifest.pp is the same

define

  define apache_wrapper::balancermember (
     $url            = "ajp://127.0.0.1:8009",
      $options        = [],
     $name_balancer  = "default",
   ){
     apache::balancermember { $title:   # it was wrong
             balancer_cluster => $name_balancer,
             url              => $url,
             options          => $options,
     }
  }

Now works... :) Thanks very much!!!

edit flag offensive delete link more

Comments

Great, glad you got it working. I see that I was mistaken on my recommendation to have a unique name for the value of the name_balancer key, but you figured that out. :)

GregLarkin gravatar imageGregLarkin ( 2015-10-27 15:36:19 -0500 )edit

And so you did need to declare multiple balancer members on the same machine, is that correct? It appears to be the case. I didn't notice the IP addresses were different in your original post.

GregLarkin gravatar imageGregLarkin ( 2015-10-27 15:37:33 -0500 )edit
0

answered 2015-10-26 19:14:34 -0500

GregLarkin gravatar image

It looks like a few things are going on here:

  • Your Hiera data shows "balancermember00" used more than once as a hash key. Each one of those needs to be unique.
  • The "name_balancer" subkey likely needs unique values for each hash entry, too.
  • Your code appears to be create multiple balancer members on a single node, and your balancer member resource title is only based on the $::fqdn fact. If you attempt to declare more than one balancer member on the same host (I'm sure you don't want to do that anyways), you'll see a duplicate declaration error as you did.

So what you probably want to do is declare a bunch of balancer members in the Hiera data, but make sure that each one is only declared on a single host, instead of multiple ones on the same host.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-10-26 15:15:38 -0500

Seen: 64 times

Last updated: Oct 27 '15