Skip to content
This repository has been archived by the owner on Nov 16, 2019. It is now read-only.

Commit

Permalink
Allow customized data directory for AWS /mnt magic
Browse files Browse the repository at this point in the history
  • Loading branch information
seldo committed Aug 13, 2014
1 parent a4e7642 commit 4c7f22a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mysql_port: 3306
mysql_bind_address: "0.0.0.0"
mysql_root_password: 'pass'
mysql_language: '/usr/share/mysql/'
mysql_datadir: '/var/lib/mysql_datadir'

# Fine Tuning
mysql_key_buffer: '16M'
Expand Down
41 changes: 39 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,42 @@
- percona-xtrabackup
- python-mysqldb

- name: Ensure datadir exists
sudo: true
file: >
path={{ mysql_datadir }}
state=directory
owner=mysql
group=mysql
- name: Ensure default datadir is not still there
sudo: true
file: >
path=/var/lib/mysql
state=absent
- name: Ensure symlink from /var/lib/mysql to datadir
sudo: true
file: >
path=/var/lib/mysql
src={{ mysql_datadir }}
state=link
force=yes
owner=mysql
group=mysql
notify:
- restart percona

- name: Copy .my.cnf file into the root home folder
template: src=root-my-cnf.j2 dest=/root/.my.cnf owner=root mode=0600

- name: Initialize the datadir if it's not already populated
sudo: true
command: mysql_install_db --datadir={{ mysql_datadir }}

- name: Update MySQL root password
mysql_user: name=root host={{ item }} password={{ root_password }} login_user=root login_password={{ root_password }} check_implicit_admin=yes
ignore_errors: true
mysql_user: name=root host={{ item }} password={{ root_password }} login_user=root login_password= check_implicit_admin=yes
with_items:
- "{{ ansible_hostname }}"
- 127.0.0.1
Expand All @@ -32,10 +63,16 @@
- "{{ ansible_hostname }}"
- localhost

- name: Ensure anonymous users are not in the database
mysql_user: name='' host={{ item }} state=absent
with_items:
- "{{ ansible_hostname }}"
- localhost

- name: remove test database
mysql_db: name=test state=absent

- name: Write custom server configuration
template: src=etc_mysql_my.cnf.j2 dest=/etc/mysql/my.cnf owner=root mode=0622
template: src=etc_mysql_my.cnf.j2 dest=/etc/mysql/my.cnf owner=root mode=0600
notify:
- restart percona

0 comments on commit 4c7f22a

Please sign in to comment.