Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. ---
  2. # sudo apt-get install *
  3. - name: Install MySQL and packages
  4. apt:
  5. name: "{{ item }}"
  6. state: present
  7. update_cache: yes
  8. with_items:
  9. - mysql-server=5.7.*
  10. - python3-mysqldb
  11. tags:
  12. - mysql
  13.  
  14. # Remove all anonymous users for all hosts
  15. - name: Remove all anonymous user accounts
  16. mysql_user:
  17. login_user: "{{ mysql.user }}"
  18. login_password: "{{ mysql.oldpassword }}"
  19. name: ""
  20. host_all: yes
  21. state: absent
  22. tags:
  23. - mysql
  24.  
  25. # Update "root" user password and grant all permissions for all hosts
  26. - name: Update "root" user password and grant all permissions for all hosts
  27. mysql_user:
  28. login_user: "{{ mysql.user }}"
  29. login_password: "{{ mysql.oldpassword }}"
  30. host: "{{ item }}"
  31. check_implicit_admin: yes
  32. name: "{{ mysql.user }}"
  33. password: "{{ mysql.newpassword }}"
  34. priv: "*.*:ALL,GRANT"
  35. state: present
  36. with_items:
  37. - "{{ mysql.hosts }}"
  38. tags:
  39. - mysql
  40.  
  41. - name: Update Mysql config
  42. template: src=/home/vagrant/vm2/playbooks/templates/mysqld.cnf.j2
  43. dest=/etc/mysql/mysql.conf.d/mysqld.cnf
  44. backup=yes
  45.  
  46. # Restart MySQL
  47. - name: Restart MySQL
  48. command: /bin/true
  49. notify:
  50. - Restart MySQL
  51. tags:
  52. - mysql
  53.  
  54. - name: Copy database
  55. sudo: yes
  56. copy:
  57. src: /home/vagrant/vm2/playbooks/templates/world.sql
  58. dest: /tmp/world.sql
  59. - name: Import Database
  60. mysql_db:
  61. login_user: "{{ mysql.user }}"
  62. login_password: "{{ mysql.oldpassword }}"
  63. name: main
  64. state: import
  65. target: /tmp/world.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement