Skip to content

Instantly share code, notes, and snippets.

@charlesjohnson
Last active December 15, 2015 17:48
Show Gist options
  • Save charlesjohnson/5298608 to your computer and use it in GitHub Desktop.
Save charlesjohnson/5298608 to your computer and use it in GitHub Desktop.
Myface default.rb
#
# Cookbook Name:: myface
# Recipe:: default
#
# Copyright (C) 2013 Charles Johnson
#
# All rights reserved - Do Not Redistribute
#
user "myface"
include_recipe "mysql::server"
#Include the mysql Ruby bindings for Chef
include_recipe "mysql::ruby"
# Create mysql connection binding
mysql_connection_info = {:host => "localhost",
:username => 'root',
:password => node['mysql']['server_root_password']}
# Metadata dependency on the database cookbook provides
# access to the mysql_database provider.
mysql_database 'myface' do
connection mysql_connection_info
action :create
end
# Write schema seed file to filesystem
cookbook_file "/tmp/myface-init.sql" do
source "myface-init.sql"
owner "root"
group "root"
mode "0644"
end
# Seed the database with test data
execute "initialize myface database" do
command "mysql -h localhost -u root -p#{node['mysql']['server_root_password']} -D myface < /tmp/myface-init.sql"
not_if "mysql -h localhost -u root -p#{node['mysql']['server_root_password']} -D myface -e 'describe users;'"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment