Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 1 | {%- from "mysql/map.jinja" import server with context %} |
| 2 | |
| 3 | {%- if server.admin is defined %} |
| 4 | |
| 5 | mariadb_debconf: |
| 6 | debconf.set: |
| 7 | - name: mariadb-server |
| 8 | - data: |
| 9 | 'mysql-server/root_password': {'type':'string','value':'{{ server.admin.password }}'} |
| 10 | 'mysql-server/root_password_again': {'type':'string','value':'{{ server.admin.password }}'} |
Martin Polreich | 6ca7c3f | 2017-08-30 15:07:57 +0200 | [diff] [blame^] | 11 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 12 | - pkg: mysql_packages |
| 13 | |
| 14 | {%- endif %} |
| 15 | |
| 16 | mysql_packages: |
| 17 | pkg.installed: |
| 18 | - names: {{ server.pkgs }} |
| 19 | |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 20 | mysql_config: |
| 21 | file.managed: |
| 22 | - name: {{ server.config }} |
| 23 | - source: salt://mysql/conf/my.cnf.{{ grains.os_family }} |
| 24 | - mode: 644 |
| 25 | - template: jinja |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 26 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 27 | - pkg: mysql_packages |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 28 | |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 29 | mysql_service: |
| 30 | service.running: |
| 31 | - name: {{ server.service }} |
| 32 | - enable: true |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 33 | - watch: |
| 34 | - file: mysql_config |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 35 | |
| 36 | {%- if grains.get('virtual_subtype', None) == "Docker" %} |
| 37 | mysql_entrypoint: |
| 38 | file.managed: |
| 39 | - name: /entrypoint.sh |
| 40 | - template: jinja |
| 41 | - source: salt://mysql/files/entrypoint.sh |
| 42 | - mode: 755 |
| 43 | {%- endif %} |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 44 | |
| 45 | mysql_config_dir: |
| 46 | file.directory: |
| 47 | - name: /etc/mysql/conf.d |
| 48 | - makedirs: true |
| 49 | - mode: 755 |
| 50 | |
| 51 | mysql_dirs: |
| 52 | file.directory: |
| 53 | - names: |
| 54 | - /root/mysql/scripts |
| 55 | - /root/mysql/flags |
| 56 | - /root/mysql/data |
| 57 | - mode: 700 |
| 58 | - user: root |
| 59 | - group: root |
| 60 | - makedirs: true |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 61 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 62 | - pkg: mysql_packages |
| 63 | |
| 64 | /root/mysql/flags: |
| 65 | file.directory: |
| 66 | - mode: 700 |
| 67 | - user: root |
| 68 | - group: root |
| 69 | - makedirs: true |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 70 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 71 | - pkg: mysql_packages |
| 72 | |
| 73 | |
| 74 | {# |
| 75 | # Backup part |
| 76 | #} |
| 77 | |
| 78 | {# |
| 79 | # Backup part - automysqlbackup |
| 80 | #} |
| 81 | |
| 82 | {% for backup_engine in pillar.mysql.server.get("backup_engine", []) %} |
| 83 | |
| 84 | {%- if backup_engine.get("name", []) == "automysqlbackup" %} |
| 85 | |
| 86 | {%- if grains.osfullname in ['CentOS'] %} |
| 87 | |
| 88 | mysql_backup1_pkgs: |
| 89 | pkg.installed: |
| 90 | - names: |
| 91 | - pigz |
| 92 | - pbzip2 |
| 93 | - cronie |
| 94 | - mailx |
| 95 | |
| 96 | {%- elif grains.osfullname in ['Ubuntu'] %} |
| 97 | |
| 98 | mysql_backup2_pkgs: |
| 99 | pkg.installed: |
| 100 | - names: |
| 101 | - mailutils |
| 102 | - pigz |
| 103 | - pbzip2 |
| 104 | |
| 105 | {%- endif %} |
| 106 | |
| 107 | {%- if grains.osfullname in ['CentOS'] or grains.osfullname in ['Ubuntu'] %} |
| 108 | |
| 109 | mysql_backup_dirs: |
| 110 | file.directory: |
| 111 | - names: |
| 112 | - /root/mysql/scripts |
| 113 | - /root/mysql/data |
| 114 | - /etc/automysqlbackup |
| 115 | - mode: 700 |
| 116 | - user: root |
| 117 | - group: root |
| 118 | - makedirs: true |
| 119 | - require: |
| 120 | {%- if grains.osfullname in ['CentOS'] %} |
| 121 | - pkg: mysql_backup1_pkgs |
| 122 | {%- elif grains.osfullname in ['Ubuntu'] %} |
| 123 | - pkg: mysql_backup2_pkgs |
| 124 | {%- endif %} |
| 125 | |
| 126 | mysql_automysqlbackup_conf: |
| 127 | file.managed: |
| 128 | - name: /etc/automysqlbackup/automysqlbackup.conf |
| 129 | - source: salt://mysql/conf/automysqlbackup.conf |
| 130 | - mode: 644 |
| 131 | - template: jinja |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 132 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 133 | - file: mysql_backup_dirs |
| 134 | |
| 135 | mysql_automysqlbackup_script: |
| 136 | file.managed: |
| 137 | - name: /root/mysql/scripts/automysqlbackup |
| 138 | - source: salt://mysql/conf/automysqlbackup |
| 139 | - mode: 755 |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 140 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 141 | - file: mysql_backup_dirs |
| 142 | |
| 143 | mysql_automysqlbackup_cron: |
| 144 | file.managed: |
| 145 | - name: /etc/cron.daily/automysqlbackup |
| 146 | - source: salt://mysql/conf/automysqlbackup.cron |
| 147 | - mode: 755 |
| 148 | - template: jinja |
Filip Pytloun | 8980ef5 | 2016-05-24 17:11:50 +0200 | [diff] [blame] | 149 | - require: |
Filip Pytloun | 5b3c12e | 2015-10-06 16:28:32 +0200 | [diff] [blame] | 150 | - file: mysql_backup_dirs |
| 151 | |
| 152 | {%- endif %} |
| 153 | |
| 154 | {%- endif %} |
| 155 | |
| 156 | {%- endfor %} |
| 157 | |