sous-chefs / mysql

Development repository for the mysql cookbook
https://supermarket.chef.io/cookbooks/mysql
Apache License 2.0
338 stars 690 forks source link

Create service managment files without starting the instance #511

Closed vpal closed 4 years ago

vpal commented 7 years ago

Cookbook version

8.2.0

Chef-client version

12.18.31

Platform Details

Ubuntu 16.04

Scenario:

Create service management scripts without starting and enabling the service.

Steps to Reproduce:

Simple service like this does not seem to create service management files:

mysql_service 'default' do
  port '3306'
  version node['mysql']['version']
  initial_root_password root_password
  action :create
end

Expected Result:

The create action should create all the service management files without enabling and starting the service.

Actual Result:

Create action does not create service service management files and it seems there are no other actions according to the documentation that can do this.

iennae commented 7 years ago

As described in the README, the current pattern for mysql_service:

The mysql_service resource manages the basic plumbing needed to get a MySQL server instance running with minimal configuration.

The :create action handles package installation, support directories, socket files, and other operating system level concerns. The internal configuration file contains just enough to get the service up and running, then loads extra configuration from a conf.d directory. Further configurations are managed with the mysql_config resource.

If the data_dir is empty, a database will be initialized, and a root user will be set up with initial_root_password. If this directory already contains database files, no action will be taken.

When you are asking about service management scripts, what are you specifically looking for?

vpal commented 7 years ago

Hi iennae, I'm looking for the service management scripts under /etc/systemd/system or /etc/init.d. In some situation (for example block device encryption) you don't want to actually start MySQL on system startup or get it started by Chef, but rather do it manually after underlying disks are set up (manually), but those scripts are still needed to do this. It would be nice if the create action would create those and then managing those with the "standard" service resource or starting the service manually would also be possible.

The internal configuration file contains just enough to get the service up and running,

If I'm not mistaken this is not correct as you can't get the service up and running in a proper way as the mentioned script(s) are not created by the create action, you have to also list the start action to get those placed into the filesystem.

cheeseplus commented 7 years ago

While adding an option to make this possible, it might be easier to simply write your own recipe for laying down the files in question as templates. This could also have custom crafted logic to prevent it from ever starting the service should a condition be present (i.e. using a not_if guard) that uses some output from the manual processes mentioned.

Not that the cookbook might not be able to be bent in this way but it's definitely not geared toward this as such which is why writing something yourself might be best given the constraints and ability to reason about interactions.

github-actions[bot] commented 4 years ago

Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.

ramereth commented 4 years ago

I think this is outside of the scope of this cookbook.