From f5cbd0264640ff921b2e0d0281273d14a2201448 Mon Sep 17 00:00:00 2001 From: Ken Fong Date: Tue, 30 Apr 2019 17:58:27 +0800 Subject: [PATCH] first commit --- README.md | 5 +++++ tasks/main.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 README.md create mode 100644 tasks/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..68d97f8 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# ansible role for basic mysql installation +URL: https://xpk.headdesk.me/git/xpk/role.mysql + +## Version +By default the latest of mysql community server will be installed. At present it's 8.0 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..ed64203 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,46 @@ +- name: Install mysql community repo + yum: + name: https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm + state: installed + +- name: Install mysql server, default 8.0 + yum: + name: + - mysql-community-server + - mysql-community-libs-compat + state: present + +- name: Tune mysql with baseline + blockinfile: + path: /etc/my.cnf + backup: yes + insertafter: '\[mysqld\]' + block: | + open_files_limit=8192 + max_connections = 200 + wait_timeout=180 + innodb_file_per_table + innodb_log_file_size=64M + innodb_log_files_in_group=3 + innodb_log_buffer_size=8M + default_storage_engine = innodb + +- name: Start up mysql + service: + name: mysqld + state: started + enabled: yes + +- name: Grep mysql cred + shell: awk '/temporary password is generated/ {print $NF}' /var/log/mysqld.log + register: mysqlRoot + +- name: Set mysql cred in /root/my.cnf + blockinfile: + path: /root/.my.cnf + mode: 0600 + block: | + [client] + password = {{ mysqlRoot.stdout }} + +