Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I export an haproxy::balancermember resource for my application servers:

class www_admin($datacenter){
  @@haproxy::balancermember{"${hostname}-www-admin:9193":
    listening_service => 'www-admin',
    server_names      => "${hostname}:9193",
    ipaddresses       => $ipaddress,
    ports             => 9193,
    options           => "check inter 65761 fastinter 1751 downinter 5761 weight ${weight}",
    tag               => $datacenter,
  }
}

I have two datacenters: dc:enovance and dc:staging. In production (dc:enovance), I use haproxy, while on staging, I don't yet. I have verified that when mike (the staging server) exports the resource, $datacenter is correctly set to dc:staging:

$ hiera --debug www_admin::datacenter ::fqdn=mike.cvib.es ::hostname=mike ::domain=cvib.es
DEBUG: Tue Dec 03 20:59:29 +0000 2013: Hiera JSON backend starting
DEBUG: Tue Dec 03 20:59:29 +0000 2013: Looking up www_admin::datacenter in JSON backend
DEBUG: Tue Dec 03 20:59:29 +0000 2013: Looking for data source node/mike.cvib.es
DEBUG: Tue Dec 03 20:59:29 +0000 2013: Looking for data source node/mike
DEBUG: Tue Dec 03 20:59:29 +0000 2013: Cannot find datafile /etc/puppet/hiera/node/mike.json, skipping
DEBUG: Tue Dec 03 20:59:29 +0000 2013: Looking for data source cvib.es
dc:staging

On the production haproxy node, I collect exported resources like this:

node proxy {
  # ...
  Haproxy::Balancermember <<| tag == 'dc:enovance' |>>
}

Unfortunately, production still wants to add mike to the production haproxy:

# puppet agent -t --noop
Info: Retrieving plugin
Info: Loading facts in /etc/puppet/modules/puppetlabs-stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/puppetlabs-stdlib/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/sshpubkey.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Caching catalog for proxy100.novalocal
Info: Applying configuration version '1386103029'
Notice: /Stage[main]/Haproxy/Concat[/etc/haproxy/haproxy.cfg]/File[/etc/haproxy/haproxy.cfg]/content:
--- /etc/haproxy/haproxy.cfg    2013-12-03 16:22:35.279592067 +0000
+++ /tmp/puppet-file20131203-5679-1qu03nj       2013-12-03 20:37:54.946867039 +0000
@@ -173,6 +173,9 @@
  timeout  server 10m
  timeout  client 10m
  timeout  http-request 10m
+  server mike:9193 142.4.219.180:9193 check inter 65761 fastinter 1751 downinter 5761 weight 100
+
+  server mike:9194 142.4.219.180:9194 check inter 65761 fastinter 1751 downinter 5761 weight 100

  server worker111:9193 10.43.0.22:9193 check inter 65761 fastinter 1751 downinter 5761 weight 100


Notice: /Stage[main]/Haproxy/Concat[/etc/haproxy/haproxy.cfg]/File[/etc/haproxy/haproxy.cfg]/content: current_value {md5}2b0fe2a09bdac5a12a6c7eaffd1cc35e, should be {md5}a72cef384a71c120d03af14bd33d29d0 (noop)
Notice: Concat[/etc/haproxy/haproxy.cfg]: Would have triggered 'refresh' from 1 events
Info: Concat[/etc/haproxy/haproxy.cfg]: Scheduling refresh of Service[haproxy]
Notice: /Stage[main]/Haproxy/Service[haproxy]: Would have triggered 'refresh' from 1 events
Notice: Class[Haproxy]: Would have triggered 'refresh' from 2 events
Notice: Stage[main]: Would have triggered 'refresh' from 2 events
Notice: Finished catalog run in 11.22 seconds

# puppet --version
3.3.2

I suspect I'm making a basic mistake. The documentation at http://docs.puppetlabs.com/puppet/latest/reference/lang_exported.html states I should simply use the equality operator to find tagged resources (look for the example with bacula). Using puppet node exports (from http://forge.puppetlabs.com/zack/exports), I can see mike does export dc:staging:

---
  - parameters:
      ports: "9194"
      ipaddresses: "142.4.219.180"
      server_names: "mike:9194"
      tag: "dc:staging"
      options: "check inter 65761 fastinter 1751 downinter 5761 weight 100"
      listening_service: www-admin
    line: 57
    file: /etc/puppet/modules/company/manifests/www_admin.pp
    exported: true
    tags:
      - "dc:staging"
      - "haproxy::balancermember"
      - www_admin
      - "mike-www-admin:9194"
      - balancermember
      - haproxy
      - class
    title: "mike-www-admin:9194"
    type: "Haproxy::Balancermember"
    resource: c19ef1cbb789f41f2f83c02ebfb31b6e6fea17f6
    certname: mike.cvib.es
  - parameters:
      ports: "9193"
      ipaddresses: "142.4.219.180"
      server_names: "mike:9193"
      tag: "dc:staging"
      options: "check inter 65761 fastinter 1751 downinter 5761 weight 100"
      listening_service: www-admin
    line: 48
    file: /etc/puppet/modules/company/manifests/www_admin.pp
    exported: true
    tags:
      - "dc:staging"
      - "haproxy::balancermember"
      - www_admin
      - "mike-www-admin:9193"
      - balancermember
      - haproxy
      - class
    title: "mike-www-admin:9193"
    type: "Haproxy::Balancermember"
    resource: f6d8c6f60a52cc2cd160f20ac5998ef07560c61f
    certname: mike.cvib.es

How can I only include the dc:enovance resources in production, and ignore the exported dc:staging resources?

share|improve this question
    
What are you using as your storeconfigs backend on your master? –  Craig Watson Dec 4 '13 at 14:05
    
@CraigWatson, storeconfig is set to puppetdb, ultimately to PostgreSQL 9.1. I also use pluginsync, for what it's worth. –  François Beausoleil Dec 4 '13 at 14:23

1 Answer 1

The documentation for haproxy::listen contains a reference to a collect_exported parameter. In the code for haproxy::listen, Haproxy::Balancermembers are collected. Since I was also collecting resources, I was collecting mike's resources anyway.

A second problem occurred because I did not export an ensure => false resource, and the concat module simply kept the file alive. When I blew away concat's cache for the /etc/haproxy/haproxy.cfg resource, my problems went away.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.