Skip to content
Snippets Groups Projects
Commit 141aa444 authored by Chris Croome's avatar Chris Croome
Browse files

Local fact script updated

parent b037a41d
No related branches found
No related tags found
1 merge request!1Merge Sury
Pipeline #22462 failed
......@@ -3,17 +3,15 @@ galaxy_info:
role_name: php
author: Chris Croome
namespace: chriscroome
description: Ansible role for installing and configuring PHP on Debian
description: Ansible role for installing and configuring PHP on Debian Bullseye and Buster
company: Webarchitects Co-operative
license: GNU General Public License v3.0 (GPLv3)
min_ansible_version: 2.11
platforms:
- name: Debian
versions:
- bookworm
- bullseye
- buster
- stretch
galaxy_tags:
- debian
- php
......
......@@ -19,11 +19,11 @@
- php_opcache_validate_root | type_debug == "bool"
quiet: "{% if ansible_verbosity == 0 %}true{% else %}false{% endif %}"
- name: Check that the distro is Debian Bookworm, Bullseye, Buster or Stretch or Ubuntu Jammy, Focal or Bionic
- name: Check that the distro is Debian Bullseye or Buster
ansible.builtin.assert:
that:
- ansible_distribution_release is defined
- ansible_distribution_release is regex("^stretch|buster|bullseye|bookworm|focal|bionic|jammy$")
- ansible_distribution_release is regex("^buster|bullseye$")
quiet: "{% if ansible_verbosity == 0 %}true{% else %}false{% endif %}"
fail_msg: "The Linux distro {{ ansible_distribution }} {{ ansible_distribution_release }} is not supported by this role"
......
......@@ -5,6 +5,7 @@
- name: Required packages present
ansible.builtin.apt:
pkg:
- aptitude
- jo
state: present
......
......@@ -10,6 +10,7 @@
- name: Include apt repo config for Sury PHP packages
ansible.builtin.include_tasks: apt.yml
when: php_sury | bool
- name: PHP versions absent
block:
......
......@@ -2,43 +2,54 @@
# {{ ansible_managed }}
set -euo pipefail
APTITUDE="{{ php_aptitude }}"
PHPQUERY="{{ php_phpquery }}"
if [[ -f "${PHPQUERY}" ]] && [[ -f "/usr/lib/php/php-helper" ]]
if [[ -f "${APTITUDE}" ]]
then
declare -a versions=()
readarray -t versions < <("${PHPQUERY}" -V | sort -V)
jo state=present versions=$(
jo $(
for v in "${versions[@]}"
do
declare -a mods_available=()
readarray -t mods_available < <("${PHPQUERY}" -v "${v}" -M | sort)
declare -a sapis=()
readarray -t sapis < <("${PHPQUERY}" -v "${v}" -S | sort)
echo ${v}=$(
jo state=present mods_available=$(jo -a "${mods_available[@]}") $(
for s in "${sapis[@]}"
do
declare -a mods_enabled=()
for m in "${mods_available[@]}"
do
if "${PHPQUERY}" -v "${v}" -s "${s}" -m "${m}" -q
then
mods_enabled=(${mods_enabled[@]} ${m})
fi
done
echo sapis["${s}"]=$(
jo state=present mods_enabled=$(
jo -e -a "${mods_enabled[@]}"
)
declare -a packages=()
readarray -t packages < <(aptitude -q=99 search '~i!~M php' -F '%p')
if [[ "${#packages[@]}" == 0 ]]
then
jo state=absent
else
if [[ -f "${PHPQUERY}" ]]
then
declare -a versions=()
readarray -t versions < <("${PHPQUERY}" -V | sort -V)
jo state=present packages=$(jo -e -a "${packages[@]}") versions=$(i
jo $(
for v in "${versions[@]}"
do
declare -a mods_available=()
readarray -t mods_available < <("${PHPQUERY}" -v "${v}" -M | sort)
declare -a sapis=()
readarray -t sapis < <("${PHPQUERY}" -v "${v}" -S | sort)
echo ${v}=$(
jo state=present mods_available=$(jo -a "${mods_available[@]}") $(
for s in "${sapis[@]}"
do
declare -a mods_enabled=()
for m in "${mods_available[@]}"
do
if "${PHPQUERY}" -v "${v}" -s "${s}" -m "${m}" -q
then
mods_enabled=(${mods_enabled[@]} ${m})
fi
done
echo sapis["${s}"]=$(
jo state=present mods_enabled=$(
jo -e -a "${mods_enabled[@]}"
)
)
done
)
done
)
)
done
)
)
else
jo state=absent
fi
done
)
)
else
jo state=absent
fi
fi
fi
......@@ -15,5 +15,4 @@ Pin-Priority: 100
{% endfor %}
{% endif %}
# vim: ft=debsources
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment