ansible-roles/lxc-php/tasks/misc.yml
Mathieu Trossevin 1d9ab0f1f3 Allows using localhost to connect to MySQL in lxc
Add 'php_conf_mysql_default_socket' variable to lxc-php role that
configure both the lxc containers and PHP so that a local MySQL database
may be used through localhost.

The PHP containers will automount /var/run/mysqld/mysqld.sock (the
default path to the mysql socket) to the path defined by the variable
'php_conf_mysql_default_socket' which will be the path used by php to
contact MySQL both with mysqli and PDO_MYSQL.
2020-06-17 16:06:53 +02:00

33 lines
1.1 KiB
YAML

---
- name: "{{ lxc_php_version }} - Configure timezone for the container"
copy:
remote_src: yes
src: "/etc/timezone"
dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/timezone"
- name: "{{ lxc_php_version }} - Ensure container's root directory is 755"
file:
path: "/var/lib/lxc/{{ lxc_php_version }}/rootfs"
state: directory
mode: '0755'
- name: "{{ lxc_php_version }} - Configure mailname for the container"
copy:
content: "{{ evolinux_hostname }}.{{ evolinux_domain }}\n"
dest: "/var/lib/lxc/{{ lxc_php_version }}/rootfs/etc/mailname"
notify: "Restart opensmtpd"
- name: "{{ lxc_php_version }} - Install misc packages"
lxc_container:
name: "{{ lxc_php_version }}"
container_command: "DEBIAN_FRONTEND=noninteractive apt install -y cron logrotate git zip unzip"
- name: "{{ lxc_php_version }} - Add MySQL socket to container default mounts"
lxc_container:
name: "{{ lxc_php_version }}"
container_config:
- "lxc.mount.entry = /var/run/mysqld/mysqld {{ php_conf_mysql_default_socket | replace('/', '', 1) }} none bind,create=file 0 0"
state: restarted
when: php_conf_mysql_default_socket is string