feat: install PHP and Composer

This commit is contained in:
Emmanuel BENOîT 2025-01-06 09:11:00 +01:00
parent 6cdd4e7d90
commit 5f569895e1
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg

View file

@ -69,6 +69,21 @@
asdf_version: 0.15.0 asdf_version: 0.15.0
# Version of Python to install using pyenv # Version of Python to install using pyenv
python_version: 3.11.11 python_version: 3.11.11
# Version of PHP to install from the Sury repos
php_version: "8.4"
# Version of Composer to install
composer_version: 2.8.4
# PHP extensions to install
php_extensions:
- curl
- gd
- ldap
- mysql
- pgsql
- mbstring
- mcrypt
- xml
- zip
# Tools that will be installed using asdf # Tools that will be installed using asdf
asdf_tools: asdf_tools:
- java - java
@ -182,14 +197,39 @@
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
> /etc/apt/sources.list.d/docker.list > /etc/apt/sources.list.d/docker.list
# Prepare for PHP installation
- name: Download Sury keyring
ansible.builtin.get_url:
url: https://packages.sury.org/debsuryorg-archive-keyring.deb
dest: /tmp
- name: Install Sury keyring
ansible.builtin.apt:
deb: /tmp/debsuryorg-archive-keyring.deb
state: present
- name: Add Sury source
ansible.builtin.copy:
content: |
deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] http://packages.sury.org/php/ {{ ansible_distribution_release }} main
dest: /etc/apt/sources.list.d/php.list
# Install various required packages # Install various required packages
- name: Remove unnecessary packages - name: Remove unnecessary packages
ansible.builtin.command: ansible.builtin.command:
cmd: apt-get autoremove -y cmd: apt-get autoremove -y
- name: Install packages - name: Install packages
vars:
php_packages: >-
{% set packages = []
%}{% for ext in php_extensions + [ 'cli' ]
%}{% set _ = packages.append( "php" + php_version + "-" + ext )
%}{% endfor
%}{{ packages }}
ansible.builtin.apt: ansible.builtin.apt:
update_cache: true update_cache: true
name: "{{ debian_packages }}" name: >-
{{ debian_packages + php_packages }}
# Keyboard / locale configuration # Keyboard / locale configuration
- name: Copy keyboard config - name: Copy keyboard config
@ -674,3 +714,31 @@
set -e ; set -e ;
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustinit.sh ; curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustinit.sh ;
sh /tmp/rustinit.sh -y -c rust-analyzer,rust-src,rust-analysis sh /tmp/rustinit.sh -y -c rust-analyzer,rust-src,rust-analysis
# Install Composer
- name: Download composer
ansible.builtin.get_url:
url: https://getcomposer.org/download/{{ composer_version }}/composer.phar
dest: /home/vagrant/.local/bin/composer
mode: "0755"
- name: Create composer config directory
ansible.builtin.file:
path: /home/vagrant/.config/composer
state: directory
mode: "0755"
- name: Fetch composer public keys
loop:
- source: https://composer.github.io/snapshots.pub
dest: keys.dev.pub
- source: https://composer.github.io/releases.pub
dest: keys.tags.pub
ansible.builtin.get_url:
url: "{{ item.source }}"
dest: /home/vagrant/.config/composer/{{ item.dest }}
- name: Run composer self-diagnostic
ansible.builtin.command:
cmd: /home/vagrant/.local/bin/composer diagnose -n
changed_when: false