chr4-cookbooks / mysqld

chef cookbook for installing and configuring mysql, only changing explicitly given options from the systems defaults
4 stars 11 forks source link

Required argument password is missing #1

Closed 501st-alpha1 closed 9 years ago

501st-alpha1 commented 9 years ago

I'm trying to use this cookbook with Vagrant, but I can't get it to allow the MySQL user root to have no password. I added cookbook "mysqld" to my Cheffile, and the following to my Vagrantfile:

config.vm.provision "chef_solo" do |chef|
    chef.add_recipe "mysqld"
end

But when I do vagrant up, the Chef configuration fails. Here is the relevant output:

==> default: ================================================================================
==> default: Recipe Compile Error in /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/default.rb
==> default: ================================================================================
==> default: 
==> default: 
==> default: Chef::Exceptions::ValidationFailed
==> default: ----------------------------------
==> default: Required argument password is missing!
==> default: 
==> default: 
==> default: Cookbook Trace:
==> default: ---------------
==> default:   /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/configure.rb:26:in `block in from_file'
==> default: 
==> default:   /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/configure.rb:25:in `from_file'
==> default: 
==> default:   /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/default.rb:22:in `from_file'
==> default: 
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/recipes/configure.rb:
==> default: 
==> default:  19:  #
==> default:  20:  
==> default:  21:  # Configure mysql/mariadb according to attributes
==> default:  22:  mysqld 'default'
==> default:  23:  
==> default:  24:  # Set password according to attribute, if set
==> default:  25:  mysqld_password 'root' do
==> default:  26>>   password node['mysqld']['root_password']
==> default:  27:    only_if { node['mysqld']['root_password'] }
==> default:  28:  end
==> default:  29:  
==> default:  30:  # Set debian-sys-maint password on Debian family
==> default:  31:  mysqld_password 'debian-sys-maint' do
==> default:  32:    password node['mysqld']['root_password']
==> default:  33:    only_if { node['mysqld']['root_password'] && node['platform_family'] == 'debian' }
==> default:  34:  end
==> default:  35:  
==> default: 
==> default: [2015-03-26T21:29:12+00:00] ERROR: Running exception handlers
==> default: [2015-03-26T21:29:12+00:00] ERROR: Exception handlers complete
==> default: [2015-03-26T21:29:12+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-03-26T21:29:12+00:00] ERROR: Required argument password is missing!

The documentation mentions that the root password will be set if given, so I don't see why the argument is required.

Any thoughts?

501st-alpha1 commented 9 years ago

I also tried setting the root password to an empty string, by modifying my Vagrantfile as follows:

config.vm.provision "chef_solo" do |chef|
  chef.add_recipe "mysqld"
  chef.json = {
    "mysqld" => {
      "root_password" => ""
    }
  }
end

But when I did that, it errored on trying to restart mysql:

==> default: ================================================================================
==> default: Error executing action `restart` on resource 'service[mysql]'
==> default: ================================================================================
==> default: 
==> default: 
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default: ------------------------------------
==> default: Expected process to exit with [0], but received '1'
==> default: 
==> default: ---- Begin output of /etc/init.d/mysql stop ----
==> default: 
==> default: STDOUT: Stopping MySQL database server: mysqld failed!
==> default: 
==> default: STDERR: 
==> default: 
==> default: ---- End output of /etc/init.d/mysql stop ----
==> default: 
==> default: Ran /etc/init.d/mysql stop returned 1
==> default: 
==> default: 
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/providers/default.rb
==> default: 
==> default: 
==> default: 
==> default:  48:   service new_resource.service_name do
==> default: 
==> default:  49:     # Use --wsrep-new-cluster if this is an initial galera startup
==> default: 
==> default:  50:     if new_resource.galera_init
==> default: 
==> default:  51:       start_command "service #{new_resource.service_name} start --wsrep-new-cluster --wsrep_cluster_address=gcomm://"
==> default: 
==> default:  52:     end
==> default: 
==> default:  53: 
==> default: 
==> default: 
==> default: 
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/providers/default.rb:48:in `block in class_from_file'
==> default: 
==> default: service("mysql") do
==> default:   action [:enable, :start]
==> default:   supports {:restart=>false, :reload=>false, :status=>false}
==> default:   retries 0
==> default:   retry_delay 2
==> default:   default_guard_interpreter :default
==> default:   service_name "mysql"
==> default:   enabled true
==> default:   running true
==> default:   pattern "mysql"
==> default:   declared_type :service
==> default:   cookbook_name :mysqld
==> default:   not_if { #code block }
==> default: end
==> default: 
==> default: [2015-03-26T21:44:16+00:00] ERROR: Running exception handlers
==> default: [2015-03-26T21:44:16+00:00] ERROR: Exception handlers complete
==> default: [2015-03-26T21:44:16+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-03-26T21:44:16+00:00] ERROR: service[mysql] (/tmp/vagrant-chef/82891d35d286774d89cfbe3b7a9ea9d4/cookbooks/mysqld/providers/default.rb line 48) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> default: ---- Begin output of /etc/init.d/mysql stop ----
==> default: STDOUT: Stopping MySQL database server: mysqld failed!
==> default: STDERR: 
==> default: ---- End output of /etc/init.d/mysql stop ----
==> default: Ran /etc/init.d/mysql stop returned 1

I also couldn't manage to login to MySQL after that, with or without a password.

chr4 commented 9 years ago

Closing in favor of the pull request.