I’ve tried this a couple different ways, including creating a new recipe and notifying that recipe to run but I keep getting the same problem which is the cloned repo directory doesn’t exist before the file resource runs, so I get a fatal error.
my question is, can I make the git clone finish before the file resource tries to execute or is there a better way to do this?
SN: what I’m trying to accomplish deals w/ new user environment setup – so after creating a new user i’m cloning down a bunch of config files from a git repo that will be deployed for that user.
git "/home/#{user_id}/.myconfigs" do
repository "https://url/to/repo"
reference "master"
user user_id
group user_id
action :checkout
not_if "test -d /home/#{user_id}/.myconfigs"
#notifies :run, "recipe[zsh_workstation::zshrc]"
end
file "/home/#{user_id}/.zshrc" do
content IO.read("/home/#{user_id}/.myconfigs/.zshrc")
owner user_id
group user_id
mode "0600"
action :create_if_missing
end
Check Anatomy of a Chef Run
At the moment chef compiles your file resource, git resource is not run (even is not started) yet, so file “/home/#{user_id}/.myconfigs/.zshrc” does not exist.
Possible workarounds:
This will copy the file after it is created by git using FileUtils.
Symlink instead of copy.
Run git resource at compile stage.