Skip to content

Instantly share code, notes, and snippets.

@jkeiser
Created December 10, 2015 21:07
Show Gist options
  • Save jkeiser/42afd5c42317b29eaa33 to your computer and use it in GitHub Desktop.
Save jkeiser/42afd5c42317b29eaa33 to your computer and use it in GitHub Desktop.
Cookbook Uploads and Artifacts
cookbooks/
if directory_name =~ /-\d+\.\d+\.\d+/
the directory name is <cookbook name>-<version>
elsif directory_name =~ /-/
else
the directory name is the cookbook name, metadata has the version
end
cookbook_artifacts/apache2/SHA
1. [local] Checksum all the files in the cookbook I want to upload.
2. POST /sandboxes with the list of checkums:
{
"id": "sandbox_xyz",
"checksums": {
"13489713598137591387": {},
"98312749123874913874": {}
}
}
3. The POST responds with the URLs to upload to and whether they are already there:
{
"112413451341343121341": {
"needs_upload": true,
"url": "http://127.0.0.1/file_store/checksums/112413451341343121341"
},
"135987139857139875987153": {
"needs_uplaod": false
}
}
4. The client uploads the files with those checksums to the relevant URLs, using PUT to the URL.
PUT http://127.0.0.1/file_store/checksums/112413451341343121341
This is the
content of the
file
5. The client informs the server that it has uploaded all the files by doing a PUT to the sandbox:
PUT /sandboxes/sandbox_xyz
{ "complete": true }
Cookbooks:
6. The client does a PUT to the cookbook (/cookbooks/apache2/1.0.0) with the metadata, which includes the checksums and URLs of all the files, as well as their relative location in the cookbook:
{
...
"files": [
{
"path": "files/default",
"url": "http://127.0.0.1/file_store/checksums/112413451341343121341",
"checksum": "112413451341343121341"
}
]
}
In chef-zero memory store, we just leave the data this way:
- file_store/checksums/112413451341343121341
<file contents>
- cookbooks/apache2/1.0.0
{ <list of files and their checksums> }
In ChefFS, we do the above, but when the cookbook is actually uploaded, we make a directory for it and move the files there.
- cookbooks/apache2/1.0.0/metadata.rb
- /recipes/default.rb
- /.cookbook-version.json
- cookbook_artifacts/apache2/ASDFLKJASFLKAJSDF
cookbook_artifacts/apache2/ASDFLKJASFLKAJSDF/metadata.rb
/recipes/default.rb
cookbooks/apache2
cookbook_artifacts/apache2/SHASUM
we try to make the resulting cookbook readable and intelligible:
Cookbook Artifacts:
6. The client does a PUT to the cookbook_artifact (/cookbook_artifacts/apache2/ABCDEFG) with the metadata, which includes the checksums and URLs of all the files, as well as their relative location in the cookbook:
{
...
"files": [
{
"path": "files/default",
"url": "http://127.0.0.1/file_store/checksums/112413451341343121341",
"checksum": "112413451341343121341"
}
]
}
cookbooks/
apache2/
metadata.rb
recipes/default.rb
policies/
SHA of apache2
apache2/
metadata.rb
recipes/default.rb
mysql-1.0.0/
metadata.rb
recipes/default.rb
Chef::Config.versioned_cookbooks = true
cookbooks/
apache2-1.0.0/
metadata.rb
recipes/default.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment