lxc-php: Add variable 'lxc_php_container_name'

This commit is contained in:
Brice Waegeneire 2023-10-31 17:44:55 +01:00
parent 96d15eb5aa
commit 736ed26036
6 changed files with 22 additions and 21 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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