From 8082fd69b9d93482b5380bae366a019f63f8a40e Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 28 Feb 2014 21:32:17 -0600 Subject: [PATCH] Add files, handlers, tasks, vars, and meta information. --- files/my.cnf | 38 ++++++++++++++++++++++++++++++++++++++ handlers/main.yml | 3 +++ meta/main.yml | 15 +++++++++++++++ tasks/main.yml | 38 ++++++++++++++++++++++++++++++++++++++ templates/my.cnf.j2 | 3 +++ vars/main.yml | 4 ++++ 6 files changed, 101 insertions(+) create mode 100644 files/my.cnf create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 templates/my.cnf.j2 create mode 100644 vars/main.yml diff --git a/files/my.cnf b/files/my.cnf new file mode 100644 index 0000000..04c0d85 --- /dev/null +++ b/files/my.cnf @@ -0,0 +1,38 @@ +[mysqld] +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock + +# Disabling symbolic-links is recommended to prevent assorted security risks +symbolic-links=0 + +# Settings user and group are ignored when systemd is used (fedora >= 15). +# If you need to run mysqld under a different user or group, +# customize your systemd unit file for mysqld according to the +# instructions in http://fedoraproject.org/wiki/Systemd +user=mysql + +# Semisynchronous Replication +# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html +# uncomment next line on MASTER +;plugin-load=rpl_semi_sync_master=semisync_master.so +# uncomment next line on SLAVE +;plugin-load=rpl_semi_sync_slave=semisync_slave.so + +# Others options for Semisynchronous Replication +;rpl_semi_sync_master_enabled=1 +;rpl_semi_sync_master_timeout=10 +;rpl_semi_sync_slave_enabled=1 + +# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html +;performance_schema + +# Customizations for local development. +wait_timeout = 28800 +max_allowed_packet = 64M +innodb_file_per_table = 1 # Allows for recovery of disk space when table are removed +innodb_buffer_pool_size = 128M # Up to 80% of available RAM on a dedicated box +innodb_flush_log_at_trx_commit = 2 # 1 for durability, 0 or 2 for performance + +[mysqld_safe] +log-error=/var/log/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..e6031ee --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: restart mysql + command: service mysqld restart diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..752d868 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,15 @@ +--- +dependencies: [] + +galaxy_info: + author: geerlingguy + description: MySQL server for RHEL/CentOS 6.x + company: "Midwestern Mac, LLC" + license: "license (BSD, MIT)" + min_ansible_version: 1.4 + platforms: + - name: EL + versions: + - 6 + categories: + - database diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..7af1272 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,38 @@ +--- +# If this is not done for the version of MySQL in certain extra repositories, +# MySQL installation fails with an error the first time. +- name: Update postfix to the latest version. + yum: name=postfix state=latest enablerepo={{ mysql_enablerepo }} + +- name: Ensure MySQL packages are installed. + yum: name={{ item }} state=installed enablerepo={{ mysql_enablerepo }} + with_items: + - mysql + - mysql-server + - MySQL-python + +- name: Copy my.cnf global MySQL configuration. + copy: src=my.cnf dest=/etc/my.cnf owner=root group=root mode=0644 + +# Set MySQL to run at startup. +- name: Ensure MySQL is started. + service: name=mysqld state=started enabled=yes + +# 'localhost' needs to be the last item for idempotency, see +# http://ansible.cc/docs/modules.html#mysql-user +- name: update mysql root password for all root accounts + mysql_user: name=root host={{ item }} password={{ mysql_root_password }} + with_items: + - 127.0.0.1 + - ::1 + - localhost + +# Has to be after the root password assignment, for idempotency. +- name: Copy .my.cnf file with root password credentials. + template: src=my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600 + +- name: Delete anonymous MySQL user for localhost. + mysql_user: name="" state="absent" + +- name: Remove the MySQL test database. + mysql_db: name="test" state="absent" diff --git a/templates/my.cnf.j2 b/templates/my.cnf.j2 new file mode 100644 index 0000000..b013aa3 --- /dev/null +++ b/templates/my.cnf.j2 @@ -0,0 +1,3 @@ +[client] +user=root +password={{ mysql_root_password }} \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..54cd290 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,4 @@ +--- +# Pass in a comma-separated list of repos to use (e.g. "remi,epel"). +mysql_enablerepo: "" +mysql_root_password: root