You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
33 lines
1.0 KiB
---
|
|
# This playbook will install mysql and create db user and give permissions.
|
|
|
|
- name: Install Mysql package
|
|
yum: name={{ item }} state=installed
|
|
with_items:
|
|
- mysql-server
|
|
- MySQL-python
|
|
- libselinux-python
|
|
- libsemanage-python
|
|
|
|
- name: Configure SELinux to start mysql on any port
|
|
seboolean: name=mysql_connect_any state=true persistent=yes
|
|
when: sestatus.rc != 0
|
|
|
|
- name: Create Mysql configuration file
|
|
template: src=my.cnf.j2 dest=/etc/my.cnf
|
|
notify:
|
|
- restart mysql
|
|
|
|
- name: Start Mysql Service
|
|
service: name=mysqld state=started enabled=true
|
|
|
|
- name: insert iptables rule
|
|
lineinfile: dest=/etc/sysconfig/iptables state=present regexp="{{ mysql_port }}"
|
|
insertafter="^:OUTPUT " line="-A INPUT -p tcp --dport {{ mysql_port }} -j ACCEPT"
|
|
notify: restart iptables
|
|
|
|
- name: Create Application Database
|
|
mysql_db: name={{ dbname }} state=present
|
|
|
|
- name: Create Application DB User
|
|
mysql_user: name={{ dbuser }} password={{ upassword }} priv=*.*:ALL host='%' state=present
|
|
|