Guest User

Untitled

a guest
Apr 14th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. mysqld_safe --wsrep-new-cluster &
  2.  
  3. - name: install python mysql bindings
  4. apt: name=python-mysqldb state=present
  5. #command: mysql_secure_installation
  6. become: yes
  7. become_method: sudo
  8.  
  9.  
  10. - name: Sets the root password
  11. mysql_user: user=root password={{ root_password }} host=localhost
  12.  
  13. - name: copy .my.cnf file with root password credentials
  14. template: src=files/my-cnf.j2 dest=/root/.my.cnf owner=root mode=0600
  15. become: yes
  16. become_method: sudo
  17.  
  18.  
  19. - name: set the sql debian-sys-maint password
  20. mysql_user: user=debian-sys-maint
  21. password={{ debian_sys_maint_password }}
  22. host=localhost
  23.  
  24.  
  25. - name: delete anonymous sql server user for localhost
  26. mysql_user: user="" state="absent" host=localhost
  27.  
  28. - name: Secures the MySQL root user for IPV6 localhost (::1)
  29. mysql_user: user="root" password="{{ root_password }}" host="::1"
  30.  
  31. - name: Secures the MySQL root user for IPV4 localhost (127.0.0.1)
  32. mysql_user: user="root" password="{{ root_password }}" host="127.0.0.1"
  33.  
  34. - name: Secures the MySQL root user for localhost domain (localhost)
  35. mysql_user: user="root" password="{{ root_password }}" host="localhost"
  36.  
  37. - name: Secures the MySQL root user for server_hostname domain
  38. mysql_user: user="root" password="{{ root_password }}" host="{{ ansible_fqdn }}"
  39. - name: Removes the MySQL test database
  40. mysql_db: db=test state=absent
  41.  
  42. - name: copy cluster.cnf file
  43. template: src=files/cluster-cnf.j2 dest=/etc/mysql/conf.d/galera.cnf owner=root mode=0600
  44. become: yes
  45. become_method: sudo
  46.  
  47. - name: Enable ufw
  48. ufw: state=enabled
  49.  
  50. - name: Configure ufw rules
  51. ufw: rule={{ item.rule }} port={{ item.port }} proto={{ item.proto }}
  52. with_items:
  53. - { rule: 'allow', port: '3306', proto: 'tcp' }
  54. - { rule: 'allow', port: '4444', proto: 'tcp' }
  55. - { rule: 'allow', port: '4567', proto: 'tcp' }
  56. - { rule: 'allow', port: '4568', proto: 'tcp' }
  57. - { rule: 'allow', port: '3306', proto: 'udp' }
  58. - { rule: 'allow', port: '4567', proto: 'udp' }
  59. - { rule: 'allow', port: '22', proto: 'tcp' }
  60.  
  61. - name: Stop mysql services
  62. service: name=mysql state=stopped
  63. ignore_errors: yes
  64. become: yes
  65. become_method: sudo
  66.  
  67.  
  68. - name: Bootstrap mysql service
  69. command: galera_new_cluster
  70. become: yes
  71. become_method: sudo
  72. when: play_hosts[0] == inventory_hostname
  73.  
  74. - name: Start mysql in other nodes
  75. service: name=mysql state=restarted
  76. when: play_hosts[0] != inventory_hostname
  77.  
  78. - name: Restart mysql on first node
  79. service: name=mysql state=restarted
  80. when: play_hosts[0] == inventory_hostname
Add Comment
Please, Sign In to add comment