hapi-fhir/vagrant/chef/cookbooks/mysql/libraries/provider_mysql_service_smar...

209 lines
6.1 KiB
Ruby
Raw Normal View History

2014-10-06 21:47:56 -04:00
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_smartos'
class Chef
class Provider
class MysqlService
class Smartos < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::SmartOS
action :create do
package new_resource.parsed_package_name do
version new_resource.parsed_version
action :install
end
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
# data_dir
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data/mysql" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data/test" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
Multiple improvements (#2997) * Add failing test * Tidy test for new tokenparam style * Add removeByQualifier to SearchParameterMap * Add new property binder for search terms * Member move, add test for new parser * whoops missed an add * Passing test. Introduced SearchParamTextWrapper to give a type for the binder. Enhance FulltextSearchSvcImpl to understand TokenParams as well as StringParams. * Add more to test, change analyzer for template * Optimize imports * Minor refactoring * added eq and gt test cases * added missing gt search param tests * Search all CodeableConcepts * Extract new LuceneRuntimeSearchParam to mediate indexing and searching. * Fix up broken test with mock * Add support for identifier type * Bump for special maven package * fix-me to todo * Prevent version check * FIx version for test * DSTU2 does not support fluent path * Don't accidentally strip SPs in DSTU2 * added lt tests * Add some high-bound test cases * More test cases and new compressed format * More test cases * More test cases * Re-order columns for easier reading * Comments * Cleanup and comments * Make support :text for all token SPs * Make support :text for all token SPs * Fixed incomplete date issue * Set to the last millisecond 23:59:59.999 * Disabled 4 failed JVM/TZ related test cases * add test for failing batch bug, remove bounding on queue * remove parallelism from non-get batch operations * Fix count for test * New index layout * Notes and cleanup * Notes and cleanup * remove the jetbrains * Demote FIXME to WIP * Change :text search to be lucene simple search and use standardAnalyzer. * Change :text to require * for prefix match. * add prefix negative test * Bump version * Added changelog * Add more search parameters to lucene indexing (#3000) * dirty the branch * Add oversight to changelog * Start using jpa indexing for es * Correct negative search test * Update templates, index tokens, write new test. TODO gotta modify SB * Add test for code token search * add comment * Flesh out token search * minor cleanup and comments * Extract index handling from FulltextSearchSvcImpl * D'oh. Actually use elastic to search. * Move supported query check closer to query builder * String search test before activating lucene * Add string:exact to hibernate search. * Add string:contains search * cleanup * demote fixmes to allow build to run. * Add unmodified string search. * empty stubs for quantity and reference * Ignore magic search params in lucene index * Support full-text on all FHIR releases * Include reference lookups in ES * Fix and/or logic in _text * Test for string with space * Cherry-pick the NoFT fix * Disable advanced indexing in a bunch of tests of emitted sql. * Stub changelog * Fix :missing flag * Move DaoConfig up to BaseJpaTest to share teardown * Disable new indexing for partition test * Add a different analyzer and field for default string search vs text * checkstyle for a pre-build * Index full prefix for string search when using Lucene * Update hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/3000-Extend-lucene-indexing.yaml Co-authored-by: Tadgh <tadgh@cs.toronto.edu> * Update hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HibernateSearchQueryBuilder.java Co-authored-by: Tadgh <tadgh@cs.toronto.edu> * Review feedback. Co-authored-by: Tadgh <garygrantgraham@gmail.com> Co-authored-by: Tadgh <tadgh@cs.toronto.edu> * Remove double-check * Version bump * Fix typo Co-authored-by: Michael Buckley <michael.buckley@smilecdr.com> Co-authored-by: Long Ma <longma@Longs-MacBook-Pro.local> Co-authored-by: Frank Tao <frankjtao@gmail.com> Co-authored-by: michaelabuckley <michaelabuckley@gmail.com>
2021-10-28 15:13:16 -04:00
# TODO: support user supplied template
2014-10-06 21:47:56 -04:00
template "#{prefix_dir}/etc/my.cnf" do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file,
:socket_file => socket_file,
:port => new_resource.parsed_port,
:include_dir => include_dir
)
action :create
notifies :run, 'bash[move mysql data to datadir]', :immediately
notifies :restart, 'service[mysql]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
/usr/sbin/svcadm disable mysql \
&& mv /opt/local/lib/mysql/* #{new_resource.parsed_data_dir}
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'initialize mysql database' do
cwd new_resource.parsed_data_dir
command "#{prefix_dir}/bin/mysql_install_db --datadir=#{new_resource.parsed_data_dir} --user=mysql"
creates "#{new_resource.parsed_data_dir}/mysql/user.frm"
end
template '/opt/local/lib/svc/method/mysqld' do
cookbook 'mysql'
source 'smartos/svc.method.mysqld.erb'
owner 'root'
group 'root'
mode '0555'
variables(
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file
)
action :create
end
template '/tmp/mysql.xml' do
cookbook 'mysql'
source 'smartos/mysql.xml.erb'
owner 'root'
group 'root'
mode '0644'
variables(:version => new_resource.parsed_version)
action :create
notifies :run, 'execute[import mysql manifest]', :immediately
end
execute 'import mysql manifest' do
command 'svccfg import /tmp/mysql.xml'
action :nothing
end
service 'mysql' do
supports :reload => true
action [:start, :enable]
end
execute 'wait for mysql' do
command "until [ -S #{socket_file} ] ; do sleep 1 ; done"
timeout 10
action :run
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
template "#{prefix_dir}/etc/mysql_grants.sql" do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]', :immediately
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < #{prefix_dir}/etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << " > #{prefix_dir}/etc/.mysql_root"
cmd << " ;/bin/chmod 0600 #{prefix_dir}/etc/.mysql_root"
command cmd
action :nothing
end
end
action :restart do
service 'mysql' do
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
supports :reload => true
action :reload
end
end
end
end
end
end