Actually try to write wirst cookbook with chef-solo and I am look up to cookbook wordpress to initialize my own site.
But for few hours I couldn't find solution for this bug:
No resource or method named `template' for `Chef::Recipe "create_configs"'
On fragment:
template "#{project_config_dir}/database.php" do
source "database.php.erb"
mode 0440
owner "root"
group node['apache']['group']
variables(
'dev' => {
'type' => app_db_config['type'],
'hostname' => app_db_config['hostname'],
'port' => app_db_config['port'],
'username' => app_db_config['user'],
'password' => app_db_config['password'],
'database' => app_db_config['dababase'],
}
)
action :create
end
with Vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :private_network, ip: "192.168.33.11", :bridge => 'en1: Wi-Fi (AirPort)'
config.vm.synced_folder "/Users/Tom/Documents/vagrant/destination_server/public", "/home/vagrant/public"
config.vm.provider :virtualbox do |vb|
# Don't boot with headless mode
vb.gui = false
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
end
config.vm.provision :shell, :inline => "/etc/init.d/networking restart"
config.vm.provision :shell, :inline => "sudo apt-get update -y"
config.vm.provision :shell, :inline => "sudo apt-get install ruby1.9.3 -y"
config.vm.provision :shell, :inline => "sudo apt-get install rubygems -y"
config.vm.provision :shell, :inline => "cd /home/vagrant && sudo ./postinstall.sh"
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "apt"
chef.add_recipe "bazaar"
chef.json = {
"mysql" => {
"server_debian_password" => "root",
"server_root_password" => "root",
"server_repl_password" => "root"
},
"run_list" =>["recipe[mysql::server]"]
}
chef.add_recipe "site"
end
end
Funny think is that resource "directory" working fine, but the same problem I have with use "execute".
Used cookbook wordpress and added all needed cookbooks and workend fine with this two resources.
I have version 11.10 of chef. Using Vagrant to create VirtualMachine
Any idea? Need help/clue what to do :/