Comments (10)
This role works correctly for me on Ansible of 2.4.0.0, when a variable php_packages
defined in group vars.
$ ansible --version
ansible 2.4.0.0
config file = /vagrant/cm/ansible.cfg
configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
vars:
php_version: '7.1'
php_packages:
- libpcre3-dev
- "php{{ php_version }}"
- "php{{ php_version }}-bcmath"
- "php{{ php_version }}-apcu"
- "php{{ php_version }}-cli"
- "php{{ php_version }}-common"
- "php{{ php_version }}-curl"
- "php{{ php_version }}-dev"
- "php{{ php_version }}-gd"
- "php{{ php_version }}-imap"
- "php{{ php_version }}-intl"
- "php{{ php_version }}-json"
- "php{{ php_version }}-mbstring"
- "php{{ php_version }}-mcrypt"
- "php{{ php_version }}-opcache"
- "php{{ php_version }}-soap"
- "php{{ php_version }}-xml"
TASK [geerlingguy.php-versions : Define PHP variables.] ************************
ok: [default] => (item={'key': u'php_extension_conf_paths', 'value': u'__php_extension_conf_paths'})
ok: [default] => (item={'key': u'php_fpm_daemon', 'value': u'__php_fpm_daemon'})
ok: [default] => (item={'key': u'php_uploadprogress_module_path', 'value': u'__php_uploadprogress_module_path'})
ok: [default] => (item={'key': u'php_xhprof_module_path', 'value': u'__php_xhprof_module_path'})
ok: [default] => (item={'key': u'php_fpm_pool_conf_path', 'value': u'__php_fpm_pool_conf_path'})
ok: [default] => (item={'key': u'php_conf_paths', 'value': u'__php_conf_paths'})
ok: [default] => (item={'key': u'php_xdebug_module_path', 'value': u'__php_xdebug_module_path'})
ok: [default] => (item={'key': u'php_pgsql_package', 'value': u'__php_pgsql_package'})
skipping: [default] => (item={'key': u'php_packages', 'value': u'__php_packages'})
ok: [default] => (item={'key': u'php_mysql_package', 'value': u'__php_mysql_package'})
ok: [default] => (item={'key': u'php_memcached_package', 'value': u'__php_memcached_package'})
ok: [default] => (item={'key': u'php_fpm_conf_path', 'value': u'__php_fpm_conf_path'})
ok: [default] => (item={'key': u'php_tideways_module_path', 'value': u'__php_tideways_module_path'})
ok: [default] => (item={'key': u'php_redis_package', 'value': u'__php_redis_package'})
...
TASK [geerlingguy.php : Ensure PHP packages are installed.] ********************
ok: [default] => (item=[u'libpcre3-dev', u'php7.1', u'php7.1-bcmath', u'php7.1-apcu', u'php7.1-cli', u'php7.1-common', u'php7.1-curl', u'php7.1-dev', u'php7.1-gd', u'php7.1-imap', u'php7.1-intl', u'php7.1-json', u'php7.1-mbstring', u'php7.1-mcrypt', u'php7.1-opcache', u'php7.1-soap', u'php7.1-xml'])
from ansible-role-php-versions.
What version of Ansible are you using?
This behaviour is valid for Ansible of 2.4.1.0. In 2.4.0.0 or lower local variable is not overridden.
from ansible-role-php-versions.
Originally this was on a 2.2 server, but I've since replicated it on 2.4.
from ansible-role-php-versions.
Just experienced the same issue on Ansible 2.4.
from ansible-role-php-versions.
Same behaviour for me on Ansible 2.4.3.0
from ansible-role-php-versions.
I... think this is the way this role is intended to be used. If you need more granularity it's probably best to not use the php-versions role at all, but rather use the php role and define versions and any other config variables manually.
This role is mostly for convenience for those who just want to get 7.1, 7.2, 5.6, etc. on an OS that comes out of the box with only one specific version of PHP, but it does a bit of variable magic to get there. It's not meant to layer on top of the variables in the base PHP role, but to override them for ease of use.
from ansible-role-php-versions.
I'm sorry to bother you @geerlingguy, but this issue is getting me confused.
If I use the php-versions role, I can set the version I want, like 7.1, but it overwrites the php_packages variables.
But if I don't use it, the php role wants to use the 7.2 version of php, which is not the one that I want to use.
How could I specify the version I want to use and use specific php_packages?
from ansible-role-php-versions.
I had this exact problem a week ago. >_<
from ansible-role-php-versions.
I'm facing the same problem now.
I created a role for my php application. This role has set the php_packages in the vars/main.yml file and uses geerlingguy.php-version + geerlingguy.php as dependents.
The variable gets overridden by the "Define PHP variables" task in the php-versions role.
After a bit of searching I maybe found a solution?
If you replace:
when:
- hostvars[inventory_hostname][item.key] is undefined
- hostvars[inventory_hostname][item.value] is defined
with
when:
- vars[item.key] is undefined
- vars[item.value] is defined
it would probably fix the problem.
It would correctly consider the variables inheritance and at the same time and fulfill its purpose since it does not check whether a variable exists at host level but whether the variable exists in the current task.
TASK [geerlingguy.php-versions : Debug php_packages] ******************************************************************************************************************************************************************************************
ok: [lion] => {
"php_packages": [
"php7.3-common",
"php7.3-cli",
"php7.3-zip",
"php7.3-curl",
"php7.3-mbstring"
]
}
TASK [geerlingguy.php-versions : Define PHP variables.] ***************************************************************************************************************************************************************************************
ok: [lion] => (item={'value': u'__php_extension_conf_paths', 'key': u'php_extension_conf_paths'})
ok: [lion] => (item={'value': u'__php_fpm_daemon', 'key': u'php_fpm_daemon'})
ok: [lion] => (item={'value': u'__php_uploadprogress_module_path', 'key': u'php_uploadprogress_module_path'})
ok: [lion] => (item={'value': u'__php_xhprof_module_path', 'key': u'php_xhprof_module_path'})
ok: [lion] => (item={'value': u'__php_fpm_pool_conf_path', 'key': u'php_fpm_pool_conf_path'})
ok: [lion] => (item={'value': u'__php_conf_paths', 'key': u'php_conf_paths'})
ok: [lion] => (item={'value': u'__php_xdebug_module_path', 'key': u'php_xdebug_module_path'})
ok: [lion] => (item={'value': u'__php_pgsql_package', 'key': u'php_pgsql_package'})
skipping: [lion] => (item={'value': u'__php_packages', 'key': u'php_packages'})
ok: [lion] => (item={'value': u'__php_mysql_package', 'key': u'php_mysql_package'})
ok: [lion] => (item={'value': u'__php_memcached_package', 'key': u'php_memcached_package'})
ok: [lion] => (item={'value': u'__php_fpm_conf_path', 'key': u'php_fpm_conf_path'})
ok: [lion] => (item={'value': u'__php_tideways_module_path', 'key': u'php_tideways_module_path'})
ok: [lion] => (item={'value': u'__php_redis_package', 'key': u'php_redis_package'})
TASK [geerlingguy.php-versions : Debug php_packages] ******************************************************************************************************************************************************************************************
ok: [lion] => {
"php_packages": [
"php7.3-common",
"php7.3-cli",
"php7.3-zip",
"php7.3-curl",
"php7.3-mbstring"
]
}
The change works as intended for my use-case, but let me know what you think about it. Maybe I missed something.
Tested on Ansible 2.7
from ansible-role-php-versions.
The point is (as stated earlier) that this role is only used for convenience, and you can use like php_packages_extra
if you want to switch versions and add other additional packages. If you need more fine-grained control than that I recommend not using this role at all, just the geerlingguy.php
role by itself, and setting up other bits and pieces to configure the exact PHP packages and versioning as you want them.
from ansible-role-php-versions.
Related Issues (20)
- Add Debian 9 on Molecule HOT 2
- Task adding the Ondrej Sury's apt key tries to download it every time HOT 5
- It would be nice for upgrades, if you could note PHP versions that no longer need to be installed HOT 2
- Php 8.0 install error caused by php-json HOT 10
- Role is not present in the Ansible Galaxy HOT 3
- ansible-lint still sees errors HOT 1
- using php_version: '7.4' installs php 8.0 HOT 4
- The goal of this role!? HOT 1
- php8.0-json is part of PHP HOT 6
- [ERROR] Could not find the requested service php7.4-fpm HOT 4
- Fails on RHEL 8 when attempting to enable the PowerTools repo HOT 6
- Question: Is it possible to install 2 or more PHP versions at the same time? HOT 2
- please add dnf module reset -y php HOT 2
- The `php_install_recommends` value is created and not honoured. HOT 3
- Ensure dnf-plugins are installed on CentOS 8+. HOT 1
- Using 7.1 as php_version installs 8.2 and some 7.1 HOT 2
- Debian 12 php8.1-yaml unavailble HOT 2
- keep php versions already installed HOT 2
- adding modules HOT 3
- Failed to update apt cache
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-php-versions.