kosmos-hubot: scope the nginx upstream to the production environment

search(:node, 'role:hubot') also matched retired nodes outside production
(e.g. nodejs-4 in _default), so the vhosts could proxy to a dead host and
return 502. Restrict the search to chef_environment:production and pick
deterministically.
This commit is contained in:
raucao committed 2026-10-28 18:22:23 +04:00
1 parent 086b31a387
commit e53df92b57
1 file changed
+10 -2
+10 -2
View File
@@ -6,8 +6,16 @@
#
node['kosmos-hubot']['vhosts'].each do |vhost|
domain = vhost['domain']
upstream_host = search(:node, 'role:hubot').first['knife_zero']['host']
domain = vhost['domain']
# Restrict to the production environment and pick deterministically, so a
# stray node carrying role[hubot] (e.g. a retired one in _default) can't
# hijack the upstream.
upstream = search(:node, 'role:hubot AND chef_environment:production')
.sort_by(&:name).first
raise 'No production node with role[hubot] found for the hubot vhosts' unless upstream
upstream_host = upstream['knife_zero']['host']
tls_cert_for domain do
auth 'gandi_dns'