Ansible – Установка percona cluster

Вот сам плейбук.

- hosts: 10.1.9.53
  vars:
    MySQL_root_pass: вашпарольдляmysql
  tasks:
   - name: Set MySQL root password before installing
     debconf: name='mysql-server' question='mysql-server/root_password' value='{{MySQL_root_pass | quote}}' vtype='password'
   - name: Confirm MySQL root password before installing
     debconf: name='mysql-server' question='mysql-server/root_password_again' value='{{MySQL_root_pass | quote}}' vtype='password'
   - name: Add Percona apt signing key
     apt_key: keyserver=keys.gnupg.net id=1C4CBDCDCD2EFD2A state=present
   - name: Add Percona repository
     apt_repository: repo='deb https://repo.percona.com/apt jessie main' state=present
   - name: Add Percona source repository
     apt_repository: repo='deb-src https://repo.percona.com/apt jessie main' state=present
   - name: Update apt cache
     apt: update_cache=yes
   - name: Install Percona XtraDB Cluster server
     apt: pkg={{ item }}
          state=present
     with_items:
       - percona-xtradb-cluster-full-56
       - percona-xtradb-cluster-56
       - rsync
       - ntp
       - ntpdate
       - python-mysqldb
       - xinetd
       - git
       - iptables-persistent
       - xtrabackup
       - percona-toolkit
   - name: Open the correct IPTables ports
     lineinfile: dest=/etc/iptables/rules.v4
                 regexp="^-A INPUT -p {{item.protocol}} -m {{item.protocol}} --dport $
                 line="-A INPUT -p {{item.protocol}} -m {{item.protocol}} --dport {{i$
                 insertafter="^:OUTPUT ACCEPT \[\d*:\d*\]$"
     with_items:
       - { protocol: tcp, port: 4567 }
       - { protocol: tcp, port: 4568 }
       - { protocol: tcp, port: 22 }
       - { protocol: tcp, port: 80 }
       - { protocol: tcp, port: 3306 }
       - { protocol: tcp, port: 464 }
       - { protocol: tcp, port: 444 }
       - { protocol: udp, port: 4567 }
       - { protocol: udp, port: 4568 }
       - { protocol: udp, port: 22 }
       - { protocol: udp, port: 80 }
       - { protocol: udp, port: 3306 }
       - { protocol: udp, port: 464 }
       - { protocol: udp, port: 444 }
     notify:
       - restart iptables
   - shell: iptables-save >/etc/iptables/rules.v4
   - name: add a string to the new file
     lineinfile: dest=/etc/fstab
                 regexp=''
                 insertafter=EOF
                 line='tmpfs /var/mysql tmpfs size=8G 0'
   - name: Craete Folder /var/mysql
     file: path=/var/mysql owner=mysql group=mysql mode=0755 state=directory
   - name: Create Folder /var/mysql_m/
     file: path=/var/mysql_m owner=mysql group=mysql mode=0755 state=directory
   - name: Create Folder /var/mysql_m/log
     file: path=/var/mysql_m/log owner=mysql group=mysql mode=0755 state=directory
   - name: Create Folder /var/mysql_m/bin
     file: path=/var/mysql_m/bin owner=mysql group=mysql mode=0755 state=directory
   - name: Create Folder /var/mysql_m/relay
     file: path=/var/mysql_m/relay owner=mysql group=mysql mode=0755 state=directory
   - shell: mount -a
   - name: Create Mysql configuration file
     template: src=/etc/ansible/files/percona53.cnf dest=/etc/mysql/my.cnf
     notify:
   - name: Update mysql root password for all root accounts
     mysql_user: name=root host={{ item }} password={{ MySQL_root_pass }}
     with_items:
       - "{{ ansible_hostname }}"
       - 127.0.0.1
       - ::1
       - localhost
   - shell: mount -a
     args:
       executable: /bin/bash
   - name: install  xinetd
     apt: name=xinetd  state=present
   - name: install  rsync
     apt: name=rsync  state=present
   - name: Copy file clustercheck to host
     copy: src=/etc/ansible/files/clustercheck dest=/usr/bin owner=root group=root mode="u+rwx"
   - name: Copy file clustercheck to host
     copy: src=/etc/ansible/files/mysqlchk dest=/etc/xinetd.d owner=root group=root mode="u+rwx"
   - name: add a string to the new file
     lineinfile: dest=/etc/services
                 regexp=''
                 insertafter=EOF
                 line='mysqlchk        9200/tcp'
   - service: name=xinetd state=stopped
   - service: name=xinetd state=started
   - service: name=mysql state=stopped

Как мы видим в процессе установке нам понадобиться конфиг , который лежит в каталоге /etc/ansible/files. Скачать его percona-test.cnf  здесь и положить в каталог, указанный в playbook’e.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

 

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.