Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysqld_safe --wsrep-new-cluster &
- - name: install python mysql bindings
- apt: name=python-mysqldb state=present
- #command: mysql_secure_installation
- become: yes
- become_method: sudo
- - name: Sets the root password
- mysql_user: user=root password={{ root_password }} host=localhost
- - name: copy .my.cnf file with root password credentials
- template: src=files/my-cnf.j2 dest=/root/.my.cnf owner=root mode=0600
- become: yes
- become_method: sudo
- - name: set the sql debian-sys-maint password
- mysql_user: user=debian-sys-maint
- password={{ debian_sys_maint_password }}
- host=localhost
- - name: delete anonymous sql server user for localhost
- mysql_user: user="" state="absent" host=localhost
- - name: Secures the MySQL root user for IPV6 localhost (::1)
- mysql_user: user="root" password="{{ root_password }}" host="::1"
- - name: Secures the MySQL root user for IPV4 localhost (127.0.0.1)
- mysql_user: user="root" password="{{ root_password }}" host="127.0.0.1"
- - name: Secures the MySQL root user for localhost domain (localhost)
- mysql_user: user="root" password="{{ root_password }}" host="localhost"
- - name: Secures the MySQL root user for server_hostname domain
- mysql_user: user="root" password="{{ root_password }}" host="{{ ansible_fqdn }}"
- - name: Removes the MySQL test database
- mysql_db: db=test state=absent
- - name: copy cluster.cnf file
- template: src=files/cluster-cnf.j2 dest=/etc/mysql/conf.d/galera.cnf owner=root mode=0600
- become: yes
- become_method: sudo
- - name: Enable ufw
- ufw: state=enabled
- - name: Configure ufw rules
- ufw: rule={{ item.rule }} port={{ item.port }} proto={{ item.proto }}
- with_items:
- - { rule: 'allow', port: '3306', proto: 'tcp' }
- - { rule: 'allow', port: '4444', proto: 'tcp' }
- - { rule: 'allow', port: '4567', proto: 'tcp' }
- - { rule: 'allow', port: '4568', proto: 'tcp' }
- - { rule: 'allow', port: '3306', proto: 'udp' }
- - { rule: 'allow', port: '4567', proto: 'udp' }
- - { rule: 'allow', port: '22', proto: 'tcp' }
- - name: Stop mysql services
- service: name=mysql state=stopped
- ignore_errors: yes
- become: yes
- become_method: sudo
- - name: Bootstrap mysql service
- command: galera_new_cluster
- become: yes
- become_method: sudo
- when: play_hosts[0] == inventory_hostname
- - name: Start mysql in other nodes
- service: name=mysql state=restarted
- when: play_hosts[0] != inventory_hostname
- - name: Restart mysql on first node
- service: name=mysql state=restarted
- when: play_hosts[0] == inventory_hostname
Add Comment
Please, Sign In to add comment