我有一本食谱,除了将客户端加入群集之外,它将完全配置客户端节点以使用consul。以下命令失败:
execute "join consul" do
command "/usr/local/bin/consul join #{consul_server}"
action :nothing
end
在实例本身上运行我认为是相同的命令,但是在食谱失败后可以运行:
/usr/local/bin/consul join server-001.flapjacks.com
该服务是通过systemd脚本设置的,该脚本将配置设置为:/etc/consul.d
[Unit]
Description="HashiCorp Consul - A service mesh solution"
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/consul.d/consul.hcl
[Service]
User=root
Group=root
ExecStart=/usr/local/bin/consul agent -config-dir /etc/consul.d
ExecReload=/usr/local/bin/consul reload
KillMode=process
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
选中该服务即可正常运行。
执行资源由模板资源触发:
template '/etc/consul.d/webserver.json' do
source 'webserver.json.erb'
owner 'root'
group 'root'
mode '0644'
action :create
notifies :restart, resources(:service => "consul")
notifies :run, "execute[join consul]"
end
厨师使用此命令运行输出错误:
STDERR: Error joining address 'server-001.flapjacks.com': Put http://127.0.0.1:8500/v1/agent/join/server-001.flapjacks.com: dial tcp 127.0.0.1:8500: connect: connection refused
Failed to join any nodes.
任何关于为什么这行不通的想法?