Categories
Ansible

Install MySQL 5.7 on CentOS via Ansible – Playbook .yml

---
- name: Install MySQL
  hosts: test123
  become: true
  remote_user: navdeepd2
  become_method: sudo
  gather_facts: true
  tasks:
    - name: "Installing Repo"
      shell: sudo rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
      ignore_errors: yes
    - name: "Installing MySQL 5.7"
      package: name=mysql-community-server state=present
    - name: Start the MySQL service
      become: true
      service: 
        name: mysqld
        state: started
        enabled: true
    - name: Find MySQL root password
      shell: "echo `grep 'temporary.*[email protected]' /var/log/mysqld.log | sed 's/.*[email protected]: //'`"
      register: mysql_root_pass
    - debug: var=mysql_root_pass.stdout