Skip to content

Commit

Permalink
Refactor php version vars to be dynamic by default whilst allowing ov…
Browse files Browse the repository at this point in the history
…errides
  • Loading branch information
dalepgrant committed Jan 17, 2024
1 parent 36c8491 commit 5425faa
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 76 deletions.
4 changes: 2 additions & 2 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
vars:
params:
files:
- '{{ php_version }}.yml'
- '7.4.yml'
- '{{ php_version }}.yml' # e.g. 8.1.yml
- version-specific-defaults.yml
paths:
- "{{ playbook_dir }}/roles/php/vars/"

Expand Down
18 changes: 0 additions & 18 deletions roles/php/vars/7.4.yml

This file was deleted.

18 changes: 0 additions & 18 deletions roles/php/vars/8.0.yml

This file was deleted.

18 changes: 0 additions & 18 deletions roles/php/vars/8.1.yml

This file was deleted.

18 changes: 0 additions & 18 deletions roles/php/vars/8.2.yml

This file was deleted.

29 changes: 29 additions & 0 deletions roles/php/vars/version-specific-defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Set php version in group_vars/all/main.yml
#
# To override these defaults for a specific php version, duplicate this
# file to roles/php/vars/ and rename with your specific php version
# e.g. roles/php/vars/8.1.yml.
#
# You can then use e.g.
# php_extensions_default:
# php8.1-bcmath: "{{ apt_package_state }}"
#
php_extensions_default:
"php{{ php_version }}-bcmath": "{{ apt_package_state }}"
"php{{ php_version }}-cli": "{{ apt_package_state }}"
"php{{ php_version }}-curl": "{{ apt_package_state }}"
"php{{ php_version }}-dev": "{{ apt_package_state }}"
"php{{ php_version }}-fpm": "{{ apt_package_state }}"
"php{{ php_version }}-imagick": "{{ apt_package_state }}"
"php{{ php_version }}-intl": "{{ apt_package_state }}"
"php{{ php_version }}-mbstring": "{{ apt_package_state }}"
"php{{ php_version }}-mysql": "{{ apt_package_state }}"
"php{{ php_version }}-xml": "{{ apt_package_state }}"
"php{{ php_version }}-xmlrpc": "{{ apt_package_state }}"
"php{{ php_version }}-zip": "{{ apt_package_state }}"

php_memcached_packages:
"php{{ php_version }}-memcached": "{{ apt_package_state }}"

php_xdebug_package: "php{{ php_version }}-xdebug"
11 changes: 9 additions & 2 deletions roles/xdebug/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
---
- name: Include php{{ php_version }} related vars
include_vars: 'roles/php/vars/{{ php_version }}.yml'
- name: Import PHP version specific vars
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ php_version }}.yml' # e.g. 8.1.yml
- version-specific-defaults.yml
paths:
- "{{ playbook_dir }}/roles/php/vars/"

- name: Install Xdebug
apt:
Expand Down

0 comments on commit 5425faa

Please sign in to comment.