Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. - name: Install MySQL packages
  2. apt: pkg={{item}} state=installed
  3. with_items:
  4. - bundler
  5. - mysql-server-core-5.5
  6. - mysql-client-core-5.5
  7. - libmysqlclient-dev
  8. - python-mysqldb
  9. - mysql-server
  10. - mysql-client
  11. - build-essential
  12. - name: Remove the MySQL test database
  13. action: mysql_db db=test state=absent
  14.  
  15.  
  16. - name: Create global my.cnf
  17. template: src=etc.my.cnf dest=/etc/mysql/my.cnf
  18. - name: Create databases
  19. mysql_db: name={{item}} state=present collation=utf8_general_ci encoding=utf8
  20. with_items:
  21. - db1
  22. - db2
  23.  
  24.  
  25. - name: Add deploy DB user and allow access to news_* databases
  26. mysql_user: name={{user}} password={{password}} host="%" priv=db1.*:ALL/db2.*:ALL,GRANT state=present
  27.  
  28.  
  29. - name: Set root password
  30. mysql_user: name=root password={{password}} host="{{item}}" priv=*.*:ALL,GRANT state=present
  31. with_items:
  32. - "{{ansible_hostname}}"
  33. - 127.0.0.1
  34. - ::1
  35. - localhost
  36.  
  37.  
  38. - name: Create local my.cnf for root user
  39. template: src=my.cnf dest=/root/.my.cnf owner=root mode=0600
  40.  
  41.  
  42. - name: Restart the MySQL service
  43. action: service name=mysql state=restarted enabled=true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement