From 736ed26036e3df5eef133a6a3aeed6774c7e3327 Mon Sep 17 00:00:00 2001 From: Brice Waegeneire Date: Tue, 31 Oct 2023 17:44:55 +0100 Subject: [PATCH] lxc-php: Add variable 'lxc_php_container_name' --- lxc-php/defaults/main.yml | 1 + lxc-php/tasks/mail_opensmtpd.yml | 8 ++++---- lxc-php/tasks/mail_ssmtp.yml | 6 +++--- lxc-php/tasks/main.yml | 8 ++++---- lxc-php/tasks/misc.yml | 14 +++++++------- lxc-php/tasks/php73.yml | 6 +++--- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/lxc-php/defaults/main.yml b/lxc-php/defaults/main.yml index c0612f4e..4f2562de 100644 --- a/lxc-php/defaults/main.yml +++ b/lxc-php/defaults/main.yml @@ -13,6 +13,7 @@ php_conf_mysql_socket_dir: /mysqld php_conf_mysql_default_socket: "{{ php_conf_mysql_socket_dir }}/mysqld.sock" lxc_php_version: Null +lxc_php_container_name: "php{{ lxc_php_version }}" lxc_php_container_releases: php56: "jessie" diff --git a/lxc-php/tasks/mail_opensmtpd.yml b/lxc-php/tasks/mail_opensmtpd.yml index 35d0e75b..f532e8e8 100644 --- a/lxc-php/tasks/mail_opensmtpd.yml +++ b/lxc-php/tasks/mail_opensmtpd.yml @@ -1,11 +1,11 @@ --- -- name: "{{ lxc_php_version }} - Install opensmtpd" +- name: "{{ lxc_php_container_name }} - Install opensmtpd" community.general.lxc_container: - name: "{{ lxc_php_version }}" + name: "{{ lxc_php_container_name }}" container_command: "DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y opensmtpd" -- name: "{{ lxc_php_version }} - Configure opensmtpd (in the container)" +- name: "{{ lxc_php_container_name }} - Configure opensmtpd (in the container)" ansible.builtin.template: src: smtpd.conf.j2 dest: "{{ lxc_rootfs }}/etc/smtpd.conf" @@ -14,7 +14,7 @@ when: lxc_php_container_releases[lxc_php_version] in ["jessie", "stretch", "buster"] -- name: "{{ lxc_php_version }} - Configure opensmtpd (in the container)" +- name: "{{ lxc_php_container_name }} - Configure opensmtpd (in the container)" ansible.builtin.template: src: smtpd.conf.bullseye.j2 dest: "{{ lxc_rootfs }}/etc/smtpd.conf" diff --git a/lxc-php/tasks/mail_ssmtp.yml b/lxc-php/tasks/mail_ssmtp.yml index 07b54118..62066b2e 100644 --- a/lxc-php/tasks/mail_ssmtp.yml +++ b/lxc-php/tasks/mail_ssmtp.yml @@ -1,11 +1,11 @@ --- -- name: "{{ lxc_php_version }} - Install ssmtp" +- name: "{{ lxc_php_container_name }} - Install ssmtp" community.general.lxc_container: - name: "{{ lxc_php_version }}" + name: "{{ lxc_php_container_name }}" container_command: "DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends --yes --force-yes ssmtp " -- name: "{{ lxc_php_version }} - Configure ssmtp" +- name: "{{ lxc_php_container_name }} - Configure ssmtp" ansible.builtin.template: src: ssmtp.conf.j2 dest: "{{ lxc_rootfs }}/etc/ssmtp/ssmtp.conf" diff --git a/lxc-php/tasks/main.yml b/lxc-php/tasks/main.yml index 035bfe15..13622b9e 100644 --- a/lxc-php/tasks/main.yml +++ b/lxc-php/tasks/main.yml @@ -9,16 +9,16 @@ name: evolix/lxc vars: lxc_containers: - - { name: "{{ lxc_php_version }}", release: "{{ lxc_php_container_releases[lxc_php_version] }}" } + - { name: "{{ lxc_php_container_name }}", release: "{{ lxc_php_container_releases[lxc_php_version] }}" } when: lxc_php_version is defined - name: set LXC rootfs ansible.builtin.set_fact: - lxc_rootfs: "/var/lib/lxc/{{ lxc_php_version }}/rootfs" + lxc_rootfs: "/var/lib/lxc/{{ lxc_php_container_name }}/rootfs" -- name: "Update APT cache in container {{ lxc_php_version }}" +- name: "Update APT cache in container {{ lxc_php_container_name }}" community.general.lxc_container: - name: "{{ lxc_php_version }}" + name: "{{ lxc_php_container_name }}" container_command: "apt-get update" - ansible.builtin.import_tasks: "php56.yml" diff --git a/lxc-php/tasks/misc.yml b/lxc-php/tasks/misc.yml index 248aa8e2..7fc4575e 100644 --- a/lxc-php/tasks/misc.yml +++ b/lxc-php/tasks/misc.yml @@ -1,31 +1,31 @@ --- -- name: "{{ lxc_php_version }} - Configure timezone for the container" +- name: "{{ lxc_php_container_name }} - Configure timezone for the container" ansible.builtin.copy: remote_src: yes src: "/etc/timezone" dest: "{{ lxc_rootfs }}/etc/timezone" -- name: "{{ lxc_php_version }} - Ensure container's root directory is 755" +- name: "{{ lxc_php_container_name }} - Ensure container's root directory is 755" ansible.builtin.file: path: "{{ lxc_rootfs }}" state: directory mode: '0755' -- name: "{{ lxc_php_version }} - Configure mailname for the container" +- name: "{{ lxc_php_container_name }} - Configure mailname for the container" ansible.builtin.copy: content: "{{ evolinux_hostname }}.{{ evolinux_domain }}\n" dest: "{{ lxc_rootfs }}/etc/mailname" notify: "Restart opensmtpd" -- name: "{{ lxc_php_version }} - Install misc packages" +- name: "{{ lxc_php_container_name }} - Install misc packages" community.general.lxc_container: - name: "{{ lxc_php_version }}" + name: "{{ lxc_php_container_name }}" container_command: "DEBIAN_FRONTEND=noninteractive apt install -y cron logrotate git zip unzip" -- name: "{{ lxc_php_version }} - Add MySQL socket to container default mounts" +- name: "{{ lxc_php_container_name }} - Add MySQL socket to container default mounts" community.general.lxc_container: - name: "{{ lxc_php_version }}" + name: "{{ lxc_php_container_name }}" container_config: - "lxc.mount.entry = /run/mysqld {{ php_conf_mysql_socket_dir | replace('/', '', 1) }} none bind,create=dir 0 0" when: diff --git a/lxc-php/tasks/php73.yml b/lxc-php/tasks/php73.yml index ade67b97..1335e8a1 100644 --- a/lxc-php/tasks/php73.yml +++ b/lxc-php/tasks/php73.yml @@ -1,11 +1,11 @@ --- -- name: "{{ lxc_php_version }} - Install PHP packages" +- name: "{{ lxc_php_container_name }} - Install PHP packages" community.general.lxc_container: - name: "{{ lxc_php_version }}" + name: "{{ lxc_php_container_name }}" container_command: "DEBIAN_FRONTEND=noninteractive apt install -y php-fpm php-cli php-gd php-intl php-imap php-ldap php-mysql php-pgsql php-sqlite3 php-gettext php-curl php-ssh2 php-zip php-mbstring php-zip composer libphp-phpmailer" -- name: "{{ lxc_php_version }} - Copy evolinux PHP configuration" +- name: "{{ lxc_php_container_name }} - Copy evolinux PHP configuration" ansible.builtin.template: src: z-evolinux-defaults.ini.j2 dest: "{{ line_item }}"