knife cookbook upload (ERROR: internal server error) - amazon-ec2

Been trying for hours to setup my own chef server on ec2. I launched an ubuntu 12.04 instance and installed open source chef server using the deb package. Then I associated an elastic ip, setup a host in route 53, updated the hostname. Also updated the ssl cert and key in .../ngnix/ca., restarted the chef server and ran chef-server-ctl reconfigure followed by chef-server-ctl test. All tests passed.
Then I followed this tutorial: http://blog.afistfulofservers.net/post/2011/03/16/a-brief-chef-tutorial-from-concentrate/
Just trying to upload a simple ntp cookbook.
knife cookbook upload ntp -VV
and this get this output.
please help!
` ubuntu#chef:~/workspace/chef-repo$ knife cookbook upload ntp -VV
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::JSONToModelOutput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
DEBUG: Signing the request as rayhwang
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Initiating GET to https://chef.originalfunction.com/cookbooks?num_versions=all
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: Accept: application/json
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
DEBUG: X-OPS-USERID: rayhwang
DEBUG: X-OPS-TIMESTAMP: 2014-06-19T17:12:14Z
DEBUG: X-OPS-CONTENT-HASH: 2jmj7l5rSw0yVb/vlWAYkK/YBwk=
DEBUG: X-OPS-AUTHORIZATION-1: O3rGoHt5f9pv8VMIPQF71lKugcFCuLW0bAU05Tlus+vIWhk0yd/JIvYPU9l0
DEBUG: X-OPS-AUTHORIZATION-2: pkkNVlPHEu5eCHvi2W8kJWVqaSBb6PwtUv5nPM/oeuI8lWpr9uUlUKh6vcr8
DEBUG: X-OPS-AUTHORIZATION-3: n5Q0jA2NqjBisRSRn6ROriJis0x4xuReXj1y12234wOjDAa7xcT/ssEXzjNw
DEBUG: X-OPS-AUTHORIZATION-4: ZFwmr95cDEA7FuOgtAGt0RWib8ZkdWYerGbW2n1lv4pKMAl9c6fDgOuN1z9A
DEBUG: X-OPS-AUTHORIZATION-5: 1hhvo0l0hH/q/DcRhePG8rBR67iN4KcsashiyMOVbM9qyDSHUfk99OrjHYys
DEBUG: X-OPS-AUTHORIZATION-6: UCWvq3569li6bBRqCx1a20Ze2kuHKvMxhasjSwcaig==
DEBUG: HOST: chef.originalfunction.com:443
DEBUG: X-REMOTE-REQUEST-ID: 1d230738-c4b4-4d69-b71c-12d4203cf5f8
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:14 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 2
DEBUG: connection: close
DEBUG: x-ops-api-info: flavor=osc;version=11.0.2;erchef=1.4.0
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Content-Length validated correctly.
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONToModelOutput#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
Uploading ntp [0.1.0]
DEBUG: No chefignore file found at /home/ubuntu/workspace/chef-repo/.chef/../cookbooks/chefignore no files will be ignored
INFO: Validating ruby files
DEBUG: Ruby file /home/ubuntu/workspace/chef-repo/.chef/../cookbooks/ntp/recipes/default.rb is unchanged, skipping syntax check
DEBUG: Ruby file /home/ubuntu/workspace/chef-repo/.chef/../cookbooks/ntp/metadata.rb is unchanged, skipping syntax check
INFO: Validating templates
DEBUG: Template /home/ubuntu/workspace/chef-repo/.chef/../cookbooks/ntp/templates/default/ntp.conf.erb is unchanged, skipping syntax check
INFO: Syntax OK
INFO: Saving ntp
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::JSONToModelOutput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
DEBUG: Signing the request as rayhwang
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Initiating POST to https://chef.originalfunction.com/sandboxes
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: Content-Type: application/json
DEBUG: Accept: application/json
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
DEBUG: X-OPS-USERID: rayhwang
DEBUG: X-OPS-TIMESTAMP: 2014-06-19T17:12:15Z
DEBUG: X-OPS-CONTENT-HASH: trgzi7/cKkm3nQVgxJylZYUyXQo=
DEBUG: X-OPS-AUTHORIZATION-1: fJSAIpj1nQMBCRiDxjMfjiZb4+0JO4G4H8EKIvdNOxtpZfY0hyQm0CTRhXnd
DEBUG: X-OPS-AUTHORIZATION-2: dwmcgy2aiPYSQjxoav1UPx4S+kVNEhJDgWOR5g0tFlucNZwL7iHik/qPCrXm
DEBUG: X-OPS-AUTHORIZATION-3: pUoJ+TUiCWpBy4W9NGPsfqE4WHcNm6x+d/V/EV36hdPzdkAO9YmB1QRxIQrd
DEBUG: X-OPS-AUTHORIZATION-4: Jy6VukLzLGdPzcpSDDmA2u27AtPhI2qvJlH5xHT6Nb3fiT8pQCcdH7YWNbC/
DEBUG: X-OPS-AUTHORIZATION-5: MUm2wMZuSrNGVEgBCt/3ZSU16SMEp0BlXGdEoxwjoq4iiWNhm8CQgg57XjMz
DEBUG: X-OPS-AUTHORIZATION-6: pcpNk6WDgBIChp8gshclhkLtn619CJePcKnIU5C47g==
DEBUG: HOST: chef.originalfunction.com:443
DEBUG: X-REMOTE-REQUEST-ID: 1d230738-c4b4-4d69-b71c-12d4203cf5f8
DEBUG: Content-Length: 215
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 201 Created
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 1772
DEBUG: connection: close
DEBUG: x-ops-api-info: flavor=osc;version=11.0.2;erchef=1.4.0
DEBUG: location: http://chef.originalfunction.com:443/sandboxes/00000000000002353a650204d5f4d7eb
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Content-Length validated correctly.
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONToModelOutput#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
INFO: Uploading files
INFO: Uploading /home/ubuntu/workspace/chef-repo/cookbooks/ntp/recipes/default.rb (checksum hex = bbefe633613e76a79797713ac99604ff) to https://chef.originalfunction.com:443/bookshelf/organization-00000000000000000000000000000000/checksum-bbefe633613e76a79797713ac99604ff?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=puzm8RkYYnH%2BdOlsa1k1pl3zT1k%3D
INFO: Uploading /home/ubuntu/workspace/chef-repo/cookbooks/ntp/templates/default/ntp.conf.erb (checksum hex = 1a2e519cdc43799100bf074f4b96a50b) to https://chef.originalfunction.com:443/bookshelf/organization-00000000000000000000000000000000/checksum-1a2e519cdc43799100bf074f4b96a50b?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=w6RU9GAtWATjeEAYtB05JxrGbA0%3D
INFO: Uploading /home/ubuntu/workspace/chef-repo/cookbooks/ntp/README.md (checksum hex = d3e0411a88dfd6905fe57e5e6975e630) to https://chef.originalfunction.com:443/bookshelf/organization-00000000000000000000000000000000/checksum-d3e0411a88dfd6905fe57e5e6975e630?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=C7vKsEE1F%2B1j76DtI5385ZULMEs%3D
INFO: Uploading /home/ubuntu/workspace/chef-repo/cookbooks/ntp/CHANGELOG.md (checksum hex = 43e746152c1a63002b6a306a94666368) to https://chef.originalfunction.com:443/bookshelf/organization-00000000000000000000000000000000/checksum-43e746152c1a63002b6a306a94666368?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=vm2cI5AVzNIipkRZGnRH%2BRK874g%3D
INFO: Uploading /home/ubuntu/workspace/chef-repo/cookbooks/ntp/metadata.rb (checksum hex = 8af72e56cfd5f3aedb1d5a5c77ba8ab7) to https://chef.originalfunction.com:443/bookshelf/organization-00000000000000000000000000000000/checksum-8af72e56cfd5f3aedb1d5a5c77ba8ab7?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=DnoM16WYVq4VhbjsiSvTZWaFabQ%3D
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Initiating PUT to https://chef.originalfunction.com/bookshelf/organization-00000000000000000000000000000000/checksum-1a2e519cdc43799100bf074f4b96a50b?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=w6RU9GAtWATjeEAYtB05JxrGbA0%3D
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: content-type: application/x-binary
DEBUG: content-md5: Gi5RnNxDeZEAvwdPS5alCw==
DEBUG: accept: application/json
DEBUG: X-Ops-Sign: algorithm=sha1;version=1.0;
DEBUG: X-Ops-Userid: rayhwang
DEBUG: X-Ops-Timestamp: 2014-06-19T17:12:15Z
DEBUG: X-Ops-Content-Hash: B7IhBLQbRkoCUtlseIpTx5ODlNM=
DEBUG: X-Ops-Authorization-1: UEOLzo2dr12JKXgOXZyxxBu4qzMebcTD15tS5dLWIRhhKkhfs7JWToDBMEqM
DEBUG: X-Ops-Authorization-2: UdPTKjJI+/hUo9CIdngFcshXejMuVQQ808hoNA35VSr5tKA7rKXpEKu3p1X6
DEBUG: X-Ops-Authorization-3: g6NC1R/SKWPAGhYA4m6rwyMsrsZ1ETh8WR27GrKAJ1Jgqg89GyR6Oessub+V
DEBUG: X-Ops-Authorization-4: rOFy3kNpM19NbESqYaL3nMzZWep/TbUu0j8KaUkZM5YFvcsc3TBGk5lZYEFd
DEBUG: X-Ops-Authorization-5: iwwNXmDMIN4r5e1lZv7BtEws4qJCEgLBjaS1oReQO4qqffwZxcsj1ygHPer1
DEBUG: X-Ops-Authorization-6: JReBLIqLlj4t7NMU22EkBZL1bfMarDdOsO9Ix+soBg==
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: Content-Length: 275
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: Initiating PUT to https://chef.originalfunction.com/bookshelf/organization-00000000000000000000000000000000/checksum-d3e0411a88dfd6905fe57e5e6975e630?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=C7vKsEE1F%2B1j76DtI5385ZULMEs%3D
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: content-type: application/x-binary
DEBUG: content-md5: 0+BBGojf1pBf5X5eaXXmMA==
DEBUG: accept: application/json
DEBUG: X-Ops-Sign: algorithm=sha1;version=1.0;
DEBUG: X-Ops-Userid: rayhwang
DEBUG: X-Ops-Timestamp: 2014-06-19T17:12:15Z
DEBUG: X-Ops-Content-Hash: DE1oiQN0K9neW6A+7u/2NzQ/W4o=
DEBUG: X-Ops-Authorization-1: fiCtNCKht0VPOvXMBPFmUz7+uQ2qSRk6U1B8uoqxzvvvTXR/KduDweyHI51y
DEBUG: X-Ops-Authorization-2: GN6dpyxisDTfebYsQLnCzmtDlhlj5lEtQ9GUFxpPjEDSInQO3ZVohd3MsDGC
DEBUG: X-Ops-Authorization-3: R2d/xvONhA7RJgnP3uPLR2VcXsafjSCycGOf4Ul5A366Ys3NTW/wS0gTH0t4
DEBUG: X-Ops-Authorization-4: lGactDkxHh0EnQq41K8j82waTnYsaGBci9NRTYxUgHPHLT8llX/2gke4KMy0
DEBUG: X-Ops-Authorization-5: S2oEBWhZnOSn1A3Js8ofUmCJ6UvQBIomZDjisDvKARZVKMbE/4jHPw8IsDqf
DEBUG: X-Ops-Authorization-6: mVps4JZJ5AnBg/MGTBSb0kwE1wJV35m7Bl8pMncErw==
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: Content-Length: 1424
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Initiating PUT to https://chef.originalfunction.com/bookshelf/organization-00000000000000000000000000000000/checksum-43e746152c1a63002b6a306a94666368?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=vm2cI5AVzNIipkRZGnRH%2BRK874g%3D
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: content-type: application/x-binary
DEBUG: content-md5: Q+dGFSwaYwArajBqlGZjaA==
DEBUG: accept: application/json
DEBUG: X-Ops-Sign: algorithm=sha1;version=1.0;
DEBUG: X-Ops-Userid: rayhwang
DEBUG: X-Ops-Timestamp: 2014-06-19T17:12:15Z
DEBUG: X-Ops-Content-Hash: xrD6SmanZIPZariIevDsxEdIYwc=
DEBUG: X-Ops-Authorization-1: FBv6fegrNfG6hzo9JHfXAUWYgNE8jYExuLEpKCPL9R3j65k64/gTvMHAvzDt
DEBUG: X-Ops-Authorization-2: vZSmZOl2y/AekvxZgcpQcfnODn+0ol2cXcoQUjuK9fTy0BDskUHEp+ZT0FUE
DEBUG: X-Ops-Authorization-3: 2VylMn8O2rmDC3yuvGk50+DUXoRmEcIG+R0kZ1HAtO17wv713GYZ7knOML9u
DEBUG: X-Ops-Authorization-4: bIz9HiuMKKhfhTHjO18cDPlDkZIimjkowlhNQl3rTBqEqCaQ4zdWOUqWrHeY
DEBUG: X-Ops-Authorization-5: 429PuSxb0aghzEjcAxAMvgyXb/7pijPRFgyMjXbiTPO1qIz6I/hAFxyoHWY5
DEBUG: X-Ops-Authorization-6: NwbuwIYlFQyV4RYj5BwYBhmuKZnUmqmPlj0NsUHYZA==
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: Content-Length: 439
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: Initiating PUT to https://chef.originalfunction.com/bookshelf/organization-00000000000000000000000000000000/checksum-8af72e56cfd5f3aedb1d5a5c77ba8ab7?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=DnoM16WYVq4VhbjsiSvTZWaFabQ%3D
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: content-type: application/x-binary
DEBUG: content-md5: ivcuVs/V867bHVpcd7qKtw==
DEBUG: accept: application/json
DEBUG: X-Ops-Sign: algorithm=sha1;version=1.0;
DEBUG: X-Ops-Userid: rayhwang
DEBUG: X-Ops-Timestamp: 2014-06-19T17:12:15Z
DEBUG: X-Ops-Content-Hash: XoOuSZFMGBbUEtZkO+3JXkPjraY=
DEBUG: X-Ops-Authorization-1: RJmE+qqBpN6AFc0a4tJ1HQtq9zu72tgPS1xwTcxUvC8nJhdNXJdolWBsTV1y
DEBUG: X-Ops-Authorization-2: Wl6OuqMbcThaXFnhYguj+mq7M1GGgwHf6onzScer0z43JoFPAGLgNRwvsBUM
DEBUG: X-Ops-Authorization-3: eA9XGsi5nX6rqbTeCClRujF2zBBKxfjzgQKlKZaQT5i+Tkmxi+JW6eGcdnCR
DEBUG: X-Ops-Authorization-4: mwk11NM95dIIRh/pI72Tr0K17i6kKzHLnJjSlP15dyoUxnLu4PsydIXMCtqH
DEBUG: X-Ops-Authorization-5: maVl8Z6qjPPB1EehqaUfOwRA5henKn55lrsBzgf9IQz3Hoi8MNht9xY4mDaB
DEBUG: X-Ops-Authorization-6: QOQdighUY5/3Z5BAj7JvYcSbPIthuKdM86ZPtd3SBw==
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: Content-Length: 290
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: Initiating PUT to https://chef.originalfunction.com/bookshelf/organization-00000000000000000000000000000000/checksum-bbefe633613e76a79797713ac99604ff?AWSAccessKeyId=ee81637c54a846e63c3690be759203a8fca05c93&Expires=1403198835&Signature=puzm8RkYYnH%2BdOlsa1k1pl3zT1k%3D
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: content-type: application/x-binary
DEBUG: content-md5: u+/mM2E+dqeXl3E6yZYE/w==
DEBUG: accept: application/json
DEBUG: X-Ops-Sign: algorithm=sha1;version=1.0;
DEBUG: X-Ops-Userid: rayhwang
DEBUG: X-Ops-Timestamp: 2014-06-19T17:12:15Z
DEBUG: X-Ops-Content-Hash: As+jO7AROTDuK2wG6/heed0nbjE=
DEBUG: X-Ops-Authorization-1: lfF8Jy5Ayz5vKcqV/hACwJzALiXkoqAbqkEmhtJsICX/3v2srJ71JaZoUczk
DEBUG: X-Ops-Authorization-2: yxnESOarrgjeQClX9WMOgb4or/J5YiWDiEOEr5+fDfhv+I6ZxLYr9DvsDMnm
DEBUG: X-Ops-Authorization-3: oXbgqyPrw35+jwmXnk7YQ4/GRadENWfBTkeUEvbTJ1X5QxBsgRGKKHO4zL9t
DEBUG: X-Ops-Authorization-4: qWlJMdIXesKLWl1+hGuXZ9pUA33U0QqGPBCp+b5MxGUPHhqoYda9yB9CL8SG
DEBUG: X-Ops-Authorization-5: PJ19tFBB6Gblll1+4ObEaYkenrPxutOj8EXfE7GPiWcPfzsY9ZWL/m0adyW6
DEBUG: X-Ops-Authorization-6: qYCKOfaqFRM2eFARQD+MFwcNv90Wbbl2oIxXsl3c4A==
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: Content-Length: 322
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 204 No Content
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 0
DEBUG: connection: close
DEBUG: x-amz-request-id: g2gCZAATYm9va3NoZWxmQDEyNy4wLjAuMWgDYgAABXtiAAMFL2IABVJQ
DEBUG: etag: 0+BBGojf1pBf5X5eaXXmMA==
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 204 No Content
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 0
DEBUG: connection: close
DEBUG: x-amz-request-id: g2gCZAATYm9va3NoZWxmQDEyNy4wLjAuMWgDYgAABXtiAAMFL2IABVqE
DEBUG: etag: Gi5RnNxDeZEAvwdPS5alCw==
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 204 No Content
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 0
DEBUG: connection: close
DEBUG: x-amz-request-id: g2gCZAATYm9va3NoZWxmQDEyNy4wLjAuMWgDYgAABXtiAAMFL2IABZs7
DEBUG: etag: Q+dGFSwaYwArajBqlGZjaA==
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 204 No Content
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 0
DEBUG: connection: close
DEBUG: x-amz-request-id: g2gCZAATYm9va3NoZWxmQDEyNy4wLjAuMWgDYgAABXtiAAMFL2IABbo2
DEBUG: etag: ivcuVs/V867bHVpcd7qKtw==
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 204 No Content
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 0
DEBUG: connection: close
DEBUG: x-amz-request-id: g2gCZAATYm9va3NoZWxmQDEyNy4wLjAuMWgDYgAABXtiAAMFL2IABzNL
DEBUG: etag: u+/mM2E+dqeXl3E6yZYE/w==
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: Committing sandbox
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::JSONToModelOutput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
DEBUG: Signing the request as rayhwang
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_request
DEBUG: Initiating PUT to https://chef.originalfunction.com/sandboxes/0000000000008170b3f221f9b2144a84
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: Content-Type: application/json
DEBUG: Accept: application/json
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
DEBUG: X-OPS-USERID: rayhwang
DEBUG: X-OPS-TIMESTAMP: 2014-06-19T17:12:15Z
DEBUG: X-OPS-CONTENT-HASH: oMRtV6loUDnbKJuGcW6nqBbF8ww=
DEBUG: X-OPS-AUTHORIZATION-1: DoblHxKdB3zjRPyuNULSlTXmusmy+TL+gQ/3+TWv1yPejJvaNt46DutW5//n
DEBUG: X-OPS-AUTHORIZATION-2: jfBh+Oot1l5mWfIwall2MH7BraHveavQCE1Thr4p2JoJff3cPsX1yiWhP5jd
DEBUG: X-OPS-AUTHORIZATION-3: cnmO1VNdwXFvgyrT7/2NOcicp+KDgv1tZ/JongFvVPvc0WYnR4mhk8+GGgmP
DEBUG: X-OPS-AUTHORIZATION-4: pVICKVUN1PM7fqhiEW17jN4yNrIQhGfW8jQLDnfYTT0GXbC4Mhoc2paJcGUj
DEBUG: X-OPS-AUTHORIZATION-5: /BZiqfFgF1Ymlh1vFR7yU+mfE3b2pA1aKyajWdNSekBcGQHkdknVuZxMDIp4
DEBUG: X-OPS-AUTHORIZATION-6: fv+NYIfIR6QKT2Opj+BsCjnctUEL+UxQyjfbieTwqQ==
DEBUG: HOST: chef.originalfunction.com:443
DEBUG: X-REMOTE-REQUEST-ID: 1d230738-c4b4-4d69-b71c-12d4203cf5f8
DEBUG: Content-Length: 21
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 500 Internal Server Error
DEBUG: server: nginx/1.4.4
DEBUG: date: Thu, 19 Jun 2014 17:12:15 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 36
DEBUG: connection: close
DEBUG: x-ops-api-info: flavor=osc;version=11.0.2;erchef=1.4.0
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: Chef::HTTP calling Chef::HTTP::ValidateContentLength#handle_response
DEBUG: Content-Length validated correctly.
DEBUG: Chef::HTTP calling Chef::HTTP::RemoteRequestID#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONToModelOutput#handle_response
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_response
INFO: HTTP Request Returned 500 Internal Server Error: internal service error
/opt/chefdk/embedded/lib/ruby/2.1.0/net/http/response.rb:119:in `error!': 500 "Internal Server Error" (Net::HTTPFatalError)
from /opt/chefdk/embedded/apps/chef/lib/chef/http.rb:143:in `request'
from /opt/chefdk/embedded/apps/chef/lib/chef/http.rb:116:in `put'
from /opt/chefdk/embedded/apps/chef/lib/chef/cookbook_uploader.rb:105:in `upload_cookbooks'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife/cookbook_upload.rb:243:in `upload'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife/cookbook_upload.rb:129:in `block in run'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife/cookbook_upload.rb:126:in `each'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife/cookbook_upload.rb:126:in `run'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:492:in `run_with_pretty_exceptions'
from /opt/chefdk/embedded/apps/chef/lib/chef/knife.rb:174:in `run'
from /opt/chefdk/embedded/apps/chef/lib/chef/application/knife.rb:135:in `run'
from /opt/chefdk/embedded/apps/chef/bin/knife:25:in `<top (required)>'
from /usr/bin/knife:30:in `load'
from /usr/bin/knife:30:in `<main>'`

Related

Extract a value from the output and then use it in next task

I'd like to extract just a one value from below output and to be exactly, the host line.
Like:
host: host-1.example.com
The playbook itself:
---
- name: Get fortios_configuration_fact
hosts: fortigate
connection: httpapi
collections:
- fortinet.fortios
gather_facts: no
vars:
ansible_httpapi_port: 4443
ansible_httpapi_use_ssl: yes
ansible_httpapi_validate_certs: no
username: some-name
tasks:
- name: Retrieve Facts of FortiOS Configurable Objects
fortinet.fortios.fortios_configuration_fact:
access_token: "{{ vault_access_token }}"
selector: "vpn.ssl.web_user-bookmark"
formatters:
- bookmarks
params:
name: "{{ username }}"
sorters:
- logon-user
register: ssl_vpn_results
- ansible.builtin.debug:
msg: "{{ ssl_vpn_results.meta.results }}"
And I have this Ansible output:
- bookmarks:
- additional-params: ''
apptype: vnc
color-depth: '16'
description:
domain: ''
folder: ''
form-data: []
host: host-1.example.com
keyboard-layout: en-us
load-balancing-info: ''
logon-password: ENC XXXX
logon-user: some-user
name: some-name
port: 5909
preconnection-blob: ''
preconnection-id: 0
q_origin_key: some-description
restricted-admin: disable
security: rdp
send-preconnection-id: disable
sso: disable
sso-credential: sslvpn-login
sso-credential-sent-once: disable
sso-password: ''
sso-username: ''
url: ''
custom-lang: ''
name: some-name
q_origin_key: some-description
Without '.meta.results' in debug message I have this output:
ok: [fortinet_vd] =>
msg:
changed: false
failed: false
meta:
build: 234
http_method: GET
http_status: 200
mkey: user-mkey
name: user-bookmark
path: vpn.ssl.web
results:
- bookmarks:
- additional-params: ''
apptype: vnc
color-depth: '16'
description: some-description
domain: ''
folder: ''
form-data: []
host: host-1.example.com
keyboard-layout: en-us
load-balancing-info: ''
logon-password: ENC XXXX
logon-user: some-user
name: some-name
port: 5909
preconnection-blob: ''
preconnection-id: 0
q_origin_key: some-user
restricted-admin: disable
security: rdp
send-preconnection-id: disable
sso: disable
sso-credential: sslvpn-login
sso-credential-sent-once: disable
sso-password: ''
sso-username: ''
url: ''
revision: 9e0c1a3432bb884fdebaeaefdb0a51be
serial: serial-nbr
status: success
vdom: root
version: v7.0.2
I tried many ansible filters to manipulate the data, but failed.
Can you help with any ideas?
Both attributes results and bookmarks are lists. You can get the first items from the lists, e.g.
- debug:
msg: "{{ ssl_vpn_results.meta.results.0.bookmarks.0.host }}"
gives
msg: host-1.example.com
There might be more items both in the results and bookmarks. You can use json_query to select all host, e.g.
- debug:
msg: "{{ ssl_vpn_results.meta.results|
json_query('[].bookmarks[].host') }}"
gives the list
msg:
- host-1.example.com
You can also iterate results and list all hosts for a particular item, e.g.
- debug:
msg: "{{ item.name }}: {{ item.bookmarks|json_query('[].host') }}"
loop: "{{ ssl_vpn_results.meta.results }}"
loop_control:
label: "{{ item.name }}"
gives
TASK [debug] *******************************************************
ok: [localhost] => (item=some-name) =>
msg: 'some-name: [''host-1.example.com'']'
you have to do this task: results and bookmarks are lists
- name: display
debug:
msg: the value of host is {{ ssl_vpn_results.meta.results.0.bookmarks.0.host }}
and you have the result wanted!!

ansible is trowing a Syntax Error while loading YAML. did not find expected key

my yml looks like:
---
# YAML documents begin with the document separator ---
# The minus in YAML this indicates a list item. The playbook contains a list
# of plays, with each play being a dictionary
-
# Hosts: where our play will run and options it will run with
hosts: localhost
gather_facts: false
# Vars: variables that will apply to the play, on all target systems
vars:
DDVE_public_IP : 34.107.103.175
destination_port: 3009
Instance_id : 8529834022607504819
S3_bucket_name : bucket_for_ddve_6
# Tasks: the list of tasks that will be executed within the playbook
tasks:
- name: login access token
uri:
url: https://{{ DDVE_public_IP }}:{{ destination_port }}/{{ resource_path }}
method: POST
headers:
Content-Type: application/json
body_format: json
body:
username: sysadmin
password: {{ Instance_id }}
return_content: yes
ignore_errors: yes
register: rest_post
vars:
resource_path: rest/v1.0/auth
- name: DEBUG / GOT INFO
debug:
msg: "{{ rest_post.json }}"
when: rest_post.status == 201
# Handlers: the list of handlers that are executed as a notify key from a task
# Roles: list of roles to be imported into the play
# Three dots indicate the end of a YAML document
...
ansible-playbook ddve6-post-deploy-object-store.yml
[WARNING]: No inventory was parsed, only implicit localhost is available.
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'.
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
did not find expected key
The error appears to be in '/Users/juergen/Documents/DPSCodeAcademy/Ansible/#dev/ddve/ddve6-post-deploy-object-store.yml': line 30, column 9, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
password: {{ Instance_id }}
return_content: yes
^ here
I have no idea where that error is coming as I can't find the responding problem here.
You just have some indentation errors in that YAML document. Pick an indentation level (e.g., 2 spaces for every level) and stick with it consistently. Many editors have plugins that will syntax check your YAML documents while you write them.
The following validates correctly:
---
- hosts: localhost
gather_facts: false
vars:
DDVE_public_IP: 34.107.103.175
destination_port: 3009
Instance_id: 8529834022607504819
S3_bucket_name: bucket_for_ddve_6
tasks:
- name: login access token
uri:
url: https://{{ DDVE_public_IP }}:{{ destination_port }}/{{ resource_path }}
method: POST
headers:
Content-Type: application/json
body_format: json
body:
username: sysadmin
password: "{{ Instance_id }}"
return_content: true
ignore_errors: true
register: rest_post
vars:
resource_path: rest/v1.0/auth
- name: DEBUG / GOT INFO
debug:
msg: "{{ rest_post.json }}"
when: rest_post.status == 201
Note that it is highly uncommon to terminate your YAML documents with the ... marker.

Ansible tasks still run regardless of tags

I have following playbook. If I run with --tags "decommision", only 2 tasks were triggered which is correct. But when I run the playbook with --tags "deliver", the last tasks is still running regardless of its tags being "decommission". I can't seem to figure out. My indentation is fine too.
tasks:
- name: Change PS 1
command: sed -i 's/PS1=\"\[\\u\#\\h\ \\W\]/PS1=\"\[\\u\#\\H\ \\W\]/g' /etc/bashrc
tags: deliver, update
- name: Update Info In CMDB
uri:
url: "update url"
method: POST
body: {"ip_list": ["{{ ansible_host }}"]}
body_format: json
tags: deliver, update
- name: Remove Old Targets
uri:
url: "remove url"
method: POST
body: {"job_name": "{{ jobname }}", "host_list": ["{{ ansible_host }}"]}
body_format: json
tags: deliver, decommision, update
- name: Associate Host With Prometheus
uri:
url: "prometheus url"
method: POST
body: {"ip_list": [ "{{ ansible_host }}" ]}
body_format: json
tags: deliver
- name: Register monitoring job
uri:
url: "register url"
method: POST
body: {"host_list": ["{{ ansible_host }}"]}
body_format: json
tags: deliver, update_hostname
- name: Remove Association Host With Prometheus
uri:
url: "remove url"
method: POST
body: {"ip_list": [ "{{ ansible_host }}" ]}
body_format: json
tags: decommision
Works as expected
shell> cat pb.yml
- hosts: localhost
gather_facts: false
tasks:
- debug:
msg: Change PS 1
tags: deliver, update
- debug:
msg: Update Info In CMDB
tags: deliver, update
- debug:
msg: Remove Old Targets
tags: deliver, decommision, update
- debug:
msg: Associate Host With Prometheus
tags: deliver
- debug:
msg: Register monitoring job
tags: deliver, update_hostname
- debug:
msg: Remove Association Host With Prometheus
tags: decommision
gives (abridged)
shell> ansible-playbook pb.yml --tags "deliver" | grep msg\:
msg: Change PS 1
msg: Update Info In CMDB
msg: Remove Old Targets
msg: Associate Host With Prometheus
msg: Register monitoring job

Ansible - Try to get a file on multiple url and fail only if all url have been called and file has not been found

I have a file that could be located on 1 of 3 urls, but not in the two others
I would like to try to get the file on each url:
Sucess if the file is found during one of the iterations
Fail if it's the end of the loop and the file has not been found
I have tried this :
- name : Try to get the file
uri:
url: "{{ item }}"
return_content: yes
status_code:
- 200
- 404
register: module_result
with_items:
- http://url_1/file.txt
- http://url_2/file.txt
- http://url_3/file.txt
when: module_result is not defined or module_result.status == 404
But there is some not handled cases:
Other http code than 200 or 404 is returned
The last iteration return 404 the task and should fail.
So my questions are :
Is there a way to handle all HTTP returned code without writing all existing codes in status_code?
How to fail the task when the last iteration doesn't return HTTP 200?
Thank you
Try this:
- name: Try to get the file
uri:
url: "{{ item }}"
return_content: yes
register: module_result
with_items:
- http://url_1/file.txt
- http://url_2/file.txt
- http://url_3/file.txt
ignore_errors: yes
- name: Register if there was any 200 status code
set_fact:
existing_file: "{{ item }}"
with_items: "{{ module_result.results }}"
when: item.status is defined and item.status == 200
- name: Fail if no 200 status code received
fail:
msg: No such file
when: existing_file is not defined
- name: Display file content
debug:
msg: "{{ existing_file.content }}"
Loop over all URLs without failing at all
Loop over results and set existing_file variable only if result with 200 status code was found
Fail if existing_file is not defined
If not failed then your file content is in existing_file.content (and in this example will be displayed with debug)

Is it possible to use variable in path with lineinfile ansible module?

I have a playbook
---
- hosts: 127.0.0.1
connection: local
vars:
WORK_DIR: /somefolder
tasks:
- debug:
msg: "{{ WORK_DIR }}"
- lineinfile:
path: /somefolder/some.file
regexp: '"display_name":'
line: ' "display_name": "another_name",'
works fine and I have a debug
ok: [127.0.0.1] => {
"msg": "/somefolder"
}
but when I try to use variable in path like
- hosts: 127.0.0.1
connection: local
vars:
WORK_DIR: /somefolder
tasks:
- debug:
msg: "{{ WORK_DIR }}"
- lineinfile:
path: "{{ WORK_DIR }}"/some.file
regexp: '"display_name":'
line: ' "display_name": "another_name",'
there is an error
- lineinfile:
path: "{{ WORK_DIR }}"/some.file
^ here
The question is why ? Is this a bug or feature or something else ?
Quotes misuse.
You should use path: "{{ WORK_DIR }}/some.file".

Resources