From 63935ec789208c792406c5c58f9d31ccda918441 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 31 Mar 2024 09:45:29 +0900 Subject: [PATCH] Deploy `/etc/consul.d/server.hcl` only when the consul is server. --- cookbooks/consul/setup.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cookbooks/consul/setup.rb b/cookbooks/consul/setup.rb index 758ed13..70042ee 100644 --- a/cookbooks/consul/setup.rb +++ b/cookbooks/consul/setup.rb @@ -71,14 +71,16 @@ template '/etc/consul.d/consul.hcl' do end # Deploy server specific config -template '/etc/consul.d/server.hcl' do - owner 'consul' - group 'consul' - mode '644' +if node['consul']['manager'] + template '/etc/consul.d/server.hcl' do + owner 'consul' + group 'consul' + mode '644' - variables(server_token: node['consul']['server_token']) + variables(server_token: node['consul']['server_token']) - notifies :restart, 'service[consul]' + notifies :restart, 'service[consul]' + end end %w( 01-bootstrap.sh 02-policy.sh ).each do |sh|