Carried on from CHEF configure MySQL on AWS EC2 Ubuntu

We want to setup each new WordPress build with the latest version so we’ll fetch it from WordPress.org. But how? Fortunately enough, Chef comes with the resource remote_file which will do just that for us.

cd cookbooks/phpapp

vi recipes/default.rb # and add the following lines

wordpress_latest = Chef::Config[:file_cache_path] + “/wordpress-latest.tar.gz”

remote_file wordpress_latest do

source “http://wordpress.org/latest.tar.gz”

mode “0644”

end

directory node[“phpapp”][“path”] do

owner “root”

group “root”

mode “0755”

action :create

recursive true

end

execute “untar-wordpress” do

cwd node[‘phpapp’][‘path’]

command “tar –strip-components 1 -xzf ” + wordpress_latest

creates node[‘phpapp’][‘path’] + “/wp-settings.php”

 

end

vi attributes/default.rb # and add the following
default[“phpapp”][“path”] = “/var/www/phpapp”

cd ../..
chef-solo -c solo.rb -j web.json