diff --git a/lxc-php/handlers/main.yml b/lxc-php/handlers/main.yml index 365179ea..b20fac7b 100644 --- a/lxc-php/handlers/main.yml +++ b/lxc-php/handlers/main.yml @@ -7,3 +7,6 @@ - name: Reload php73-fpm command: "lxc-attach -n php73 -- systemctl reload php7.3-fpm" + +- name: Restart opensmtpd + command: "lxc-attach -n php73 -- systemctl restart opensmtpd" diff --git a/lxc-php/tasks/php.yml b/lxc-php/tasks/php.yml index 25b72ccd..d2b627f6 100644 --- a/lxc-php/tasks/php.yml +++ b/lxc-php/tasks/php.yml @@ -23,27 +23,8 @@ command: "lxc-attach -n {{name}} -- apt-get update" when: name == 'php73' -- name: Install requirements for sury repository - command: "lxc-attach -n {{name}} -- apt-get install -y --no-install-recommends wget apt-transport-https ca-certificates gnupg" - when: name == 'php73' - -- name: Add sury APT repository - copy: - content: "deb https://packages.sury.org/php/ stretch main" - dest: "/var/lib/lxc/{{name}}/rootfs/etc/apt/sources.list.d/sury.list" - mode: "0644" - when: name == 'php73' - -- name: Add sury GPG key - shell: "wget -O- https://packages.sury.org/php/apt.gpg |lxc-attach -n {{name}} -- apt-key add -" - when: name == 'php73' - -- name: Update APT cache - command: "lxc-attach -n {{name}} -- apt-get update" - when: name == 'php73' - - name: Install PHP packages - command: "lxc-attach -n {{name}} -- apt-get install -y php7.3 php7.3-fpm php7.3-cli php7.3-curl php7.3-mysql php7.3-pgsql php7.3-ldap php7.3-imap php7.3-gd php-ssh2 php-gettext composer libphp-phpmailer ssmtp git zip unzip php7.3-zip" + command: "lxc-attach -n {{name}} -- /bin/bash -c 'export DEBIAN_FRONTEND=noninteractive && apt-get install -y php-fpm php-cli php-gd php-intl php-imap php-ldap php-mysql php-pgsql php-gettext php-curl php-ssh2 composer libphp-phpmailer opensmtpd git zip unzip php-zip'" when: name == 'php73' - name: Copy evolinux PHP 5.6 configuration @@ -90,18 +71,36 @@ name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf" regexp: "^mailhub=.*$" replace: "mailhub=127.0.0.1" + when: name != 'php73' - name: Configure ssmtp replace: name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf" regexp: "^#FromLineOverride=.*$" replace: "FromLineOverride=YES" + when: name != 'php73' - name: Configure ssmtp replace: name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf" regexp: "^hostname=.*" replace: "hostname={{ansible_fqdn}}" + when: name != 'php73' + +- name: Configure opensmtpd + template: + src: smtpd.conf.j2 + dest: "/var/lib/lxc/{{name}}/rootfs/etc/smtpd.conf" + mode: "0644" + notify: "Restart opensmtpd" + when: name == 'php73' + +- name: Configure mailname + template: + src: mailname.j2 + dest: "/var/lib/lxc/{{name}}/rootfs/etc/mailname" + notify: "Restart opensmtpd" + when: name == 'php73' - name: Configure timezone copy: diff --git a/lxc-php/templates/smtpd.conf.j2 b/lxc-php/templates/smtpd.conf.j2 new file mode 100644 index 00000000..8458d4b4 --- /dev/null +++ b/lxc-php/templates/smtpd.conf.j2 @@ -0,0 +1,14 @@ +# This is the smtpd server system-wide configuration file. +# See smtpd.conf(5) for more information. + +# To accept external mail, replace with: listen on all +#listen on localhost + +# If you edit the file, you have to run "smtpctl update table aliases" +table aliases file:/etc/aliases + +# Uncomment the following to accept external mail for domain "example.org" +#accept from any for domain "example.org" alias deliver to mbox + +accept for local alias deliver to mbox +accept for any relay via "smtp://127.0.0.1" diff --git a/lxc/defaults/main.yml b/lxc/defaults/main.yml index e7e1c1ff..485f2784 100644 --- a/lxc/defaults/main.yml +++ b/lxc/defaults/main.yml @@ -3,7 +3,7 @@ lxc_unprivilegied_containers: false # Network type to use. See lxc.container.conf(5). -lxc_network_type: "none" +lxc_net_0_type: "none" # Partition to bind mount into containers. lxc_mount_part: "/home" @@ -15,4 +15,6 @@ lxc_mount_part: "/home" # release: jessie # - name: php70 # release: stretch +# - name: php73 +# release: buster lxc_containers: [] diff --git a/lxc/tasks/create-container.yml b/lxc/tasks/create-container.yml index 6faeeabf..c022b0fb 100644 --- a/lxc/tasks/create-container.yml +++ b/lxc/tasks/create-container.yml @@ -5,7 +5,7 @@ register: container_exists - name: Create container - command: "lxc-create --name {{name}} --template debian --bdev dir --logfile /var/log/lxc/lxc-{{name}}.log --logpriority INFO -- --arch amd64 --release {{release}}" + command: "lxc-create --name {{name}} --template download --bdev dir --logfile /var/log/lxc/lxc-{{name}}.log --logpriority INFO -- --dist debian --release {{release}} --arch amd64" when: container_exists.stdout_lines == [] #- name: Create container @@ -13,21 +13,25 @@ # name: "{{name}}" # container_log: true # template: download -# state: stopped +# state: started # template_options: "--release {{release}}" +# when: container_exists.stdout_lines == [] - name: Disable network configuration inside container replace: name: "/var/lib/lxc/{{name}}/rootfs/etc/default/networking" regexp: "^#CONFIGURE_INTERFACES=yes" replace: CONFIGURE_INTERFACES=no - when: lxc_network_type == "none" + when: lxc_net_0_type == "none" - name: Disable interface shut down on halt inside container lineinfile: name: "/var/lib/lxc/{{name}}/rootfs/etc/default/halt" line: "NETDOWN=no" - when: lxc_network_type == "none" and release != "stretch" + when: + - lxc_net_0_type == "none" + - release != "stretch" + - release != "buster" - name: Make the container poweroff on SIGPWR (sent by lxc-stop) on jessie file: @@ -49,7 +53,9 @@ name: "/var/lib/lxc/{{name}}/rootfs/etc/rc.local" line: "chmod 755 /dev" insertbefore: "^exit 0$" - when: release != 'stretch' + when: + - release != 'stretch' + - release != 'buster' - name: Check if container is running command: "lxc-ls --running {{name}}" diff --git a/lxc/templates/default.conf b/lxc/templates/default.conf index 94e7c1d6..f388422a 100644 --- a/lxc/templates/default.conf +++ b/lxc/templates/default.conf @@ -7,7 +7,7 @@ lxc.id_map = g 0 100000 10000 {% endif %} # Set the default network virtualization method. -lxc.network.type = {{lxc_network_type}} +lxc.net.0.type = {{lxc_net_0_type}} {% if lxc_mount_part %} # Mount {{lxc_mount_part}} into containers. @@ -16,7 +16,7 @@ lxc.mount.entry = {{lxc_mount_part}} {{lxc_mount_part |replace('/', '')}} none b {% endif %} # Only one tty is enough. # This require that you disabled others tty ([2-6]) in systemd. -lxc.tty = 1 +lxc.tty.max = 1 # Run 64bits containers lxc.arch = x86_64 diff --git a/webapps/evoadmin-web/tasks/web.yml b/webapps/evoadmin-web/tasks/web.yml index 1009960a..9c0fe311 100644 --- a/webapps/evoadmin-web/tasks/web.yml +++ b/webapps/evoadmin-web/tasks/web.yml @@ -57,7 +57,7 @@ - "templates/evoadmin-web/config.local.{{ inventory_hostname }}.php.j2" - "templates/evoadmin-web/config.local.{{ host_group }}.php.j2" - "templates/evoadmin-web/config.local.php.j2" - - "config.local.conf.j2" + - "config.local.php.j2" register: evoadmin_config_local_php_template - name: Enable proxy_fcgi