Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate templates for CLI php.ini? #140

Open
jonpugh opened this issue Jul 8, 2016 · 15 comments
Open

Separate templates for CLI php.ini? #140

jonpugh opened this issue Jul 8, 2016 · 15 comments
Labels

Comments

@jonpugh
Copy link

jonpugh commented Jul 8, 2016

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!

@thom8
Copy link

thom8 commented Jul 10, 2016

I'd also like to only override the default php.ini with a simple include -- #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.

@thom8
Copy link

thom8 commented Jul 10, 2016

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.

@thom8
Copy link

thom8 commented Jul 30, 2016

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.

@geerlingguy
Copy link
Owner

It looks like downstream issue geerlingguy/ansible-role-php-xdebug#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).

@thom8
Copy link

thom8 commented Aug 2, 2016

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

@thom8
Copy link

thom8 commented Aug 4, 2016

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?

#93 (comment)

@jradtilbrook
Copy link

jradtilbrook commented Jan 11, 2017

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.

@ndench
Copy link

ndench commented Sep 13, 2018

@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.

@stale
Copy link

stale bot commented Mar 6, 2020

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.

@stale stale bot added the stale label Mar 6, 2020
@colinodell
Copy link

I'm currently using the workaround @ndench proposed. It's not a perfect solution but it works for now.

@stale
Copy link

stale bot commented Mar 6, 2020

This issue is no longer marked for closure.

@stale stale bot removed the stale label Mar 6, 2020
@stale
Copy link

stale bot commented Jun 4, 2020

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.

@stale stale bot added the stale label Jun 4, 2020
@colinodell
Copy link

Bumping this out of the stale state as this is still something I have to work around and would find valuable to have.

@stale
Copy link

stale bot commented Jun 4, 2020

This issue is no longer marked for closure.

@stale stale bot removed the stale label Jun 4, 2020
colans pushed a commit to consensus-enterprises/ansible-role-php that referenced this issue Oct 8, 2021
colans pushed a commit to consensus-enterprises/ansible-role-php that referenced this issue Oct 8, 2021
@colans
Copy link

colans commented Oct 8, 2021

Please review my just-submitted MR, which should work for Debian-based OSes at least: #347.

colans pushed a commit to consensus-enterprises/ansible-role-php that referenced this issue Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants