chef-recipe ArgumentError unknown directive: "\n"

125 Views Asked by At

I am using chef-server 11 and using chef-provisioning gem to automate the cloud infrastructure. I have an simple recipe to create an instance from AMI but it fails with an ArgumentError unknown directive: "\n" error

my chef recipe is

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

after executing this recipe like this

chef-client -z recipes/createserver.rb

I get the following error after instance creation

[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)

Though the instance is created properly and I can SSH it from command line but the complete recipe execution fails, how can I fix the error and I am sure there is no extra character "\n" in my recipe

1

There are 1 best solutions below

0
On

You have an extra newline between creating the machine resource and the do which starts its block.