phpmyadmin as utility
This commit is contained in:
parent
f27b289e12
commit
ecd2f7aa61
@ -2,8 +2,15 @@
|
||||
# Lenvi: Central Configuration for Your Development Environment
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# Optional developer utilities
|
||||
utilities:
|
||||
phpmyadmin:
|
||||
enabled: true
|
||||
domain: "pma.lenvi.local" # Or whatever you prefer
|
||||
php_version: "8.2"
|
||||
|
||||
# 1. Set the global database engine.
|
||||
db_engine: "mariadb"
|
||||
db_engine: "mariadb" # mariadb, mysql or postgresql
|
||||
|
||||
# 2. Define the global database credentials.
|
||||
db_credentials:
|
||||
|
@ -17,4 +17,6 @@
|
||||
- role: php
|
||||
- role: composer
|
||||
- role: nginx
|
||||
- role: phpmyadmin
|
||||
when: utilities.phpmyadmin.enabled is defined and utilities.phpmyadmin.enabled
|
||||
- role: projects
|
57
roles/phpmyadmin/tasks/main.yml
Normal file
57
roles/phpmyadmin/tasks/main.yml
Normal file
@ -0,0 +1,57 @@
|
||||
---
|
||||
- name: Define Apache packages to manage
|
||||
ansible.builtin.set_fact:
|
||||
apache_packages:
|
||||
- apache2
|
||||
- apache2-bin
|
||||
- apache2-data
|
||||
- apache2-utils
|
||||
|
||||
# This block runs when phpmyadmin is enabled
|
||||
- name: "Enable phpMyAdmin"
|
||||
when: utilities.phpmyadmin.enabled | default(false)
|
||||
block:
|
||||
- name: "Place a 'hold' on Apache packages to prevent installation"
|
||||
ansible.builtin.dpkg_selections:
|
||||
name: "{{ item }}"
|
||||
selection: hold
|
||||
loop: "{{ apache_packages }}"
|
||||
|
||||
- name: "Install phpMyAdmin from APT repository"
|
||||
ansible.builtin.apt:
|
||||
name: phpmyadmin
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: "Create Nginx config for phpMyAdmin using the main project template"
|
||||
ansible.builtin.template:
|
||||
src: ../projects/templates/nginx-site.conf.j2
|
||||
dest: "/etc/nginx/conf.d/{{ utilities.phpmyadmin.domain }}.conf"
|
||||
vars:
|
||||
project:
|
||||
domain: "{{ utilities.phpmyadmin.domain }}"
|
||||
document_root: "/usr/share/phpmyadmin"
|
||||
php_version: "{{ utilities.phpmyadmin.php_version }}"
|
||||
notify: Reload Nginx
|
||||
|
||||
# This block runs when phpmyadmin is disabled or not defined
|
||||
- name: "Disable phpMyAdmin"
|
||||
when: not (utilities.phpmyadmin.enabled | default(false))
|
||||
block:
|
||||
- name: "Remove the Nginx config for phpMyAdmin"
|
||||
ansible.builtin.file:
|
||||
path: "/etc/nginx/conf.d/{{ utilities.phpmyadmin.domain }}.conf"
|
||||
state: absent
|
||||
notify: Reload Nginx
|
||||
|
||||
- name: "Remove the phpMyAdmin package"
|
||||
ansible.builtin.apt:
|
||||
name: phpmyadmin
|
||||
state: absent
|
||||
autoremove: yes
|
||||
|
||||
- name: "Release the 'hold' on Apache packages"
|
||||
ansible.builtin.dpkg_selections:
|
||||
name: "{{ item }}"
|
||||
selection: install
|
||||
loop: "{{ apache_packages }}"
|
Loading…
x
Reference in New Issue
Block a user