VMware Cloud Community
SimonSparksBetf
Contributor
Contributor
Jump to solution

Interaction with OpsCode Chef HTTP REST API from vCenter Orchestrator v5.1 Update 1

Interaction with OpsCode Chef HTTP REST API from vCenter Orchestrator v5.1 Update 1

I need to be able to use the HTTP REST API to initiate commands against the Chef server during provisioning and decommissioning of virtual machines.

Chef Server API Documents

This requires the ability to use the SHA1 algorithm and also the Base64 algorithm within vCenter Orchestrator v5.1 Update 1 to create the hashes header.

Method:HTTP_METHOD

Hashed Path:HASHED_PATH

X-Ops-Content-Hash:HASHED_BODY

X-Ops-Timestamp:TIME

X-Ops-UserId:USERID

where:

  • HTTP_METHOD is the method used in the API request (GET, POST, and so on)
  • HASHED_PATH is the path of the request (/name_of_endpoint for the open source server and /organizations/organization_name/name_of_endpoint for Hosted Chef or Private Chef). The HASHED_PATH must be hashed using SHA1 and encoded using Base64 and must not have repeated forward slashes (/) or end in a forward slash (unless the path is /).
  • The private key must be an RSA key in the SSL .pem file format. This signature is then broken into character strings (of not more than 60 characters per line) and placed in the header.

The server de-crypts this header and ensures its content matches the content of the non-encrypted headers that were in the request. The time stamp of the message is checked to ensure the request was received within a reasonable amount of time. One approach generating the signed headers is to use mixlib-authentication, which is a class-based header signing authentication object similar to the one used by the chef-client.

Any help with this would be greatly appreciated.

Reply
0 Kudos
1 Solution

Accepted Solutions
Dan_Linsley
VMware Employee
VMware Employee
Jump to solution

Perfect timing!  I've just been finalizing the docs and testing of a package for the Chef Server API this week:

CHEF Server Workflows

Let me know how it works for you!  Plus if there are other endpoints or scenarios I missed they should be easy to add.

View solution in original post

Reply
0 Kudos
8 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Joerg and I are reaching out to people in VMware who worked on chef integration.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
Reply
0 Kudos
tschoergez
Leadership
Leadership
Jump to solution

...forwarded to colleagues, hopefully we get some answer soon 🙂

Cheers,

Joerg

Reply
0 Kudos
Dan_Linsley
VMware Employee
VMware Employee
Jump to solution

Perfect timing!  I've just been finalizing the docs and testing of a package for the Chef Server API this week:

CHEF Server Workflows

Let me know how it works for you!  Plus if there are other endpoints or scenarios I missed they should be easy to add.

Reply
0 Kudos
SimonSparksBetf
Contributor
Contributor
Jump to solution

Which version of Chef were you using the plugin and workflows with ?

Reply
0 Kudos
Dan_Linsley
VMware Employee
VMware Employee
Jump to solution

It was developed and tested against Chef open source 11.0.8 and validated against a version of private Chef (I don't recall the version though).  It's designed to work with all three variations: open source, private, hosted.

Reply
0 Kudos
tmactive
Enthusiast
Enthusiast
Jump to solution

Trying this agains both an older version and 11.10, can't seem to get past this: ReferenceError: "ChefAuthUtil" is not defined. (Dynamic Script Module name : executeRequest#32)

Reply
0 Kudos
Dan_Linsley
VMware Employee
VMware Employee
Jump to solution

That object is part of the associated plugin with the package (o11nplugin-chef.dar).  Did you install in as a plugin through the orchestrator configuration interface and restart the orchestrator service?

Reply
0 Kudos
tmactive
Enthusiast
Enthusiast
Jump to solution

Reboot of Orchestrator host did it. Seems that's bit me, yet again Smiley Happy I didn't realize right away I had posted in someone else's thread, but perhaps this will help the next person.

Reply
0 Kudos