linux - Chef Recipe ArgumentError 未知指令 : "\n"

标签 linux amazon-web-services chef-infra provisioning argument-error

我正在使用 chef-server 11 并使用 chef-provisioning gem 来自动化云基础架构。 我有一个从 AMI 创建实例的简单方法,但它失败了 ArgumentError 未知指令:“\n”错误

我的 Chef Recipe 是

require 'chef/provisioning/aws_driver'
with_driver 'aws::us-east-1'
machine 'new-chef-instance' 
do 
   machine_options :ssh_username => 'root',
       :bootstrap_options => 
        {
         :key_name => 'mykeyname',
         :image_id => 'myamiid',
         :instance_type => 't2.micro',
         :subnet_id => 'mysubnetid',
         :security_group_ids => 'my-security-group' 
        }
end

像这样执行这个 Recipe 之后

chef-client -z recipes/createserver.rb

创建实例后出现以下错误

[2015-08-24T11:42:17+00:00] INFO: Processing chef_node[new-chef-provision] action create (basic_chef_client::block line 57)

================================================================================
Error executing action `converge` on resource 'machine[new-chef-instance]'
================================================================================

ArgumentError
-------------
unknown directive: "\n"

Resource Declaration:
---------------------
# In /mypath/recipes/createserver.rb'
[2015-08-24T11:42:27+00:00] INFO: Running queued delayed notifications  before re-raising exception

Running handlers:
[2015-08-24T11:42:27+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-08-24T11:42:27+00:00] ERROR: Exception handlers complete
[2015-08-24T11:42:27+00:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 268.92955968 seconds
[2015-08-24T11:42:27+00:00] ERROR: machine[new-chef-provision]       (@recipe_files::/mypath/recipes/createserver.rb line 3) had an error: ArgumentError: unknown directive: "\n"
[2015-08-24T11:42:28+00:00] FATAL:    Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

虽然实例已正确创建并且我可以从命令行对其进行 SSH,但完整的配方执行失败,我该如何修复错误并且我确定我的配方中没有额外的字符“\n”

最佳答案

在创建 machine 资源和开始其 block 的 do 之间有一个额外的换行符。

关于linux - Chef Recipe ArgumentError 未知指令 : "\n",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32182049/

相关文章:

amazon-web-services - 地形 : Error creating Security Group: UnauthorizedOperation: You are not authorized to perform this operation

chef-infra - Chef 节点属性。哪些可用?

amazon-web-services - Stubber没有boto3属性

clock_gettime() 在 PC 上运行良好,但在服务器上它会中止编译

c - 与 mmap 共享进程内存

linux - 管道 Perl 脚本输出到 head -n 10 在打印 10 行后杀死脚本

amazon-web-services - 我在 Amazon Lex Bot 中没有看到 "Publish"按钮,并且我发现所有教程的屏幕截图与我的 AWS 控制台不一致

ssh - 如何在Chef中修复 'knife bootstrap ssh connection to client issue'?

chef-infra - 具有自定义 GUID 的 Windows 防火墙的 Chef Guard

database - 使用 grep 提取文件之间的行