chef/cookbooks/database/metadata.json
Greg Karékinian bdfb3a1afb Downgrade mysql cookbook for now
It doesn't play well with our current dev server setup
2017-06-16 22:44:57 +02:00

1 line
14 KiB
JSON

{"name":"database","version":"6.1.1","description":"provides LWRPs for common database tasks","long_description":"# Database Cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/database.svg?branch=master)](http://travis-ci.org/chef-cookbooks/database) [![Cookbook Version](http://img.shields.io/cookbook/v/database.svg)](https://supermarket.chef.io/cookbooks/database)\n\nThe main highlight of this cookbook is the `database` and `database_user` resources for managing databases and database users in a RDBMS. Providers for MySQL, PostgreSQL and SQL Server are also provided, see usage documentation below.\n\n## Requirements\n\n### Platforms\n\n- Debian / Ubuntu derivatives\n- RHEL derivatives\n- Fedora\n\n### Chef\n\n- Chef 12.1+\n\n### Cookbooks\n\n- postgresql\n\n## Resources/Providers\n\nThese resources aim to expose an abstraction layer for interacting with different RDBMS in a general way. Currently the cookbook ships with providers for MySQL, PostgreSQL and SQL Server. Please see specific usage in the **Example** sections below. The providers use specific Ruby gems installed under Chef's Ruby environment to execute commands and carry out actions. These gems will need to be installed before the providers can operate correctly. Specific notes for each RDBS flavor:\n\n- MySQL: leverages the `mysql2` gem, which can be installed with the `mysql2_chef_gem` resource prior to use (available on the Supermarket). You must depend on the `mysql2_chef_gem` cookbook, then use a `mysql2_chef_gem` resource to install it. The resource allows the user to select MySQL client library versions, as well as optionally select MariaDB libraries.\n\n- PostgreSQL: leverages the `pg` gem which is installed as part of the `postgresql::ruby` recipe. You must declare `include_recipe \"database::postgresql\"` to include this.\n\n- SQL Server: leverages the `tiny_tds` gem which is installed as part of the `sql_server::client` recipe.\n\n- SQLite: leverages the `sqlite3` gem which is installed as part of the `database::sqlite` recipe. You must declare `include_recipe \"database::sqlite\"` to include this.\n\n### database\n\nManage databases in a RDBMS. Use the proper shortcut resource depending on your RDBMS: `mysql_database`, `postgresql_database`, `sql_server_database` or `sqlite_database`.\n\n#### Actions\n\n- `:create`: create a named database\n- `:drop`: drop a named database\n- `:query`: execute an arbitrary query against a named database\n\n#### Attribute Parameters\n\n- database_name: name attribute. Name of the database to interact with\n- connection: hash of connection info. valid keys include `:host`, `:port`, `:username`, and `:password`\n\n - only for MySQL DB*:\n\n - `:flags` (see `Mysql2::Client@@default_query_options[:connect_flags]`)\n - `:default_file`, `:default_group` (see <https://github.com/brianmario/mysql2#reading-a-mysql-config-file>)\n\n - only for PostgreSQL: `:database` (overwrites parameter `database_name`)\n\n - not used for SQLlite\n\n- sql: string of sql or a block that executes to a string of sql, which will be executed against the database. used by `:query` action only\n\n- The database cookbook uses the `mysql2` gem.\n\n> \"The value of host may be either a host name or an IP address. If host is NULL or the string \"127.0.0.1\", a connection to the local host is assumed. For Windows, the client connects using a shared-memory connection, if the server has shared-memory connections enabled. Otherwise, TCP/IP is used. For a host value of \".\" on Windows, the client connects using a named pipe, if the server has named-pipe connections enabled. If named-pipe connections are not enabled, an error occurs.\"\n\nIf you specify a `:socket` key and are using the mysql_service resource to set up the MySQL service, you'll need to specify the path in the form `/var/run/mysql-<instance name>/mysqld.sock`.\n\n#### Providers\n\n- `Chef::Provider::Database::Mysql`: shortcut resource `mysql_database`\n- `Chef::Provider::Database::Postgresql`: shortcut resource `postgresql_database`\n- `Chef::Provider::Database::SqlServer`: shortcut resource `sql_server_database`\n- `Chef::Provider::Database::Sqlite`: shortcut resource `sqlite_database`\n\n#### Examples\n\n```ruby\n# Create a mysql database\nmysql_database 'wordpress-cust01' do\n connection(\n :host => '127.0.0.1',\n :username => 'root',\n :password => node['wordpress-cust01']['mysql']['initial_root_password']\n )\n action :create\nend\n```\n\n```ruby\n# Create a mysql database on a named mysql instance\nmysql_database 'oracle_rools' do\n connection(\n :host => '127.0.0.1',\n :username => 'root',\n :socket => \"/var/run/mysql-#{instance-name}/mysqld.sock\"\n :password => node['mysql']['server_root_password']\n )\n action :create\nend\n```\n\n```ruby\n# Create a sql server database\nsql_server_database 'mr_softie' do\n connection(\n :host => '127.0.0.1',\n :port => node['sql_server']['port'],\n :username => 'sa',\n :password => node['sql_server']['server_sa_password'],\n :options => { 'ANSI_NULLS' => 'ON', 'QUOTED_IDENTIFIER' => 'OFF' }\n )\n action :create\nend\n```\n\n```ruby\n# create a postgresql database\npostgresql_database 'mr_softie' do\n connection(\n :host => '127.0.0.1',\n :port => 5432,\n :username => 'postgres',\n :password => node['postgresql']['password']['postgres']\n )\n action :create\nend\n```\n\n```ruby\n# create a postgresql database with additional parameters\npostgresql_database 'mr_softie' do\n connection(\n :host => '127.0.0.1',\n :port => 5432,\n :username => 'postgres',\n :password => node['postgresql']['password']['postgres']\n )\n template 'DEFAULT'\n encoding 'DEFAULT'\n tablespace 'DEFAULT'\n connection_limit '-1'\n owner 'postgres'\n action :create\nend\n```\n\n```ruby\n# Externalize conection info in a ruby hash\nmysql_connection_info = {\n :host => '127.0.0.1',\n :username => 'root',\n :password => node['mysql']['server_root_password']\n}\n\nsql_server_connection_info = {\n :host => '127.0.0.1',\n :port => node['sql_server']['port'],\n :username => 'sa',\n :password => node['sql_server']['server_sa_password']\n}\n\npostgresql_connection_info = {\n :host => '127.0.0.1',\n :port => node['postgresql']['config']['port'],\n :username => 'postgres',\n :password => node['postgresql']['password']['postgres']\n}\n\n# Same create commands, connection info as an external hash\nmysql_database 'foo' do\n connection mysql_connection_info\n action :create\nend\n\nsql_server_database 'foo' do\n connection sql_server_connection_info\n action :create\nend\n\npostgresql_database 'foo' do\n connection postgresql_connection_info\n action :create\nend\n\n# Create database, set provider in resource parameter\ndatabase 'bar' do\n connection mysql_connection_info\n provider Chef::Provider::Database::Mysql\n action :create\nend\n\ndatabase 'bar' do\n connection sql_server_connection_info\n provider Chef::Provider::Database::SqlServer\n action :create\nend\n\ndatabase 'bar' do\n connection postgresql_connection_info\n provider Chef::Provider::Database::Postgresql\n action :create\nend\n\n\n\n# Drop a database\nmysql_database 'baz' do\n connection mysql_connection_info\n action :drop\nend\n\n\n\n# Query a database\nmysql_database 'flush the privileges' do\n connection mysql_connection_info\n sql 'flush privileges'\n action :query\nend\n\n\n# Query a database from a sql script on disk\nmysql_database 'run script' do\n connection mysql_connection_info\n sql { ::File.open('/path/to/sql_script.sql').read }\n action :query\nend\n\n\n\n# Vacuum a postgres database\npostgresql_database 'vacuum databases' do\n connection postgresql_connection_info\n database_name 'template1'\n sql 'VACUUM FULL VERBOSE ANALYZE'\n action :query\nend\n```\n\n```ruby\n# Create, Insert, Query a SQLite database\n# Note that inserting anything in to the database will create it automaticly.\nsqlite_database 'mr_softie' do\n database_name '/path/to/database.db3'\n sql \"sql command\"\n action :query\nend\n\n# Delete the database, will remove the file\nsqlite_database 'mr_softie' do\n database_name '/path/to/database.db3'\n action :drop\nend\n```\n\n### database_user\n\nManage users and user privileges in a RDBMS. Use the proper shortcut resource depending on your RDBMS: `mysql_database_user`, `postgresql_database_user`, or `sql_server_database_user`.\n\n#### Actions\n\n- `:create`: create a user\n- `:drop`: drop a user\n- `:grant`: manipulate user privileges on database objects\n\n#### Attribute Parameters\n\n- username: name attribute. Name of the database user\n- password: password for the user account\n- database_name: Name of the database to interact with\n- connection: hash of connection info. valid keys include :host, :port, :username, :password\n- privileges: array of database privileges to grant user. used by the :grant action. default is :all\n- host: host where user connections are allowed from. used by MySQL provider only. default is '127.0.0.1'\n- table: table to grant privileges on. used by :grant action and MySQL provider only. default is '*' (all tables)\n- require_ssl: true or false to force SSL connections to be used for user\n- require_x509: true or false to force SSL with client certificate verification\n\n#### Providers\n\n- `Chef::Provider::Database::MysqlUser`: shortcut resource `mysql_database_user`\n- `Chef::Provider::Database::PostgresqlUser`: shortcut resource `postgresql_database_user`\n- `Chef::Provider::Database::SqlServerUser`: shortcut resource`sql_server_database_user`\n\n#### Examples\n\n```ruby\n# create connection info as an external ruby hash\nmysql_connection_info = {\n :host => '127.0.0.1',\n :username => 'root',\n :password => node['mysql']['server_root_password']\n}\n\npostgresql_connection_info = {\n :host => '127.0.0.1',\n :port => node['postgresql']['config']['port'],\n :username => 'postgres',\n :password => node['postgresql']['password']['postgres']\n}\n\nsql_server_connection_info = {\n :host => '127.0.0.1',\n :port => node['sql_server']['port'],\n :username => 'sa',\n :password => node['sql_server']['server_sa_password']\n}\n\n# Create a mysql user but grant no privileges\nmysql_database_user 'disenfranchised' do\n connection mysql_connection_info\n password 'super_secret'\n action :create\nend\n\n# Do the same but pass the provider to the database resource\ndatabase_user 'disenfranchised' do\n connection mysql_connection_info\n password 'super_secret'\n provider Chef::Provider::Database::MysqlUser\n action :create\nend\n\n# Create a postgresql user but grant no privileges\npostgresql_database_user 'disenfranchised' do\n connection postgresql_connection_info\n password 'super_secret'\n action :create\nend\n\n# The same as above but utilizing hashed password string instead of\n# plain text one\npostgresql_database_user 'disenfranchised' do\n connection postgresql_connection_info\n password hashed_password('md5eacdbf8d9847a76978bd515fae200a2a')\n action :grant\nend\n\n# Do the same but pass the provider to the database resource\ndatabase_user 'disenfranchised' do\n connection postgresql_connection_info\n password 'super_secret'\n provider Chef::Provider::Database::PostgresqlUser\n action :create\nend\n\n# Create a sql server user but grant no privileges\nsql_server_database_user 'disenfranchised' do\n connection sql_server_connection_info\n password 'super_secret'\n action :create\nend\n\n# Drop a mysql user\nmysql_database_user 'foo_user' do\n connection mysql_connection_info\n action :drop\nend\n\n# Bulk drop sql server users\n%w(disenfranchised foo_user).each do |user|\n sql_server_database_user user do\n connection sql_server_connection_info\n action :drop\n end\nend\n\n# Grant SELECT, UPDATE, and INSERT privileges to all tables in foo db from all hosts\nmysql_database_user 'foo_user' do\n connection mysql_connection_info\n password 'super_secret'\n database_name 'foo'\n host '%'\n privileges [:select,:update,:insert]\n action :grant\nend\n\n# The same as above but utilizing hashed password string instead of\n# plain text one\nmysql_database_user 'foo_user' do\n connection mysql_connection_info\n password hashed_password('*664E8D709A6EBADFC68361EBE82CF77F10211E52')\n database_name 'foo'\n host '%'\n privileges [:select,:update,:insert]\n action :grant\nend\n\n# Grant all privileges on all databases/tables from 127.0.0.1\nmysql_database_user 'super_user' do\n connection mysql_connection_info\n password 'super_secret'\n action :grant\nend\n\n# grant all privileges on all tables, sequences and functions in public schema of foo db\npostgresql_database_user 'foo_user' do\n connection postgresql_connection_info\n database_name 'foo'\n schema_name 'public'\n tables [:all]\n sequences [:all]\n functions [:all]\n privileges [:all]\n action [:grant, :grant_schema, :grant_table, :grant_sequence, :grant_function]\nend\n\n# grant select,update,insert privileges to all tables in foo db\nsql_server_database_user 'foo_user' do\n connection sql_server_connection_info\n password 'super_secret'\n database_name 'foo'\n privileges [:select,:update,:insert]\n action :grant\nend\n```\n\n## License & Authors\n\n**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))\n\n**Copyright:** 2009-2016, Chef Software, Inc.\n\n```\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","freebsd":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","suse":">= 0.0.0","ubuntu":">= 0.0.0"},"dependencies":{"postgresql":">= 1.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}}