From 07f4f8a509ce11cf9fe99190f359adab349eccac Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Thu, 17 Oct 2024 17:10:57 +0100 Subject: [PATCH] check opcache.jit_buffer_size is 0 or >= 40960 --- defaults/main.yml | 8 ++++---- meta/argument_specs.yml | 17 +++++++++++++++++ tasks/check_vars.yml | 22 ++++++++++++++++++++++ vars/main.yml | 6 ++++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 368df68..37e6de2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -78,7 +78,7 @@ php_config: "opcache.enable": "1" "opcache.interned_strings_buffer": "64" # "opcache.jit": "tracing" - # "opcache.jit_buffer_size": "256" + # "opcache.jit_buffer_size": "40961" # minimum size is 40961 bytes "opcache.jit": "0" "opcache.jit_buffer_size": "0" "opcache.max_accelerated_files": "100000" @@ -188,7 +188,7 @@ php_config: "opcache.enable": "1" "opcache.interned_strings_buffer": "64" # "opcache.jit": "tracing" - # "opcache.jit_buffer_size": "256" + # "opcache.jit_buffer_size": "40961" # minimum size is 40961 bytes "opcache.jit": "0" "opcache.jit_buffer_size": "0" "opcache.max_accelerated_files": "100000" @@ -298,7 +298,7 @@ php_config: "opcache.enable": "1" "opcache.interned_strings_buffer": "64" # "opcache.jit": "tracing" - # "opcache.jit_buffer_size": "256" + # "opcache.jit_buffer_size": "40961" # minimum size is 40961 bytes "opcache.jit": "0" "opcache.jit_buffer_size": "0" "opcache.max_accelerated_files": "100000" @@ -408,7 +408,7 @@ php_config: "opcache.enable": "1" "opcache.interned_strings_buffer": "64" # "opcache.jit": "tracing" - # "opcache.jit_buffer_size": "256" + # "opcache.jit_buffer_size": "40961" # minimum size is 40961 bytes "opcache.jit": "0" "opcache.jit_buffer_size": "0" "opcache.max_accelerated_files": "100000" diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index bf82df3..aaf7f34 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -66,6 +66,23 @@ argument_specs: elements: str required: false description: A generated list of php configuration that is not absent. + php_conf_opcache_jit_buffer_sizes: + type: list + elements: str + required: false + description: A generated list of the opcache.jit_buffer_sizes. + php_conf_opcache_jit_buffer_sizes_jmespath_query: + type: str + required: true + description: A JMESPath query for the opcache.jit_buffer_sizes. +# php_conf_opcache_jit_buffer_sizes_jmespath_query1: +# type: str +# required: true +# description: A JMESPath query for the opcache.jit_buffer_sizes. +# php_conf_opcache_jit_buffer_sizes_jmespath_query2: +# type: str +# required: true +# description: A JMESPath query for the opcache.jit_buffer_sizes. php_conf_pool_files_not_absent: type: list elements: str diff --git a/tasks/check_vars.yml b/tasks/check_vars.yml index f3b78c9..a2085ca 100644 --- a/tasks/check_vars.yml +++ b/tasks/check_vars.yml @@ -170,6 +170,28 @@ fail_msg: "Non unique PHP-FPM pool names:{% for php_pool_name in php_pool_names_not_absent %} {{ php_pool_name }}{% endfor %}, please run the role once with --extra-vars='php_fpm_pool_check_fail=false' to fix this" when: php_fpm_pool_check_fail | bool + - name: Debug php_conf_opcache_jit_buffer_sizes_jmespath_query + ansible.builtin.debug: + var: php_conf_opcache_jit_buffer_sizes_jmespath_query + verbosity: "{% if ansible_check_mode | bool or ansible_diff_mode | bool %}1{% else %}2{% endif %}" + + - name: Debug php_conf_opcache_jit_buffer_sizes + ansible.builtin.debug: + var: php_conf_opcache_jit_buffer_sizes + verbosity: "{% if ansible_check_mode | bool or ansible_diff_mode | bool %}1{% else %}2{% endif %}" + + # https://github.com/composer/composer/issues/12153#issuecomment-2419452358 + - name: Check that the opcache.jit_buffer_size is set to 0 or is >= 40961 + ansible.builtin.assert: + that: + - php_conf_opcache_jit_buffer_size is ansible.builtin.regex('^[0-9]{1,20}$') + - ( php_conf_opcache_jit_buffer_size == "0" ) or ( php_conf_opcache_jit_buffer_size >= "40961" ) + quiet: "{% if ansible_verbosity == 0 %}true{% else %}false{% endif %}" + loop: "{{ php_conf_opcache_jit_buffer_sizes }}" + loop_control: + loop_var: php_conf_opcache_jit_buffer_size + when: php_conf_opcache_jit_buffer_sizes != [] + # TODO sapis are required when php_modules are set to be present tags: diff --git a/vars/main.yml b/vars/main.yml index 7f131c2..9040d5c 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -96,6 +96,12 @@ php_conf_pool_files_not_absent: "{{ php_config | community.general.json_query('s # cat defaults/main.yml | yq -o=json | jp "php_config[?state=='present'].files[]|[?state!='absent']" php_conf_not_absent: "{{ php_config | community.general.json_query('[?state==`present`].files[]|[?state!=`absent`]') }}" +# PHP opcache jit buffer sizes +# cat defaults/main.yml | yq -o=json | \ +# jp "php_config[?state=='present'].files[]|[?state!='absent'].conf.opcache.[\"opcache.jit_buffer_size\"]|[]" +php_conf_opcache_jit_buffer_sizes_jmespath_query: '[?state==`present`].files[]|[?state!=`absent`].conf.opcache.["opcache.jit_buffer_size"]|[]' +php_conf_opcache_jit_buffer_sizes: "{{ php_config | community.general.json_query(php_conf_opcache_jit_buffer_sizes_jmespath_query) }}" + # PHP modules configuration absent # cat defaults/main.yml | yq -o=json | jp "sort(php_modules[?state=='absent'].version)" php_mods_ver_absent: "{{ php_modules | community.general.json_query('sort([?state==`absent`].version)') }}" -- GitLab