简体   繁体   中英

unable to override mysql database using mysql chef coookbook

I am newbie to the chef and its overall eco system, just has an experiment I trying to use mysql cookbook and trying to create a database and set username and password of the same. I am not able to figure out how to get this things done. I have set up my own chef-server on aws ec2 ubuntu instance. Kindly help me out.

Checkout the mysql_test cookbook. where it uses resource mysql_database_user provided from the database cookbook.

Here's the code sample:

include_recipe 'mysql::server'

mysql_connection = {:host => "localhost", :username => 'root',
                :password => node['mysql']['server_root_password']}

mysql_database node['mysql_test']['database'] do
  connection mysql_connection
  action :create
end

mysql_database_user node['mysql_test']['username'] do
  connection mysql_connection
  password node['mysql_test']['password']
  database_name node['mysql_test']['database']
  host 'localhost'
  privileges [:select,:update,:insert, :delete]
  action [:create, :grant]
end

Notice that you need to depend on the database cookbook and the mysql cookbook, and set the following node attributes:

  • default['mysql_test']['database'] - mysql database name
  • default['mysql_test']['username'] - mysql database user name
  • default['mysql_test']['password'] - mysql database user password

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM