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

master
Zachary Seguin 6 years ago
parent f31ddfcbe5
commit a434363727
  1. 1
      roles/webnode/files/mysql-forwarding.conf
  2. 9
      roles/webnode/files/mysql-forwarding.service
  3. 35
      roles/webnode/tasks/main.yml

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

@ -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

@ -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

Loading…
Cancel
Save