Advertisement
Guest User

Untitled

a guest
Mar 5th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. --- # Install mariadb via ansible on centOS
  2. - hosts: appserver
  3. user: test
  4. sudo: yes
  5. vars:
  6. mysql_root_password: passwd
  7. tasks:
  8. - name: Install MYSQL
  9. yum:
  10. name: mariadb-server #debian: mysql-server
  11. state: present
  12. - name: Install the Python MySQL Support Libraries
  13. yum: pkg=MySQL-python state=latest
  14. - name: start mysql server and enable it on reboot
  15. service: name=mariadb state=started enabled=true #debian: mysql
  16. - name: update mysql root password for all root accounts
  17. mysql_user:
  18. name: root
  19. host: "{{ item }}"
  20. password: "{{ mysql_root_password }}"
  21. login_user: root
  22. login_password: "{{ mysql_root_password }}"
  23. check_implicit_admin: yes
  24. priv: "*.*:ALL,GRANT"
  25. with_items:
  26. - "{{ ansible_hostname }}"
  27. - 127.0.0.1
  28. - ::1
  29. - localhost
  30. - name: Copy the root credentials as .my.cnf file
  31. template: src=root.cnf.j2 dest=~/.my.cnf mode=0600
  32. - name: Create a New Test DB called MyNewDB
  33. mysql_db: name=MyNewDB state=present login_user=root login_password={{ mysql_root_password }}
  34.  
  35. #
  36. #
  37. #templates/root.cnf.j2
  38. #
  39. #[client]
  40. #user=root
  41. #password={{ mysql_root_pass }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement