We're looking to deploy a few Laravel4 based PHP apps on amazon with OpsWorks, this requires a few things:
php composer.phar install
I'm completely fresh with it comes to chef, so initially looking for a place to get to grips with the basics of chef, and then how to achieve the tasks above, would appreciate any pointers.
I'm no Chef guru (I usually use Puppet) but try the following:
You may want to execute a wget command (see examples below).
If you want something more sophisticated see http://docs.opscode.com/resource_deploy.html
deploy_revision "/path/to/application" do
repo 'ssh://name-of-git-repo/repos/repo.git'
migrate false
purge_before_symlink %w{one two folder/three}
create_dirs_before_symlink []
symlinks(
"one" => "one",
"two" => "two",
"three" => "folder/three"
)
before_restart do
# some Ruby code
end
notifies :restart, "service[foo]"
notifies :restart, "service[bar]"
end
I would execute a wget.
I lifted some code from here: http://cookingclouds.com/2012/06/23/chef-simple-cookbook-example/
It's basically just doing a wget in a specific folder, extracting the contents of the tar & updating some permissions on the new files. It only does this if the folder doesn't already exist.
# Run a bash shell - download and extract composer
bash "install_composer" do
user "root"
cwd "/folder/to/extact/to"
code <<-EOH
wget http://getcomposer.com/composer.tar.gz
tar -xzf composer.tar.gz
chown -R user:group /folder/to/extact/to
EOH
not_if "test -d /folder/to/extact/to"
end
http://docs.opscode.com/resource_execute.html
execute "composer install" do
command "php composer.phar install && touch /var/log/.php_composer_installed"
creates "/var/log/.php_composer_installed"
action :run
end
This will only run it once, otherwise you can remove the "creates" and it will run it each time.
http://docs.opscode.com/resource.html
directory "/tmp/folder" do
owner "root"
group "root"
mode 0755
action :create
end
If the directory already exists, nothing will happen. If the directory was changed in any way, the resource is marked as updated.
I find the search handy, browsing stuff on the Chef site seems to be hopeless (too much stuff to dig through). http://docs.opscode.com/search.html
I would go pretty much with Drew Khoury's answer, with one change. To download compose.phar, you can use the remote_file resource instead of doing a wget in a bash script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With