Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- # sudo apt-get install *
- - name: Install MySQL and packages
- apt:
- name: "{{ item }}"
- state: present
- update_cache: yes
- with_items:
- - mysql-server=5.7.*
- - python3-mysqldb
- tags:
- - mysql
- # Remove all anonymous users for all hosts
- - name: Remove all anonymous user accounts
- mysql_user:
- login_user: "{{ mysql.user }}"
- login_password: "{{ mysql.oldpassword }}"
- name: ""
- host_all: yes
- state: absent
- tags:
- - mysql
- # Update "root" user password and grant all permissions for all hosts
- - name: Update "root" user password and grant all permissions for all hosts
- mysql_user:
- login_user: "{{ mysql.user }}"
- login_password: "{{ mysql.oldpassword }}"
- host: "{{ item }}"
- check_implicit_admin: yes
- name: "{{ mysql.user }}"
- password: "{{ mysql.newpassword }}"
- priv: "*.*:ALL,GRANT"
- state: present
- with_items:
- - "{{ mysql.hosts }}"
- tags:
- - mysql
- - name: Update Mysql config
- template: src=/home/vagrant/vm2/playbooks/templates/mysqld.cnf.j2
- dest=/etc/mysql/mysql.conf.d/mysqld.cnf
- backup=yes
- # Restart MySQL
- - name: Restart MySQL
- command: /bin/true
- notify:
- - Restart MySQL
- tags:
- - mysql
- - name: Copy database
- sudo: yes
- copy:
- src: /home/vagrant/vm2/playbooks/templates/world.sql
- dest: /tmp/world.sql
- - name: Import Database
- mysql_db:
- login_user: "{{ mysql.user }}"
- login_password: "{{ mysql.oldpassword }}"
- name: main
- state: import
- target: /tmp/world.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement