From 44f6d2922954c823d06d5b70ee454937ed4ecc7a Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 6 Mar 2023 12:45:05 +0200 Subject: [PATCH 1/3] change_php_detection_for_fastcgi_and_cachetool --- roles/cache_clear/cache_clear-opcache/tasks/main.yml | 5 +++-- roles/cli/cachetool/tasks/main.yml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/cache_clear/cache_clear-opcache/tasks/main.yml b/roles/cache_clear/cache_clear-opcache/tasks/main.yml index 57feac51..2f3524cc 100644 --- a/roles/cache_clear/cache_clear-opcache/tasks/main.yml +++ b/roles/cache_clear/cache_clear-opcache/tasks/main.yml @@ -1,12 +1,13 @@ --- - name: Get latest php installed ansible.builtin.shell: - cmd: "ls /etc/php/ | tail -1" + cmd: cmd: "netstat -anp | grep php-fpm | grep tcp | awk '{print $4}' | cut -d: -f2 | sort -r | head -n1 | awk '{print substr($0, length-1)}'" register: _php_version + become: yes - name: Set cachetool adapter. ansible.builtin.set_fact: - _cachetool_adapter: "{{ cache_clear_opcache.adapter | default('--fcgi=127.0.0.1:90' + _php_version.stdout | replace('.','')) }}" + _cachetool_adapter: "{{ cache_clear_opcache.adapter | default('--fcgi=127.0.0.1:90' + _php_version.stdout) }}" - name: Clear opcache. command: diff --git a/roles/cli/cachetool/tasks/main.yml b/roles/cli/cachetool/tasks/main.yml index f0f05b28..6da9bea1 100644 --- a/roles/cli/cachetool/tasks/main.yml +++ b/roles/cli/cachetool/tasks/main.yml @@ -17,8 +17,9 @@ block: - name: Get latest php installed ansible.builtin.shell: - cmd: "ls /etc/php/ | tail -1 | sed -e 's/\\.//g'" + cmd: "netstat -anp | grep php-fpm | grep tcp | awk '{print $4}' | cut -d: -f2 | sort -r | head -n1 | awk '{print substr($0, length-1)}'" register: _php_version_str + become: yes - name: Download latest cachetool installer if PHP is 8.1 or newer. ansible.builtin.get_url: From b7604114d749680ed7490cd5cd1a8914f41dda6b Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 6 Mar 2023 12:46:49 +0200 Subject: [PATCH 2/3] fix_typo --- roles/cache_clear/cache_clear-opcache/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/cache_clear/cache_clear-opcache/tasks/main.yml b/roles/cache_clear/cache_clear-opcache/tasks/main.yml index 2f3524cc..8ee697c7 100644 --- a/roles/cache_clear/cache_clear-opcache/tasks/main.yml +++ b/roles/cache_clear/cache_clear-opcache/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Get latest php installed ansible.builtin.shell: - cmd: cmd: "netstat -anp | grep php-fpm | grep tcp | awk '{print $4}' | cut -d: -f2 | sort -r | head -n1 | awk '{print substr($0, length-1)}'" + cmd: "netstat -anp | grep php-fpm | grep tcp | awk '{print $4}' | cut -d: -f2 | sort -r | head -n1 | awk '{print substr($0, length-1)}'" register: _php_version become: yes From c06883b78b08d07f10158ca6b76db08e1cc12b9c Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 6 Mar 2023 19:01:12 +0200 Subject: [PATCH 3/3] change_php_detection_for_fastcgi_and_cachetool_no_sudo --- roles/cache_clear/cache_clear-opcache/tasks/main.yml | 5 ++--- roles/cli/cachetool/tasks/main.yml | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/roles/cache_clear/cache_clear-opcache/tasks/main.yml b/roles/cache_clear/cache_clear-opcache/tasks/main.yml index 8ee697c7..d7c9f6e2 100644 --- a/roles/cache_clear/cache_clear-opcache/tasks/main.yml +++ b/roles/cache_clear/cache_clear-opcache/tasks/main.yml @@ -1,13 +1,12 @@ --- - name: Get latest php installed ansible.builtin.shell: - cmd: "netstat -anp | grep php-fpm | grep tcp | awk '{print $4}' | cut -d: -f2 | sort -r | head -n1 | awk '{print substr($0, length-1)}'" + cmd: 'ls -1 /etc/php/ | while read ver; do if [ -d "/etc/php/$ver/fpm" ]; then echo "$ver"; fi; done | tail -1' register: _php_version - become: yes - name: Set cachetool adapter. ansible.builtin.set_fact: - _cachetool_adapter: "{{ cache_clear_opcache.adapter | default('--fcgi=127.0.0.1:90' + _php_version.stdout) }}" + _cachetool_adapter: "{{ cache_clear_opcache.adapter | default('--fcgi=127.0.0.1:90' + _php_version.stdout | replace('.','')) }}" - name: Clear opcache. command: diff --git a/roles/cli/cachetool/tasks/main.yml b/roles/cli/cachetool/tasks/main.yml index 6da9bea1..2e2a49d1 100644 --- a/roles/cli/cachetool/tasks/main.yml +++ b/roles/cli/cachetool/tasks/main.yml @@ -17,9 +17,8 @@ block: - name: Get latest php installed ansible.builtin.shell: - cmd: "netstat -anp | grep php-fpm | grep tcp | awk '{print $4}' | cut -d: -f2 | sort -r | head -n1 | awk '{print substr($0, length-1)}'" + cmd: 'ls -1 /etc/php/ | while read ver; do if [ -d "/etc/php/$ver/fpm" ]; then echo "$ver"; fi; done | tail -1 | sed -e "s/\\.//g"' register: _php_version_str - become: yes - name: Download latest cachetool installer if PHP is 8.1 or newer. ansible.builtin.get_url: