Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. ---
  2. - hosts: all
  3. become: true
  4. remote_user: centos
  5. vars:
  6. rootpwd: Password1
  7. replipwd: Password2
  8. dbname: tests
  9. tasks:
  10. - name: Installing packages
  11. yum: name={{item}} state=latest
  12. with_items:
  13. - mariadb
  14. - mariadb-server
  15. - mariadb-devel
  16. - name: Installing Python module
  17. pip: name=MySQL-python
  18. - name: Server configuration
  19. lineinfile: dest=/etc/my.cnf line={{ item }} mode=0644 create=yes
  20. with_items:
  21. - bind-address=0.0.0.0
  22. - log-bin
  23. - server_d={{ ansible_all_ipv4_addresses[0].split('.')[3] }}
  24. - log-basename=log{{ ansible_all_ipv4_addresses[0].split('.')[3] }}
  25. - name: Restarting services
  26. service: state=restarted name=mariadb enabled=yes
  27. - name: Securing root account
  28. mysql_user: name=root password={{ rootpwd }} priv=*.*:ALL state=present
  29. - name: Client configuration
  30. lineinfile: dest=/root/.my.cnf line={{ item }} mode=0600 create=yes
  31. with_items:
  32. - "[client]"
  33. - user=root
  34. - password={{ rootpwd }}
  35. - name: Making database
  36. mysql_db: name={{ dbname }} state=present
  37. - name: Making replication user
  38. mysql_user: name=replicate password={{ replipwd }} priv="*.*:REPLICATION SLAVE" state=present host="%"
  39.  
  40. ...
  41. TASK [Restarting services] *****************************************************
  42. task path: /home/centos/.ansible/centos-mariadb.playbook:25
  43. changed: [172.30.1.21] => {"changed": true, "enabled": true, "name": "mariadb", "state": "started"}
  44. changed: [172.30.1.38] => {"changed": true, "enabled": true, "name": "mariadb", "state": "started"}
  45.  
  46. TASK [Securing root account] ***************************************************
  47. task path: /home/centos/.ansible/centos-mariadb.playbook:27
  48. ok: [172.30.1.38] => {"changed": false, "user": "root"}
  49. ok: [172.30.1.21] => {"changed": false, "user": "root"}
  50.  
  51. TASK [Client configuration] ****************************************************
  52. task path: /home/centos/.ansible/centos-mariadb.playbook:30
  53. ok: [172.30.1.21] => (item=[client]) => {"backup": "", "changed": false, "item": "[client]", "msg": ""}
  54. ok: [172.30.1.38] => (item=[client]) => {"backup": "", "changed": false, "item": "[client]", "msg": ""}
  55. ok: [172.30.1.21] => (item=user=root) => {"backup": "", "changed": false, "item": "user=root", "msg": ""}
  56. ok: [172.30.1.38] => (item=user=root) => {"backup": "", "changed": false, "item": "user=root", "msg": ""}
  57. ok: [172.30.1.21] => (item=password=Password1) => {"backup": "", "changed": false, "item": "password=Password1", "msg": ""}
  58. ok: [172.30.1.38] => (item=password=Password1) => {"backup": "", "changed": false, "item": "password=Password1", "msg": ""}
  59.  
  60. TASK [Making database] *********************************************************
  61. task path: /home/centos/.ansible/centos-mariadb.playbook:36
  62. ok: [172.30.1.21] => {"changed": false, "db": "tests"}
  63. ok: [172.30.1.38] => {"changed": false, "db": "tests"}
  64.  
  65. TASK [Making replication user] *************************************************
  66. task path: /home/centos/.ansible/centos-mariadb.playbook:38
  67. fatal: [172.30.1.21]: FAILED! => {"changed": false, "failed": true, "msg": "(1045, "Access denied for user 'root'@'localhost' (using password: YES)")"}
  68. fatal: [172.30.1.38]: FAILED! => {"changed": false, "failed": true, "msg": "(1045, "Access denied for user 'root'@'localhost' (using password: YES)")"}
  69.  
  70. NO MORE HOSTS LEFT *************************************************************
  71.  
  72. $ sudo mysql
  73. Welcome to the MariaDB monitor. Commands end with ; or g.
  74. Your MariaDB connection id is 6
  75. Server version: 5.5.50-MariaDB MariaDB Server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement