diff --git a/ansible/provision.yml b/ansible/provision.yml index 4eb733d..a74eb4b 100644 --- a/ansible/provision.yml +++ b/ansible/provision.yml @@ -69,6 +69,21 @@ asdf_version: 0.15.0 # Version of Python to install using pyenv 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 asdf_tools: - java @@ -182,14 +197,39 @@ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \ > /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 - name: Remove unnecessary packages ansible.builtin.command: cmd: apt-get autoremove -y - 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: update_cache: true - name: "{{ debian_packages }}" + name: >- + {{ debian_packages + php_packages }} # Keyboard / locale configuration - name: Copy keyboard config @@ -674,3 +714,31 @@ set -e ; 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 + + # 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