Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Add file_cache_path support for Chef #14

Merged
merged 3 commits into from
Jul 22, 2013

Conversation

patcon
Copy link
Collaborator

@patcon patcon commented Jun 11, 2013

Forked issue from #12

@fgrehm
Copy link
Owner

fgrehm commented Jun 11, 2013

@patcon Just checking, would be possible (at least in theory) to have file_cache_path supported for :chef_solo? I can try to make it a PR for vagrant itself if it is ;)

@patcon
Copy link
Collaborator Author

patcon commented Jun 11, 2013

Oh. Shit. I just checked. I thought chef-solo defaulted to /var/chef/cache :/

chef_provisioners = [:chef_solo, :chef_client]
compat_provisioners = provisioners.keep_if { |p| chef_provisioners.include? p.name }

if compat_provisioners.empty?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patcon I think you can shortcut this to compat_provisioners.any? ;)

@patcon
Copy link
Collaborator Author

patcon commented Jun 11, 2013

Actually, this is going to be ugly for chef_solo, since Vagrant currently uses the provisioning_path as the file_cache_path in the solo.rb template, which already has the synced_folders for the cookbooks and roles within it. vagrant-cachier's approach is to delete a non-symlink cache bucket like /tmp/vagrant-chef-1, which would mess things up since it has syned_folders within.

Seems that vagrant's chef_solo provisioner needs to start making the file_cache_path separately configurable (rather than using provisioning_path in its solo.rb template) before vagrant-cachier can work for it. Would be great if both :chef_solo and :chef_client defaulted to /var/chef/cache, otherwise caching will remain messy or will require custom config by end-user.

cc: @mitchellh Thoughts?

@patcon
Copy link
Collaborator Author

patcon commented Jun 11, 2013

My second and final commit doesn't work, by the way.

@patcon
Copy link
Collaborator Author

patcon commented Jul 4, 2013

Still blocked, but awaiting review of the above vagrant core PR that allows use to move forward.

@fgrehm
Copy link
Owner

fgrehm commented Jul 17, 2013

@patcon the Vagrant PR has been merged \o/ I'm thinking about converting some puppet manifests I've got to chef cookbooks to find out the impact of having this in place, so if I can be of any help just let me know ;)

@patcon
Copy link
Collaborator Author

patcon commented Jul 17, 2013

Working on this now, btw :)

@patcon
Copy link
Collaborator Author

patcon commented Jul 17, 2013

OK, this should work. My connection is mega-slow since I'm tethering (and chef omnibus still seems to take forever), so I've only tested on the ubuntu test box.

The java cookbook that I added to the development vagrantfile run has a big 75MB download placed in file_cache_path, and it showed up fine.

@patcon
Copy link
Collaborator Author

patcon commented Jul 17, 2013

Note, that we might need to move the lockfile (a setting in solo.rb and client.rb), which is the file that chef drops into place to prevent itself from having two processes trying to modify the system:
http://docs.opscode.com/config_rb_solo.html

By default, this is placed in file_cache_path, but this is not recommended for NF mounts, as the links explains.

No issue so far, but might rear it's head later. Will likely require that we add lockfile support to the chef_solo and chef_client provisioners in vagrant core. I'll open a new issue for later.

@fgrehm
Copy link
Owner

fgrehm commented Jul 17, 2013

@patcon AWESOME! I think I'm gonna be able to try it out before the weekend :)

@patcon
Copy link
Collaborator Author

patcon commented Jul 17, 2013

I'm also starting to doubt whether this will be useful right away.

The remote_file resource has two main actions in chef: :create and :create_if_missing:

  • Using :create_if_missing on a file stored in file_cache_path would work right away, but people don't tend to use it much because it can lead to non-idempotent situations (I believe). In fact, it would probably be bad and tough for users to debug.
  • Using :create doesn't checks the remote modification date unless you do some gymnastics:
    http://docs.opscode.com/resource_remote_file.html#examples

So this might not actually do much right away, except for the rare place where someone has used http_request magic and stored the file in file_cache_path.

What we really need is a new core chef action for remote_file that uses http_request and makes the above simpler -- something like :create_if_modified.

cc: @jtimberman @schisamo Thoughts?

@fgrehm
Copy link
Owner

fgrehm commented Jul 17, 2013

@patcon it might not be useful for everything but my idea is to use for my own stuff like this and this :)

@patcon
Copy link
Collaborator Author

patcon commented Jul 17, 2013

👍

@fgrehm fgrehm mentioned this pull request Jul 17, 2013
@fgrehm
Copy link
Owner

fgrehm commented Jul 21, 2013

@patcon I'm giving this a go right now but before I forget, we need to update the current docs and let everyone knows that this is only going to work with vagrant 1.2.4+ :)

@fgrehm
Copy link
Owner

fgrehm commented Jul 21, 2013

@patcon this is awesome man! 👍 Looking forward to the docs so we can merge this one in. Would you also be able to rebase / merge this branch against current master? tks!

patcon pushed a commit that referenced this pull request Jul 22, 2013
Adds `file_cache_path` support for Chef
@patcon patcon merged commit a5b01d2 into fgrehm:master Jul 22, 2013
@patcon
Copy link
Collaborator Author

patcon commented Jul 22, 2013

Awesome. Added some docs and merged

@patcon patcon deleted the 14-chef-file-cache-path branch July 22, 2013 16:16
@fgrehm
Copy link
Owner

fgrehm commented Jul 22, 2013

@patcon 👍

@dergachev
Copy link

@patcon 👍

1 similar comment
@mrjcleaver
Copy link

@patcon 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants