Configure MySQL on webnodes; forwarding /var/run/mysqld/mysqld.sock to caffeine:3306

This commit is contained in:
Zachary Seguin 2016-11-30 16:25:33 -05:00
parent f31ddfcbe5
commit a434363727
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1 @@
d /var/run/mysqld 0755 root root -

View File

@ -0,0 +1,9 @@
[Unit]
Description=MySQL forwarding to caffeine
After=networking.target
[Service]
ExecStart=/usr/bin/socat UNIX-LISTEN:/var/run/mysqld/mysqld.sock,fork,reuseaddr,unlink-early,user=nobody,group=nogroup,mode=777 TCP:caffeine:3306
[Install]
WantedBy=multi-user.target

View File

@ -3,7 +3,12 @@
- name: Install packages
package: name={{ item }} state=latest
with_items:
# PHP5
- php5-fpm
- php5-mysql
# MySQL
- socat
#
# Apache setup
@ -21,6 +26,7 @@
service:
name: apache2
state: restarted
enabled: yes
when: apache_configuration.changed
#
@ -37,4 +43,33 @@
service:
name: php5-fpm
state: restarted
enabled: yes
when: fpm_configuration.changed
#
# MySQL setup
#
- name: Configure MySQL forwarding service
copy:
src: mysql-forwarding.service
dest: /etc/systemd/system/mysql-forwarding.service
backup: no
register: mysql_forwarding
- name: Configure MySQL tmp file
copy:
src: mysql-forwarding.conf
dest: /etc/tmpfiles.d/mysql-forwarding.conf
backup: no
register: mysql_forwarding_tmpfile
- name: Create tmpfiles for MySQL forwarding
command: systemd-tmpfiles --create
when: mysql_forwarding_tmpfile.changed
- name: Enable MySQL forwarding service
service:
name: mysql-forwarding
state: restarted
enabled: yes
when: mysql_forwarding.changed or mysql_forwarding_tmpfile.changed