-
-
Save liuha/339ce738f0500b24777f3b3767a0f516 to your computer and use it in GitHub Desktop.
Install mariadb via ansible on centOS
This file contains hidden or 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
--- # Install mariadb via ansible on centOS | |
- hosts: appserver | |
user: test | |
sudo: yes | |
vars: | |
mysql_root_password: passwd | |
tasks: | |
- name: Install MYSQL | |
yum: | |
name: mariadb-server #debian: mysql-server | |
state: present | |
- name: Install the Python MySQL Support Libraries | |
yum: pkg=MySQL-python state=latest | |
- name: start mysql server and enable it on reboot | |
service: name=mariadb state=started enabled=true #debian: mysql | |
- name: update mysql root password for all root accounts | |
mysql_user: | |
name: root | |
host: "{{ item }}" | |
password: "{{ mysql_root_password }}" | |
login_user: root | |
login_password: "{{ mysql_root_password }}" | |
check_implicit_admin: yes | |
priv: "*.*:ALL,GRANT" | |
with_items: | |
- "{{ ansible_hostname }}" | |
- 127.0.0.1 | |
- ::1 | |
- localhost | |
- name: Copy the root credentials as .my.cnf file | |
template: src=root.cnf.j2 dest=~/.my.cnf mode=0600 | |
- name: Create a New Test DB called MyNewDB | |
mysql_db: name=MyNewDB state=present login_user=root login_password={{ mysql_root_password }} | |
# | |
# | |
#templates/root.cnf.j2 | |
# | |
#[client] | |
#user=root | |
#password={{ mysql_root_pass }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment