简体   繁体   English

AWS上的Terraform + Chef:405错误

[英]Terraform+Chef on AWS: 405 Not Allowed error

We're using the Terraform Chef provisioner on AWS using AWS-managed Chef server. 我们正在使用AWS管理的Chef服务器在AWS上使用Terraform Chef设置程序。 Terraform is able to: Terraform能够:

  1. create the instance 创建实例
  2. connect to the instance via SSH and install the chef-client 通过SSH连接到实例并安装Chef-client

The chef-client is up to the point where it generates the private key and then it is followed by this error: 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>

Here's the configuration: 配置如下:

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"
  }
}

What is causing this error and how do I fix this? 是什么导致此错误,我该如何解决?

Thanks in advance! 提前致谢!

EDIT: I enabled Terraform logging TF_LOG=1 and found that the chef client is trying to reference PEM files that are not on the node: 编辑:我启用了Terraform日志记录TF_LOG=1并发现Chef客户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

and

sudo knife client create test -d -f /etc/chef/client.pem -c /etc/chef/client.rb -u user --key /etc/chef/user.pem

I made a mistake with the server_url parameter. 我在server_url参数上犯了一个错误。 The correct URL should be in this format: http://chef_server/ organizations/default 正确的URL应采用以下格式: http:// chef_server / Organizations / default

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM