Skip to content

saygoweb/mysql

 
 

Repository files navigation

ANXS - MySQL Build Status

Ansible role that installs MySQL on (for now) Ubuntu variants. Features include:

  • Installation of MySQL and it's dependencies
  • Basic configuration
  • Standard hardening (root password, removal of test databases)
  • Add databases
  • Add users
  • Setup of monit process supervision

Requirements & Dependencies

  • Tested on Ansible 1.4 or higher.
  • ANXS.monit if you want monit protection (in that case, you should set monit_protection: true)

Variables

# Basic settings
mysql_port: 3306                        # The port on which mysql listens
mysql_bind_address: "0.0.0.0"           # The address the mysql server binds on
mysql_root_password: ''			# The root password

# Optional, single use variable, see below for changing root password
# mysql_current_root_password: 'newpass'

# Fine Tuning
mysql_key_buffer: '16M'
mysql_max_allowed_packet: '128M'
mysql_thread_stack: '192K'
mysql_cache_size: 8
mysql_myisam_recover: 'BACKUP'
mysql_max_connections: 100
mysql_table_cache: 64
mysql_thread_concurrency: 10
mysql_query_cache_limit: '1M'
mysql_query_cache_size: '16M'
mysql_character_set_server: 'utf8'
mysql_collation_server: 'utf8_general_ci'
mysql_mysqldump_max_allowed_packet: '128M'
mysql_isamchk_key_buffer: '16M'

# InnoDB tuning
mysql_innodb_file_per_table: 'innodb_file_per_table'
mysql_innodb_flush_method: 'fdatasync'
mysql_innodb_buffer_pool_size: '128M'
mysql_innodb_flush_log_at_trx_commit: 1
mysql_innodb_lock_wait_timeout: 50
mysql_innodb_log_buffer_size: '1M'
mysql_innodb_log_file_size: '5M'

# List of databases to be created (optional)
mysql_databases:
  - name: foobar
    collation: "utf8_general_ci"        # optional, defaults to "utf8_general_ci"
    encoding: "utf8"                    # optional, defaults to "utf8"

# List of users to be created (optional)
mysql_users:
  - name: baz
    pass: pass
    priv: "*.*:ALL"                     # optional, defaults to "*.*:ALL"
    host: "%"                           # optional, defaults to "localhost"

# GLOBAL Setting
monit_protection: false                 # true or false, requires ANXS.monit

Setting the Root Password

If You would like to change your mysql root password using this role, ensure you use the following variables in your play:

mysql_current_root_password: <Your current root password>
mysql_root_password: <Your new root password>

These will be used to change the password of the root user, once you have run your play, please remove the mysql_current_root_password variable, as it is no longer needed, and will cause subsequent plays to fail.

Heres an example of how you might change the root password using the -e parameter:

ansible-playbook myplay.yml -e "mysql_current_root_password='current_pass' mysql_root_password='new_pass'" --sudo

Testing

This project comes with a VagrantFile, this is a fast and easy way to test changes to the role, fire it up with vagrant up, provision the box with either:

vagrant provision

This also happens automatically after the first vagrant up, or:

ansible-playbook test.yml -i vagrant-inventory --sudo

This is the ansible way, and will easily allow command line arguments like --tags and -e

See vagrant docs for getting setup with vagrant

License

Licensed under the MIT License. See the LICENSE file for details.

Feedback, bug-reports, requests, ...

Are welcome!

About

Ansible role for MySQL

Resources

License

Stars

Watchers

Forks

Packages

No packages published