Reputation: 183
I tried creating my own MariaDB cookbook with the following recipe:
I tried replicating the steps used to Install MariaDB in Manual Installation. mariadb.repo file is created but apart from that I do not see the my.cnf or my.cnf.d file and folder getting created.
Kindly let me know what's going wrong, or where should I look into to find out to get a lead on what's going wrong?
MariaDB/recipes/default.rb:
include_recipe "yum"
arch = node['kernel']['machine']
# Fedora reports the architecture as 'x86_64'
arch = 'amd64' if arch == 'x86_64'
arch = 'x86' unless arch == 'amd64'
pversion = node['platform_version'].split('.').first
case node["platform"] #Create Yum Repository for MariaDB
when "redhat"
yum_repository "MariaDB" do
name 'mariadb'
baseurl 'http://yum.mariadb.org/5.5/rhel6-amd64'
gpgkey 'https://yum.mariadb.org/RPM-GPG-KEY-MariaDB'
gpgcheck true
action :create
end
when "centos"
yum_repository "MariaDB" do
name 'mariadb'
baseurl "http://yum.mariadb.org/#{node['mariadb']['version']}/#{node['platform']}#{pversion}-#{arch}"
gpgkey 'https://yum.mariadb.org/RPM-GPG-KEY-MariaDB'
gpgcheck true
action :create
end
end
bash 'remove postfix' do
cwd '/etc'
code <<-EOH
rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
yum remove postfix
EOH
end
bash 'install_MariaDB-server-Client' do
cwd '/etc'
code <<-EOF
/usr/bin/expect -c 'spawn yum install MariaDB-server MariaDB-client
expect "Is this ok [y/d/N]:"
send "y\n" eof'
EOF
end
bash 'install postfix' do
cwd '/etc'
code <<-EOF
/usr/bin/expect -c 'spawn yum install postfix
expect "Is this ok [y/d/N]:"
send "y\n" eof'
EOF
end
# Start mariadb service
service "mysql" do
supports :status => true, :restart => true, :start => true
action [ :start, :enable]
end
bash "mysql_secure_installation" do
user "root"
code <<-EOF
/usr/bin/expect -c 'spawn /etc/mysql_secure_installation
expect "Enter current password for root (enter for none):"
send "\r"
expect "Change root password?"
send "y\n"
expect "New password:"
send "root\n"
expect "Re-enter new password:"
send "root\n"
expect "Remove anonymous users?"
send "y\n"
expect "Disallow root login remotely?"
send "y\n"
expect "Remove test database and access to it?"
send "y\n"
expect "Reload privilege tables now?"
send "y\n" eof'
EOF
end
On executing chef-client
[2015-03-03T11:16:52+00:00] WARN:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.
To fix this issue add an entry like this to your configuration file:
```
# Verify all HTTPS connections (recommended)
ssl_verify_mode :verify_peer
# OR, Verify only connections to chef-server
verify_api_cert true
```
To check your SSL configuration, or troubleshoot errors, you can use the
knife ssl check
command like so:
knife ssl check -c /etc/chef/client.rb
Starting Chef Client, version 11.16.4
resolving cookbooks for run list: ["lgmariadb"]
Synchronizing Cookbooks:
- yum
- lgmariadb
Compiling Cookbooks...
Converging 7 resources
Recipe: yum::default
* yum_globalconfig[/etc/yum.conf] action create
* template[/etc/yum.conf] action create (up to date)
(up to date)
Recipe: lgmariadb::default
* yum_repository[mariadb] action create
* template[/etc/yum.repos.d/mariadb.repo] action create (up to date)
* execute[yum-makecache-mariadb] action nothing (skipped due to action :nothing)
* ruby_block[yum-cache-reload-mariadb] action nothing (skipped due to action :nothing)
(up to date)
* bash[remove postfix] action run
- execute "bash" "/tmp/chef-script20150303-14830-hcss75"
* bash[install_MariaDB-server-Client] action run
- execute "bash" "/tmp/chef-script20150303-14830-69e4w"
* bash[install postfix] action run
- execute "bash" "/tmp/chef-script20150303-14830-d4wjcl"
* service[mysql] action start
================================================================================
Error executing action `start` on resource 'service[mysql]'
================================================================================
Chef::Exceptions::Exec
----------------------
/bin/systemctl start mysql returned 6, expected 0
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/lgmariadb/recipes/default.rb
89: service "mysql" do
90: supports :status => true, :restart => true, :start => true
91: action [ :start, :enable]
92: end
93:
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/lgmariadb/recipes/default.rb:89:in `from_file'
service("mysql") do
provider Chef::Provider::Service::Systemd
action [:start, :enable]
supports {:status=>true, :restart=>true, :start=>true}
retries 0
retry_delay 2
guard_interpreter :default
service_name "mysql"
pattern "mysql"
cookbook_name "lgmariadb"
recipe_name "default"
end
Running handlers:
[2015-03-03T11:16:53+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-03-03T11:16:53+00:00] ERROR: Exception handlers complete
[2015-03-03T11:16:53+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 3 resources updated in 1.477241151 seconds
[2015-03-03T11:16:53+00:00] ERROR: service[mysql] (lgmariadb::default line 89) had an error: Chef::Exceptions::Exec: /bin/systemctl start mysql returned 6, expected 0
[2015-03-03T11:16:53+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Upvotes: 0
Views: 1183
Reputation: 11
If that's a CentOS 7 or RHEL7, I'm afraid that the service is now called "mariadb.service", therefore if you call:
$ sudo systemctl start mariadb.service
That shall work. Also on 'mariadb' cookbook you will need to inform a different service name:
service 'mariadb.service' do
action :nothing
end
Upvotes: 1