chef/knife-ec2

Chef 15: knife ec2 server create fails with error : Syntax error: end of file unexpected (expecting "then")

Closed this issue · 5 comments

Version:

knife-ec2 v1.0.0 and chef v15.0.303 on workstation (Windows)

Environment:

Ubuntu 18.04 Node

Scenario:

bundle exec knife ec2 server create -N dh-ubu-03 -I ami-005bdb005fb00e791 --flavor t2.micro -c "E:\Backup\Project\chef-starter\chef-repo\.chef\knife.rb"

With other details in knife.rb :

knife[:aws_access_key_id] = "xxxxxx"
knife[:aws_secret_access_key] = "xxxxxx"
knife[:region] = "xxxx"
knife[:ssh_key_name] = "xxxx"
knife[:identity_file] = 'C:\Users\chef\Downloads\dh-aws-key.pem'
knife[:host_key_verify] = false
knife[:ssh_user] = 'ubuntu'

Steps to Reproduce:

Please run above command to create the server from windows workstation.

Expected Result:

It should create server in AWS and bootstrap.

Actual Result:

Bootstrapping ec2-54-212-84-255.us-west-2.compute.amazonaws.com
DEBUG: [SSH] ubuntu@ec2-54-212-84-255.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (sh /tmp/chef_YX0McY/bootstrap.sh)
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com] sh: 1:
: not found2-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com] sh: 2:
: not found2-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com] sh: 3:
: not found2-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com] sh: 4:
: not found2-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com]
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com] sh: 239:
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com] Syntax error: end of file unexpected (expecting "then")
 [ec2-54-212-84-255.us-west-2.compute.amazonaws.com]
ERROR: The following error occurred on ec2-54-212-84-255.us-west-2.compute.amazonaws.com:
ERROR:
DEBUG: [SSH] ubuntu@ec2-54-212-84-255.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (rm -f "/tmp/chef_YX0McY/bootstrap.sh")
btm commented

@dheerajd-msys can you run this with -VVV so we get the trace output and can see which bootstrap files are paths are being used?

@btm trace output is :

PS E:\Backup\Project\Chef_Repo\knife-ec2> bundle exec knife ec2 server create -N "dh-test-node-ubu1" -I "ami-005bdb005fb00e791" --flavor t2.micro -c "E:\Backup\Project\chef-starter\chef-repo\.chef\knife.rb" -VVV

E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap.rb:31: warning: already initialized constant Chef::Knife::Bootstrap::SUPPORTED_CONNECTION_PROTOCOLS
E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap.rb:31: warning: previous definition of SUPPORTED_CONNECTION_PROTOCOLS was here
E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap.rb:32: warning: already initialized constant Chef::Knife::Bootstrap::WINRM_AUTH_PROTOCOL_LIST
E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap.rb:32: warning: previous definition of WINRM_AUTH_PROTOCOL_LIST was here
E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap.rb:350: warning: already initialized constant Chef::Knife::Bootstrap::DEPRECATED_FLAGS
E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap.rb:350: warning: previous definition of DEPRECATED_FLAGS was here
INFO: Using configuration from E:/Backup/Project/chef-starter/chef-repo/.chef/knife.rb
Instance ID: i-088b261f549848d4a
Flavor: t2.micro
Image: ami-005bdb005fb00e791
Region: us-west-2
Availability Zone: us-west-2a
Security Groups: default
AWS Tags: Name: dh-test-node-ubu1
SSH Key: dh-aws-key

Waiting for EC2 to create the instance......
Public DNS Name: ec2-54-218-175-214.us-west-2.compute.amazonaws.com
Public IP Address: 54.218.175.214
Private DNS Name: ip-172-31-23-144.us-west-2.compute.internal
Private IP Address: 172.31.23.144

Waiting for sshd access to become available
SSH Target Address: ec2-54-218-175-214.us-west-2.compute.amazonaws.com(dns_name)
DEBUG: No ssh gateway found, making a direct connection
DEBUG: sshd accepting connections on ec2-54-218-175-214.us-west-2.compute.amazonaws.com, banner is SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.2

done

SSH Target Address: ec2-54-218-175-214.us-west-2.compute.amazonaws.com()
DEBUG: Checking if we need to accept Chef license to bootstrap node
DEBUG: Reading products and relationships...
DEBUG: Successfully read products and relationships
DEBUG: License acceptance required for chef version: 15
DEBUG: Searching for the following licenses: ["infra-client", "inspec"]
DEBUG: Found license chef_infra_client at C:/Users/chef/.chef/accepted_licenses/chef_infra_client
DEBUG: Found license inspec at C:/Users/chef/.chef/accepted_licenses/inspec
DEBUG: Missing licenses remaining: []
DEBUG: All licenses present
Connecting to ec2-54-218-175-214.us-west-2.compute.amazonaws.com
WARN: [SSH] PTY requested: stderr will be merged into stdout
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (cmd.exe /c ver)
DEBUG: [SSH] opening connection to ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}>
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (uname -s)
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (uname -m)
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (test -f /etc/debian_version && cat /etc/debian_version)
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (test -f /etc/lsb-release && cat /etc/lsb-release)
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (sudo echo)
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (echo '[SSH] Established')
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
TRACE: Signing the request as dheerajd-msys
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
TRACE: Initiating GET to https://api.chef.io/organizations/msystech/nodes/dh-test-node-ubu1
TRACE: ---- HTTP Request Header Data: ----
TRACE: Accept: application/json
TRACE: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
TRACE: X-Ops-Server-API-Version: 1
TRACE: X-OPS-SIGN: algorithm=sha1;version=1.1;
TRACE: X-OPS-USERID: dheerajd-msys
TRACE: X-OPS-TIMESTAMP: 2019-05-30T04:52:49Z
TRACE: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
TRACE: X-OPS-AUTHORIZATION-1: bAEQYQ9ie1tq091Yr12+oXzj7ccRRq0Lx8U6OiKz7weLAbT0WUx1ReTyCJtM
TRACE: X-OPS-AUTHORIZATION-2: hmzTTqVhJJfv7PaF0+w6GPZL2EdUm+MkzKnJt4sbo33pVwhis/Rwg+5ou/i5
TRACE: X-OPS-AUTHORIZATION-3: 7kirGrxLX0eEjPHNqcL+NTm6MJLKWOqs18UdsE2Sm1hph6TdrMU3Eizghv2U
TRACE: X-OPS-AUTHORIZATION-4: JNdCZoN2OBPxwkdtGf1XUK+n16G/c5ZDiiF6EcMKSIC+NVLcrMok9UdtcmYE
TRACE: X-OPS-AUTHORIZATION-5: AcjI6hyFulGCwYDatQz7+ya4yida2Jb0BFheixB7FePcVLwIrd1dGdiIgToJ
TRACE: X-OPS-AUTHORIZATION-6: NKSOZy/M5aLZormwRuxRORK/5gKJzm7W51Cu+L/PfQ==
TRACE: HOST: api.chef.io:443
TRACE: X-REMOTE-REQUEST-ID: 9ebea3fe-9cc1-4462-9a7d-023f2c7f2349
TRACE: ---- End HTTP Request Header Data ----
TRACE: ---- HTTP Status and Header Data: ----
TRACE: HTTP 1.1 404 Object Not Found
TRACE: date: Thu, 30 May 2019 04:52:48 GMT
TRACE: server: openresty/1.11.2.1
TRACE: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.17.29
TRACE: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
TRACE: content-length: 48
TRACE: connection: Close
TRACE: ---- End HTTP Status/Header Data ----
TRACE: ---- HTTP Response Body ----
TRACE: {"error":["node 'dh-test-node-ubu1' not found"]}
TRACE: ---- End HTTP Response Body -----
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
TRACE: Content-Length validated correctly.
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
TRACE: Expected JSON response, but got content-type ''
TRACE: Response body contains:
{"error":["node 'dh-test-node-ubu1' not found"]}
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
TRACE: Signing the request as dheerajd-msys
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
TRACE: Initiating GET to https://api.chef.io/organizations/msystech/clients/dh-test-node-ubu1
TRACE: ---- HTTP Request Header Data: ----
TRACE: Accept: application/json
TRACE: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
TRACE: X-Ops-Server-API-Version: 1
TRACE: X-OPS-SIGN: algorithm=sha1;version=1.1;
TRACE: X-OPS-USERID: dheerajd-msys
TRACE: X-OPS-TIMESTAMP: 2019-05-30T04:52:50Z
TRACE: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
TRACE: X-OPS-AUTHORIZATION-1: jvx1wPKMGRze+b0VXxtBq07lIVtc5+f/Lc2WPec942NKij+0DtMipnSqAmXj
TRACE: X-OPS-AUTHORIZATION-2: wa8E7Yjowui4y1rY9stj66Cjd/jD8cjDwo4ZLSqRPKNbs5Bvd44dklFZiLpB
TRACE: X-OPS-AUTHORIZATION-3: H4GfJ2ZH7EoE+0je3d5IZAnYm6HrpyATfofrteqFO/1y1ZeFDHfnRtjQlKNH
TRACE: X-OPS-AUTHORIZATION-4: aE69n+MB3VnibWaC54ZKezbEZhufnb/4S6vnXSUklNefFrMxaYISJkPsRPgt
TRACE: X-OPS-AUTHORIZATION-5: OzqRDqNbFe1/zhIOwroQB5MLnHX0LtxH1M4wWIo8WZpnuYcu1emjzi3AMG43
TRACE: X-OPS-AUTHORIZATION-6: fZuysopYfcHboKOYtOW2/MYzETl7TjQHRTxLzjfKkQ==
TRACE: HOST: api.chef.io:443
TRACE: X-REMOTE-REQUEST-ID: 9ebea3fe-9cc1-4462-9a7d-023f2c7f2349
TRACE: ---- End HTTP Request Header Data ----
TRACE: ---- HTTP Status and Header Data: ----
TRACE: HTTP 1.1 404 Object Not Found
TRACE: date: Thu, 30 May 2019 04:52:48 GMT
TRACE: server: openresty/1.11.2.1
TRACE: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.17.29
TRACE: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
TRACE: content-length: 50
TRACE: connection: Close
TRACE: ---- End HTTP Status/Header Data ----
TRACE: ---- HTTP Response Body ----
TRACE: {"error":["Cannot load client dh-test-node-ubu1"]}
TRACE: ---- End HTTP Response Body -----
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
TRACE: Content-Length validated correctly.
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
TRACE: Expected JSON response, but got content-type ''
TRACE: Response body contains:
{"error":["Cannot load client dh-test-node-ubu1"]}
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
Creating new client for dh-test-node-ubu1
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
TRACE: Signing the request as dheerajd-msys
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
TRACE: Initiating POST to https://api.chef.io/organizations/msystech/clients
TRACE: ---- HTTP Request Header Data: ----
TRACE: Content-Type: application/json
TRACE: Accept: application/json
TRACE: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
TRACE: X-Ops-Server-API-Version: 1
TRACE: X-OPS-SIGN: algorithm=sha1;version=1.1;
TRACE: X-OPS-USERID: dheerajd-msys
TRACE: X-OPS-TIMESTAMP: 2019-05-30T04:52:51Z
TRACE: X-OPS-CONTENT-HASH: UrnB6dKE4olpqk/KkQ/ttv2KOdM=
TRACE: X-OPS-AUTHORIZATION-1: oBzXN72IRmpu0qmAtsQX9pQUBw9pvawAU0KX94tfn/2TsVOFXia3MIMWKEfg
TRACE: X-OPS-AUTHORIZATION-2: au6YxScH4gh2N9Ftqp2E1CunhSHfxu/rBY9mFWwBw8TKdnNP7uM/oEFAT30U
TRACE: X-OPS-AUTHORIZATION-3: DvEmQnoPTqmtfynXd6sNI/HIbDuqwJ6hp3l6Z8LfE5RqalWJg42uFhZhWlbp
TRACE: X-OPS-AUTHORIZATION-4: VWAERJiEldJgB1mq2nlKeOjzFqgTu2FmUyiRrcnvYpMtGis1Vnkil/S+T9A7
TRACE: X-OPS-AUTHORIZATION-5: OdvXrsA9HjNS/+0hPXc/PrSN6uX7VHDnrBVn2zTwLy9UrBK0CBdLphvauqee
TRACE: X-OPS-AUTHORIZATION-6: jkUB3qTgO8svGaCC3Y0QzGi8egmejfWTlr/PVkk5kw==
TRACE: HOST: api.chef.io:443
TRACE: X-REMOTE-REQUEST-ID: 9ebea3fe-9cc1-4462-9a7d-023f2c7f2349
TRACE: Content-Length: 518
TRACE: ---- End HTTP Request Header Data ----
TRACE: ---- HTTP Status and Header Data: ----
TRACE: HTTP 1.1 201 Created
TRACE: content-type: application/json
TRACE: date: Thu, 30 May 2019 04:52:50 GMT
TRACE: location: https://api.chef.io/organizations/msystech/clients/dh-test-node-ubu1
TRACE: server: openresty/1.11.2.1
TRACE: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.17.29
TRACE: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
TRACE: content-length: 703
TRACE: connection: Close
TRACE: ---- End HTTP Status/Header Data ----
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
TRACE: Content-Length validated correctly.
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
Creating new node for dh-test-node-ubu1
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
TRACE: Signing the request as dh-test-node-ubu1
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
TRACE: Initiating PUT to https://api.chef.io/organizations/msystech/nodes/dh-test-node-ubu1
TRACE: ---- HTTP Request Header Data: ----
TRACE: Content-Type: application/json
TRACE: Accept: application/json
TRACE: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
TRACE: X-Ops-Server-API-Version: 1
TRACE: X-OPS-SIGN: algorithm=sha1;version=1.1;
TRACE: X-OPS-USERID: dh-test-node-ubu1
TRACE: X-OPS-TIMESTAMP: 2019-05-30T04:52:52Z
TRACE: X-OPS-CONTENT-HASH: Yr31Ik/82uU/fF/Lo68aAhQveR0=
TRACE: X-OPS-AUTHORIZATION-1: Vz5Jq9dVOzaBYEN8gkEavDZMs6wtZKaci+dnqsV4et0494GuDfkWoa6xUvEy
TRACE: X-OPS-AUTHORIZATION-2: O2F0m80gJEwBgH1D4f3WmGZnUfHaEc+CKG5AVBHD5uQ0apYVW5IZtWqhsQNv
TRACE: X-OPS-AUTHORIZATION-3: C5PstF51guLzwIYR0X4ZWyqtlIfPawh4Zkt3YqyIJl+XtVSftKxu8xAwSovP
TRACE: X-OPS-AUTHORIZATION-4: IEeEsMjq6wTjB6Um4E3cz8rVvveuGONpoDhtkGBrWA43ar+eiqvt1QeFagYB
TRACE: X-OPS-AUTHORIZATION-5: Kn1f5IC+JgDctGdw+LWYmXYySSHDQm3kDIrUt6R4o303upLZl5xgPpTMjH+H
TRACE: X-OPS-AUTHORIZATION-6: /eMVg70t9bvNMdI10u/zhZTG8jcpy4/0V3KwUZEUlQ==
TRACE: HOST: api.chef.io:443
TRACE: X-REMOTE-REQUEST-ID: 9ebea3fe-9cc1-4462-9a7d-023f2c7f2349
TRACE: Content-Length: 171
TRACE: ---- End HTTP Request Header Data ----
TRACE: ---- HTTP Status and Header Data: ----
TRACE: HTTP 1.1 404 Object Not Found
TRACE: date: Thu, 30 May 2019 04:52:51 GMT
TRACE: server: openresty/1.11.2.1
TRACE: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.17.29
TRACE: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
TRACE: content-length: 48
TRACE: connection: Close
TRACE: ---- End HTTP Status/Header Data ----
TRACE: ---- HTTP Response Body ----
TRACE: {"error":["node 'dh-test-node-ubu1' not found"]}
TRACE: ---- End HTTP Response Body -----
TRACE: ---- HTTP Request Body ----
TRACE: {"name":"dh-test-node-ubu1","chef_environment":"_default","json_class":"Chef::Node","automatic":{},"normal":{},"chef_type":"node","default":{},"override":{},"run_list":[]}
TRACE: ---- End HTTP Request Body ----
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
TRACE: Content-Length validated correctly.
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
TRACE: Expected JSON response, but got content-type ''
TRACE: Response body contains:
{"error":["node 'dh-test-node-ubu1' not found"]}
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
TRACE: Signing the request as dh-test-node-ubu1
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_request
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
TRACE: Initiating POST to https://api.chef.io/organizations/msystech/nodes
TRACE: ---- HTTP Request Header Data: ----
TRACE: Content-Type: application/json
TRACE: Accept: application/json
TRACE: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
TRACE: X-Ops-Server-API-Version: 1
TRACE: X-OPS-SIGN: algorithm=sha1;version=1.1;
TRACE: X-OPS-USERID: dh-test-node-ubu1
TRACE: X-OPS-TIMESTAMP: 2019-05-30T04:52:53Z
TRACE: X-OPS-CONTENT-HASH: Yr31Ik/82uU/fF/Lo68aAhQveR0=
TRACE: X-OPS-AUTHORIZATION-1: nJLcqgTsZiQVlRXAHhL3eGkzcYhfYPAoW9kdvywM9jWHcf6tROMfx/OyhruX
TRACE: X-OPS-AUTHORIZATION-2: /pikQK6uKF9slKH9FnpBkH64ys/L9kQH1kYGf6pn2zmyUg8DVYmHyQlWhKyn
TRACE: X-OPS-AUTHORIZATION-3: dwm3oUv5ldqV7vWKromp5AWvigXtiObvjZPHVWRdKgUQ0YfMDACB03PFPCIG
TRACE: X-OPS-AUTHORIZATION-4: CA1oxkP9g0lK7cg2y5eLB6T4QAYXIbcscF5F1G+ZrvJfKViLZjNnO+E/kUEC
TRACE: X-OPS-AUTHORIZATION-5: H6EFjnIN7VWpn1ksO81fzlMz5s+YQYv6Ol96Jr1eNlxRvazTkqWyfGXPQ5mX
TRACE: X-OPS-AUTHORIZATION-6: H04Nc2enD39U8Xdqm4EXrDE5yepPX2POCPdu3cuNhA==
TRACE: HOST: api.chef.io:443
TRACE: X-REMOTE-REQUEST-ID: 9ebea3fe-9cc1-4462-9a7d-023f2c7f2349
TRACE: Content-Length: 171
TRACE: ---- End HTTP Request Header Data ----
TRACE: ---- HTTP Status and Header Data: ----
TRACE: HTTP 1.1 201 Created
TRACE: content-type: application/json
TRACE: date: Thu, 30 May 2019 04:52:52 GMT
TRACE: location: https://api.chef.io/organizations/msystech/nodes/dh-test-node-ubu1
TRACE: server: openresty/1.11.2.1
TRACE: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.17.29
TRACE: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
TRACE: content-length: 76
TRACE: connection: Close
TRACE: ---- End HTTP Status/Header Data ----
TRACE: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
TRACE: Content-Length validated correctly.
TRACE: Chef::HTTP calling Chef::HTTP::APIVersions#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_response
TRACE: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
TRACE: Looking for bootstrap template in E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap/templates
TRACE: Found bootstrap template in E:/Backup/Project/Chef_Repo/chef/lib/chef/knife/bootstrap/templates
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (bash -c 'd=$(mktemp -d ${TMPDIR:-/tmp}/chef_XXXXXX); echo $d')
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (chown ubuntu '/tmp/chef_LkLyBA')
Bootstrapping ec2-54-218-175-214.us-west-2.compute.amazonaws.com
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (sh /tmp/chef_LkLyBA/bootstrap.sh)
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com] sh: 1:
: not found8-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com] sh: 2:
: not found8-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com] sh: 3:
: not found8-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com] sh: 4:
: not found8-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com]
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com] sh: 239:
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com] Syntax error: end of file unexpected (expecting "then")
 [ec2-54-218-175-214.us-west-2.compute.amazonaws.com]
ERROR: The following error occurred on ec2-54-218-175-214.us-west-2.compute.amazonaws.com:
ERROR:
DEBUG: [SSH] ubuntu@ec2-54-218-175-214.us-west-2.compute.amazonaws.com<{:user_known_hosts_file=>"/dev/null", :port=>22, :compression=>false, :compression_level=>0, :keepalive=>true, :keepalive_interval=>60, :timeout=>60, :auth_methods=>["none", "publickey"], :keys_only=>true, :keys=>["C:\\Users\\chef\\Downloads\\dh-aws-key.pem"], :password=>"<hidden>", :forward_agent=>nil, :non_interactive=>true, :verify_host_key=>:never}> (rm -f "/tmp/chef_LkLyBA/bootstrap.sh")

Facing same issue chef/knife-google#148

btm commented

After a handful of workarounds, this worked for me on ubuntu bootstrapping ubuntu with chef 15.0.308 and knife-ec2 1.0.0 (master / d75ff03).

ssh_user workaround:
@dheerajd-msys suggested putting knife[:ssh_user]='ubuntu' in my knife.rb, but at the moment I'm also testing knife profiles, so I put this in my .chef/credentials file:

[opscode-btm.knife]
ssh_user = 'ubuntu'

then ran:

knife ec2 server create --aws-profile chef-engineering -I ami-024a64a6685d05041 -g sg-0800ca7db33b765e0 -S btm-opscode-new -VVV

This was successful, so now I need to try to reproduce this on windows -> ubuntu.

btm commented

This is because when we evaluate the bootstrap template to disk on windows with Tempfile, it creates the file with CRLF/dos line endings. We then upload the file, and the line endings are preserved, which confuse/break sh when we try to execute the script.

chef/chef#8631 fixes this by switching the temp file to binmode to prevent Ruby from doing anything special regarding line endings. We'll want to test that this still works when bootstrapping windows from windows.