Open jonpugh opened 8 years ago
I'd also like to only override the default php.ini
with a simple include -- https://github.com/geerlingguy/ansible-role-php/pull/97
maybe allow php_cli_[conf var]
or php_fpm_[conf_var]
or in this case --
php_cli_memory_limit
would override php_memory_limit
for cli.
or even easier an override var per SAPI like
php_cli_conf:
memory_limit: -1
could create /etc/php/7.0/cli/conf.d/zzz_overrides.ini
on Ubuntu.
Might try to tackle a PR for this over the next week or so but would need to know the best approach for overriding php.ini
config for CLI on CentOS.
http://www.php.net/manual/en/configuration.file.php
Is using a /etc/php-cli.ini
the recommended way? would prefer not to duplicate all config but only set overrides.
It looks like downstream issue https://github.com/geerlingguy/ansible-role-php-xdebug/issues/34 will need this as well.
On CentOS/RHEL, where config is typically much simpler (e.g. don't have some crazy set of potentially dozens of config files), you would generally have one CLI config file, and /etc
would be where it resides (next to /etc/php.ini
).
From what I can tell there's no standard way to set only overrides for a single SAPI in CentOS, so whilst it's crazy to have dozens of config files they do provide an easy way to manage overrides.
In this case I'd only need to create and single conf file with 2 lines rather than duplicating the whole php conf file.
/etc/php/[php_version]/cli/conf.d/zzz_overrides.ini
php_memory_limit=-1
xdebug.default_enable=0
php --ini
CentOS 7 (PHP7)
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/...
...
Ubuntu 14.04 (PHP7)
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/...
...
CentOS does support php-cli.ini
but the issue is any config will still be overridden by /etc/php.d/..
so in the case of xdebug if we set xdebug.default_enable=0
in php-cli.ini
it could be overridden in /etc/php.d/xdebug.ini
so you could only disable xdebug globally not only in CLI.
We probably just need to have different configuration tasks for each OS..
@geerlingguy I'm happy to put together a PR but would it be accepted if this role primarily supports RHEL?
https://github.com/geerlingguy/ansible-role-php/issues/93#issuecomment-199838746
I'm fairly new to ansible, but wouldn't it be possible to use this role twice and pass two different variable files to it to configure fpm and cli differently? See my thinking below:
- host: xyz
roles:
- role: geerlingguy.php
include_vars: cli.yml
- role: geerlingguy.php
include_vars: fpm.yml
where cli.yml is something like:
php_conf_paths:
- /etc/php/7.0/cli
php_extension_conf_paths:
- /etc/php/7.0/cli/conf.d
php_expose_php: "On"
php_memory_limit: "-1"
php_session_save_handler: "files"
php_session_save_path: ""
and something similar for fpm setting the conf_paths
appropriately.
I suppose its not optimal because of some redundant duplicated tasks.
@jradtilbrook you solution should work if you're not also using geerlingguy.php-versions, because it sets php_conf_paths
with set_fact
which overrides most other ways to set a variable (see the docs). So I had to use set_fact
to ensure my second run off geerlingguy.php got the correct variables:
- hosts: xyz
roles:
- geerlingguy.php-versions
- geerlingguy.php
- hosts: xyz
pre_tasks:
- name: Override php cli config
set_fact: "{{ item.key }}={{item.value }}"
with_dict:
php_conf_paths: [/etc/php/7.2/cli]
php_memory_limit: -1
roles:
- geerlingguy.php
You're right it is a bit gross, since the roll is being run twice it kind of breaks idempotency. But I'm only running it once when I build an AMI/vagrant box so I'm not too worried.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
I'm currently using the workaround @ndench proposed. It's not a perfect solution but it works for now.
This issue is no longer marked for closure.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
Bumping this out of the stale
state as this is still something I have to work around and would find valuable to have.
This issue is no longer marked for closure.
Please review my just-submitted MR, which should work for Debian-based OSes at least: #347.
I think we should figure out a way to have either separate templates or separate variables for php.ini for CLI.
For example often there will be no memory limit for CLI.
Not sure the best approach here, but perhaps the CLI php.ini is an exception and we should add a separate template and variables for it?
Just a thought!