mirror of
https://github.com/aljazceru/ansible-role-mysql.git
synced 2025-12-20 15:04:24 +01:00
Add files, handlers, tasks, vars, and meta information.
This commit is contained in:
38
tasks/main.yml
Normal file
38
tasks/main.yml
Normal file
@@ -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"
|
||||
Reference in New Issue
Block a user