opscode-cookbooks/mysql — pull request #157 by bdwyertech (2014-02-05 00:34:20+00:00)
Title: RHEL - Non-default Directories and SELinux

Changing data directories from the defaults doesn't always work correctly because the MySQL RPM's are installed prior to directory and configuration file creation. RPM installations are respective of the directories specified in /etc/my.cnf. If the RPM is installed before the directories are changed, mysql_install_db must be run again.
I've went ahead and moved around the execution order to place the package installation prerogatives underneath the directory creation and my.cnf population for RHEL.

Additionally, this makes use of some relatively simple bash code to ensure the directory's SELinux context is appropriate. If changing directories from default, this is imperative if running SELinux in enforcing mode.
I added an attribute, to enable this functionality, and it defaults to false. ['mysql']['server']['selinux_enabled']

Tested on RHEL 6.5 and CentOS 6.5.