- 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 }}