Skip to content

Commit 6a0b0e8

Browse files
committed
Check if memcache is compatible with the PHP version
1 parent 45fa4bf commit 6a0b0e8

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/roles/apache-php/tasks/php-redhat8.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,34 @@
8484
path: /usr/lib64/php/modules/memcached.so
8585
register: memcached_so
8686

87-
- name: Reinstall memcached if .so file missing
87+
- name: Check if memcached extension loads without errors
88+
shell: php -d display_errors=on -d display_startup_errors=on -m 2>&1 | grep -q "^memcached$"
89+
register: memcached_loads
90+
failed_when: false
91+
changed_when: false
92+
93+
- name: Reinstall memcached if missing or incompatible
8894
block:
95+
- name: Remove old memcached.so before reinstalling
96+
file:
97+
path: /usr/lib64/php/modules/memcached.so
98+
state: absent
99+
89100
- name: Uninstall existing memcached PECL package
90101
shell: pecl uninstall memcached
91102
ignore_errors: true
92103

93-
# --configureoptions parameter is not supported in all versions of pecl.
104+
# --configureoptions parameter is not supported in all versions of pecl.
94105
- name: Install memcached PECL packages
95106
shell: >
96107
printf 'no\nno\nno\nno\nno\nno\nno\nyes\nyes\n' |
97108
pecl install memcached
98-
when: not memcached_so.stat.exists
109+
when: not memcached_so.stat.exists or memcached_loads.rc != 0
99110

100111
- name: Trigger restart if memcached was reinstalled
101112
debug:
102113
msg: "Memcached was reinstalled"
103-
changed_when: not memcached_so.stat.exists
114+
changed_when: not memcached_so.stat.exists or memcached_loads.rc != 0
104115
notify:
105116
- restart apache
106117
- restart php-fpm

0 commit comments

Comments
 (0)