【问题标题】:Terraform+Chef on AWS: 405 Not Allowed errorAWS 上的 Terraform+Chef:405 Not Allowed 错误
【发布时间】:2018-03-08 15:49:35
【问题描述】:

我们使用 AWS 托管的 Chef 服务器在 AWS 上使用 Terraform Chef 配置程序。 Terraform 能够:

  1. 创建实例
  2. 通过 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


【解决方案1】:

我在server_url 参数上犯了一个错误。正确的 URL 应采用以下格式:http://chef_server/organizations/default

【讨论】:

  • 我遇到了同样的错误。但是通过使用来自knife.rb 文件的正确URL 来纠正
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-26
  • 2016-05-12
  • 1970-01-01
  • 2021-12-12
  • 1970-01-01
  • 2017-06-14
  • 2011-03-31
相关资源
最近更新 更多