-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Install MySL server and set password for root user from local environment variable. - Continue ansible run if mysql_user fails. Password is already configured at first run. - Remove debuging from mysql playbook and rename mysql password setup task. - Change mysql data folder setting, move mysql data folder and restart required service. - Cheack if apparmor is installed and reconfigure if it does. - Move mysql playbook to webservers section. - Change password variable to mysql_root_passwd. Fixes #11 Closes #35
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
|
||
- name: Restart mysql | ||
action: service name=mysql state=restarted | ||
|
||
- name: Move mysql data folder | ||
command: echo "Starting to move MySQL data folder" | ||
notify: Stop mysql service | ||
|
||
- name: Stop mysql service | ||
action: service name=mysql state=stopped | ||
notify: Move mysql data | ||
|
||
- name: Move mysql data | ||
command: mv /var/lib/mysql /data/ | ||
notify: Start mysql service | ||
|
||
- name: Start mysql service | ||
service: name=mysql state=started | ||
|
||
- name: Restart apparmor service | ||
service: name=mysql state=stopped | ||
service: name=apparmor state=restarted | ||
notify: Start mysql service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
|
||
- name: Install mysql-server package | ||
apt: name=mysql-server update_cache=yes | ||
|
||
- name: Install python-mysqldb module required by Ansible | ||
apt: name=python-mysqldb update_cache=yes | ||
|
||
- name: Configure mysql root user pass | ||
mysql_user: name=root password="{{ lookup('env','mysql_root_passwd') }}" | ||
ignore_errors: yes | ||
|
||
- name: Create /data/mysql folder | ||
file: path=/data/mysql state=directory owner=mysql group=mysql | ||
|
||
- name: Change mysql data folder | ||
lineinfile: dest=/etc/mysql/my.cnf line='datadir = /data/mysql' | ||
regexp='^datadir' | ||
notify: Move mysql data folder | ||
|
||
- name: Test if apparmor exists | ||
stat: path=/etc/init.d/apparmor | ||
register: apparmor_installed | ||
|
||
- name: Fix apparmor configuration for mysql | ||
lineinfile: | ||
regexp='{{ item.apparmor }}' backrefs=yes line='{{ item.apparmor_line }}' dest=/etc/apparmor.d/usr.sbin.mysqld | ||
with_items: | ||
- { apparmor: '^ /var/lib/mysql/ r\,', apparmor_line: ' /data/mysql/ r,' } | ||
- { apparmor: '^ /var/lib/mysql/\*\* rwk\,', apparmor_line: ' /data/mysql/** rwk,' } | ||
|
||
notify: Restart apparmor service | ||
when: apparmor_installed.stat.exists |