diff options
Diffstat (limited to 'deploy/adapters/ansible/roles/database/tasks')
6 files changed, 46 insertions, 27 deletions
diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml index 442cd18b..9752b550 100644 --- a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_debian.yml @@ -8,7 +8,9 @@ ############################################################################## --- - name: get cluster status - shell: mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"'|awk '{print $2}' + shell: | + mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \ + | awk '{print $2}' register: cluster_status when: - inventory_hostname == haproxy_hosts.keys()[0] @@ -22,7 +24,9 @@ and not cluster_status.stdout | search("OPERATIONAL") - name: wait for cluster ready - shell: mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"'|awk '{print $2}' + shell: | + mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \ + | awk '{print $2}' register: cluster_status until: cluster_status|success failed_when: not cluster_status.stdout | search("OPERATIONAL") @@ -33,7 +37,9 @@ and not cluster_status.stdout | search("OPERATIONAL") - name: if I in the cluster nodes - shell: mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_incoming_addresses"'|awk '{print $2}' + shell: | + mysql --silent --skip-column-names \ + -e 'SHOW STATUS LIKE "wsrep_incoming_addresses"' | awk '{print $2}' register: cluster_nodes changed_when: false @@ -42,7 +48,7 @@ when: | inventory_hostname != haproxy_hosts.keys()[0] and not cluster_nodes.stdout | search( "{{ internal_ip }}" ) - ignore_errors: True + ignore_errors: "True" - name: delay 60 seconds shell: sleep 60 @@ -55,15 +61,13 @@ - name: chmod directory shell: > - chmod 755 -R /var/lib/mysql/ ; - chmod 755 -R /var/log/mysql/ ; - chmod 755 -R /etc/mysql/conf.d/; + chmod 755 -R /var/lib/mysql/; + chmod 755 -R /var/log/mysql/; + chmod 755 -R /etc/mysql/conf.d/; - name: restart first nodes shell: service mysql restart when: | - (inventory_hostname == haproxy_hosts.keys()[0] + (inventory_hostname == haproxy_hosts.keys()[0] and haproxy_hosts|length > 1 and not cluster_nodes.stdout | search( '{{ internal_ip }}' )) - - diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml index cfd778f1..77b18702 100644 --- a/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_cluster_redhat.yml @@ -13,10 +13,12 @@ - name: killall mysqld processes shell: sudo killall -9 mysqld when: RECOVERY_ENV - ignore_errors: True + ignore_errors: "True" - name: get cluster status - shell: mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"'|awk '{print $2}' + shell: | + mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \ + | awk '{print $2}' register: cluster_status when: - inventory_hostname == haproxy_hosts.keys()[0] @@ -28,7 +30,9 @@ and not cluster_status.stdout | search("OPERATIONAL") - name: wait for cluster ready - shell: mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"'|awk '{print $2}' + shell: | + mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_evs_state"' \ + | awk '{print $2}' register: cluster_status until: cluster_status|success failed_when: not cluster_status.stdout | search("OPERATIONAL") @@ -39,7 +43,9 @@ and not cluster_status.stdout | search("OPERATIONAL") - name: if I in the cluster nodes - shell: mysql --silent --skip-column-names -e 'SHOW STATUS LIKE "wsrep_incoming_addresses"'|awk '{print $2}' + shell: | + mysql --silent --skip-column-names \ + -e 'SHOW STATUS LIKE "wsrep_incoming_addresses"' | awk '{print $2}' register: cluster_nodes changed_when: false @@ -47,7 +53,7 @@ service: name: mysql state: restarted - enabled: yes + enabled: "yes" when: | inventory_hostname != haproxy_hosts.keys()[0] and not cluster_nodes.stdout | search( "{{ internal_ip }}") @@ -61,7 +67,5 @@ name: mysql state: restarted when: | - inventory_hostname == haproxy_hosts.keys()[0] + inventory_hostname == haproxy_hosts.keys()[0] and haproxy_hosts|length > 1 - - diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml index 780fc322..22b5d60c 100644 --- a/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_config.yml @@ -8,7 +8,10 @@ ############################################################################## --- - name: create all needed db - mysql_db: login_unix_socket=/var/run/mysqld/mysqld.sock name={{ item.db }} state=present + mysql_db: + login_unix_socket=/var/run/mysqld/mysqld.sock + name={{ item.db }} + state=present with_items: "{{ credentials }}" tags: - test_db @@ -63,7 +66,8 @@ service: name: mysql state: restarted - when: inventory_hostname == haproxy_hosts.keys()[0] and haproxy_hosts|length > 1 + when: inventory_hostname == haproxy_hosts.keys()[0] + and haproxy_hosts|length > 1 - name: wait for cluster ready command: mysql -e"show status like 'wsrep%'" @@ -79,7 +83,6 @@ service: name: mysql state: restarted - enabled: yes + enabled: "yes" when: - inventory_hostname != haproxy_hosts.keys()[0] - diff --git a/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml b/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml index d1897173..ba800dca 100644 --- a/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mariadb_install.yml @@ -32,7 +32,7 @@ template: src: '{{ item.src }}' dest: '{{ item.dest }}' - backup: yes + backup: "yes" mode: 0644 with_items: "{{ mysql_config }}" @@ -52,7 +52,13 @@ when: ansible_os_family == "Debian" - name: set owner - file: path=/var/lib/mysql owner=mysql group=mysql recurse=yes state=directory mode=0755 + file: + path: /var/lib/mysql + owner: mysql + group: mysql + recurse: "yes" + state: directory + mode: 0755 - name: get logfile stat stat: path='{{ mysql_data_dir }}/ib_logfile0' @@ -67,4 +73,3 @@ when: | logfile_stat.stat.exists and logfile_stat.stat.size != 1073741824 - diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml index 76aa5675..10f0322c 100755 --- a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml @@ -19,7 +19,9 @@ shell: mongo compass /opt/replica.js - name: wait replica servers are ready - shell: mongo compass --eval 'printjson(rs.status())'|grep -E 'PRIMARY|SECONDARY'|wc -l + shell: | + mongo compass --eval 'printjson(rs.status())'| \ + grep -E 'PRIMARY|SECONDARY'| wc -l register: servers until: servers.stdout|int == {{ haproxy_hosts|length }} retries: 60 diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml index bac6c6eb..67bc0499 100755 --- a/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml +++ b/deploy/adapters/ansible/roles/database/tasks/mongodb_install.yml @@ -19,7 +19,8 @@ template: src=mongodb.conf dest=/opt/os_templates backup=yes - name: update mongodb config file - shell: crudini --merge {{ mongodb_config.dest }} < /opt/os_templates/mongodb.conf + shell: | + crudini --merge {{ mongodb_config.dest }} < /opt/os_templates/mongodb.conf - name: rm prealloc files file: |