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

Access to attribute in "templates/default/my.cnf.erb" #281

Closed
JAG-01 opened this issue Jan 16, 2015 · 8 comments
Closed

Access to attribute in "templates/default/my.cnf.erb" #281

JAG-01 opened this issue Jan 16, 2015 · 8 comments
Assignees

Comments

@JAG-01
Copy link

JAG-01 commented Jan 16, 2015

Feature request to provide access to attributes found in "templates/default/my.cnf.erb" such as "pid-file", "log-error" and "socket".

# Chef generated my.cnf for instance mysql-myappname

[client]
default-character-set          = utf8
port                           = 3306
socket                         = /run/mysql-myappname/mysqld.sock

[mysql]
default-character-set          = utf8

[mysqld]
user                           = mysql
pid-file                       = /run/mysql-myappname/mysqld.pid
socket                         = /run/mysql-myappname/mysqld.sock
port                           = 3306
datadir                        = /var/lib/mysql-myappname
tmpdir                         = /tmp
log-error                      = /var/log/mysql-myappname/error.log
!includedir /etc/mysql-myappname/conf.d

[mysqld_safe]
socket                         = /run/mysql-myappname/mysqld.sock

*This issue created as requested in issue #280.

@flatrocks
Copy link

Yep... with the v6 mysql cookbook, it's virtually impossible to set up proper client connections from other apps without knowing the (non-standard) socket, for example.

@someara
Copy link
Contributor

someara commented Jan 30, 2015

I just added a quick patch to make the socket configurable.

I'll add the rest of them in 6.1

9ef63c6

Released as 6.0.12

On Fri, Jan 30, 2015 at 8:23 AM, Tom Wilson notifications@github.com
wrote:

Yep... with the v6 mysql cookbook, it's virtually impossible to set up
proper client connections from other apps without knowing the
(non-standard) socket, for example.


Reply to this email directly or view it on GitHub
#281 (comment)
.

@someara someara self-assigned this Feb 6, 2015
@idwright
Copy link

Can you please make sure you include tmpdir and include the apparmor configuration
Thanks.

@geleman
Copy link

geleman commented Jun 19, 2015

I agree with all these changes. We should be able to chose the data_dir, error_log, tmpdir, socket, and pid file. tmpdir in particular because it should be placed in memory and not on disk, which is what hard coding it to /tmp is doing. We should also be able to determine the location of the my.cnf file.

@flatrocks
Copy link

The things you might reasonably want to do in my.cnf could be endless. One solution would be to change the hard coded cookbook attribute for my.cnf template in mysql/libraries/provider_mysql_service.rb:

        # Main configuration file
        template "#{new_resource.name} :create #{etc_dir}/my.cnf" do
          ...
          cookbook 'mysql'
          ...
            )
          action :create
        end

to something schematically like:

        # Main configuration file
        template "#{new_resource.name} :create #{etc_dir}/my.cnf" do
          ...
          cookbook new_resource.mycnf_template_cookbook if new_resource.mycnf_template_cookbook
          ...
            )
          action :create
        end

Default cookbook would still be mysql but alternatively, you could use a custom template in a wrapper. That would avoid complicating things for most applications, while providing ultimate flexibility for special needs. We use this a lot to provide future flexibility while avoiding lots of YAGNI code. Omitting settings from the cnf file can have the result of picking up distro/package defaults and it seems like trying to hardcode proper defaults for a full-featured my.cnf template in each context would be a huge task.
Pardon me if details are wrong due to Friday afternoon effects, but you get the idea.

(Of course doesn't provide a way to use a non-standard my.cnf location.)

@geleman
Copy link

geleman commented Jun 22, 2015

@flatrocks that looks like a good solution. I'm currenlty trying to figure out if I can rewrite some of this to be able to control the directory structures. I'm new to Ruby so it's been an adventure so far. If I can just get the directories how I want them I can write a wrapper to create my default my.cnf for my environment.

@someara
Copy link
Contributor

someara commented Jul 17, 2015

These should all be tunable now as of 6.1.0... There are explicit knobs for the main my.cnf managed by a mysql_service, and an mysqld_options hash property as well. Enjoy!

@someara someara closed this as completed Jul 17, 2015
@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants