Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:create on mariadb_server_install restarts service on every chef-client run #265

Closed
sfiggins opened this issue Jun 28, 2019 · 3 comments · Fixed by #277
Closed

:create on mariadb_server_install restarts service on every chef-client run #265

sfiggins opened this issue Jun 28, 2019 · 3 comments · Fixed by #277

Comments

@sfiggins
Copy link

sfiggins commented Jun 28, 2019

Cookbook version

2.1.0

Chef-client version

14.11.21

Platform Details

centos vagrant in test-kitchent

Scenario:

Adding mariadb_server_install resource with :create as an action causes the mariadb service to stop and reset the root password whenever chef-client is run, regardless of whether the root password needs to be changed or not.

Steps to Reproduce:

Use [:install, :create] as the actions for a mariadb_server_install

Expected Result:

When nothing has been changed, the mysql server is not be restarted

Actual Result:

The mysql service is stopped, the password reconfigured, then mysql is restarted on every chef-client run.

@sfiggins
Copy link
Author

Pretty sure the server is stopped because of these lines in the server_install resource for the create action:

log 'Enable and start MariaDB service' do
    notifies :enable, "service[#{platform_service_name}]", :immediately
    notifies :stop, "service[#{platform_service_name}]", :immediately
    notifies :run, 'execute[apply-mariadb-root-password]', :immediately
end

@sfiggins
Copy link
Author

A workaround I might try is to not include :create as an action, and instead write something to test if create needs to be run, then signal server_install resource, but my general expectation is that my database won't get restarted unless there is some need for a restart.

@sfiggins
Copy link
Author

sfiggins commented Jul 1, 2019

If anyone else is struggling with this, my initial fix is to put a not_if on the resource checking for the recovery.conf file.

mariadb_server_install 'package' do
  version '10.3'
  setup_repo false
  action [:install, :create]
  password ''
  not_if { ::File.exist?('/var/lib/mysql/recovery.conf') }
end

Your data directory may differ.

ccrebolder added a commit to ccrebolder/mariadb that referenced this issue Oct 18, 2019
The server_configuration resource would call a ruby_block on every run,
using internal logic for idempotency instead of resource guards.

The server_install resource's create action would stop the server to
reset the root password every chef run.

Fixes sous-chefs#265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant