Parth6288

Untitled

Sep 26th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. --- # this file is for instlaling DB
  2. - hosts: rancher
  3. remote_user: ansible
  4. become: yes
  5. become_method: sudo
  6. connection: ssh
  7. vars:
  8. my_sql_root_pass: root_password
  9. tasks:
  10. - name: Install Mysql
  11. apt: name={{item}} state=installed update_cache=true
  12. with_items:
  13. - mysql-server
  14. - python-mysqldb
  15. - build-essential
  16. - python-pip
  17. - name: install mysql-python using pip
  18. pip: name={{item}} state=present
  19. with_items:
  20. - pip
  21. - MySQL-python
  22. - name: Start mysql service
  23. service: name=mysqld state=started enabled=true
  24. - name: update mysql root password
  25. mysql_user: name=root password={{ my_sql_root_pass }} priv=*.*:ALL,GRANT
  26. - name: create a new DB
  27. mysql_db: name=cattle
  28. collation=utf8_general_ci
  29. encoding=utf8
  30. state=present
  31. - name: create a new DB user
  32. mysql_user: name=cattle
  33. password=user_password
  34. priv="cattle.*:ALL,GRANT"
  35. host=localhost
  36. state=present
  37. - name: restart mysql
  38. service: name=mysqld state=restarted
Add Comment
Please, Sign In to add comment