【发布时间】:2018-03-08 15:49:35
【问题描述】:
我们使用 AWS 托管的 Chef 服务器在 AWS 上使用 Terraform Chef 配置程序。 Terraform 能够:
- 创建实例
- 通过 SSH 连接到实例并安装 chef-client
厨师客户端到了它生成私钥的地步,然后出现以下错误:
aws_instance.machine (chef): ERROR: Not Allowed
aws_instance.machine (chef): Response: <html>
aws_instance.machine (chef): <head><title>405 Not Allowed</title></head>
aws_instance.machine (chef): <body bgcolor="white">
aws_instance.machine (chef): <center><h1>405 Not Allowed</h1></center>
aws_instance.machine (chef): <hr><center>nginx</center>
aws_instance.machine (chef): </body>
aws_instance.machine (chef): </html>
这是配置:
provider "aws" { }
resource "aws_instance" "test" {
ami = "ami-xxxxxxxx"
instance_type = "t2.micro"
vpc_security_group_ids = ["sg-xxxxxxx"]
subnet_id = "subnet-xxxxxx"
key_name = "Test"
tags {
Name = "test"
}
provisioner "chef" {
server_url = "https://<chef server url>"
user_name = "user"
user_key = "${file("~/.chef/user.pem")}"
node_name = "test"
run_list = ["role[app]"]
on_failure = "continue"
recreate_client = true
version = "12.16.42"
fetch_chef_certificates = false
ssl_verify_mode = ":verify_none"
environment = "test"
client_options = [
"verbose_logging = true"
]
}
connection {
type = "ssh"
user = "ssh-user"
private_key = "${file("../keys/ssh-user.pem")}"
bastion_host = "1.1.1.1"
}
}
是什么导致了这个错误,我该如何解决这个问题?
提前致谢!
编辑:
我启用了 Terraform 日志记录 TF_LOG=1 并发现厨师客户端正在尝试引用不在节点上的 PEM 文件:
sudo knife client show test -c /etc/chef/client.rb -u user --key /etc/chef/user.pem > /dev/null 2>&1
和
sudo knife client create test -d -f /etc/chef/client.pem -c /etc/chef/client.rb -u user --key /etc/chef/user.pem
【问题讨论】:
-
你安装 chef-client 吗?请分享代码。
-
我更新了帖子。希望有人能指出我正确的方向。
-
IRC,当使用堡垒主机时,
connection块应该是provisioner块的一部分。 405 错误,看起来像是来自您网络中的代理(?)。
标签: amazon-web-services amazon-ec2 chef-infra terraform