Eu exporto um recurso haproxy::balancermember
para meus servidores de aplicativos:
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,
}
}
Eu tenho dois datacenters: dc:enovance
e dc:staging
. Na produção (dc: enovance), eu uso haproxy, enquanto na encenação, eu ainda não o faço. Verifiquei que, quando mike
(o servidor de temporariedade) exportar o recurso, $datacenter
está corretamente definido como 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
No nó haproxy de produção, eu coleciono recursos exportados assim:
node proxy {
# ...
Haproxy::Balancermember <<| tag == 'dc:enovance' |>>
}
Infelizmente, a produção ainda quer adicionar microfones à produção de 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
Eu suspeito que estou cometendo um erro básico. A documentação no link indica que eu deveria simplesmente usar o operador de igualdade para encontrar recursos marcados (procure pelo exemplo com bacula). Usando puppet node exports
(do link ), vejo que o mike exporta 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
Como posso incluir somente os recursos dc:enovance
na produção e ignorar os recursos dc:staging
exportados?