geerlingguy / ansible-role-php-versions

Ansible Role - PHP Versions
https://galaxy.ansible.com/geerlingguy/php-versions/
MIT License
98 stars 73 forks source link

This role overrides php_packages, which is also used in geerlingguy.php #46

Closed mloveday closed 3 years ago

mloveday commented 4 years ago

Our playbook has the following config defined:

vars:
  php_packages:
    - php{{ php_version }}-intl
    - php{{ php_version }}-zip
    ...
roles:
  - geerlingguy.php-versions
  - geerlingguy.php
  ...

When we run the playbook, the php packages we were specifying were not being installed. We found that geerlingguy.php_versions was setting php_packages to that role's default value, and geerlingguy.php was then using this default over our user-specified value. We tried specifying php_packages in vars as above, in a vars file, and inline with the role itself (- { role: geerlingguy.php, vars: php_packages: ... }), but nothing changed.

The only way we could work around this was by defining the php_packages variable in a new role after php-versions had run:

vars:
  php_packages:
    - php{{ php_version }}-cli
    - php{{ php_version }}-zip
    ...
roles:
  - geerlingguy.php-versions
  - php-packages
  - geerlingguy.php
  ...

... with the php-packages role containing the following ...

set_fact: php_packages="{{ custom_php_packages }}"

Firstly, is there something I'm doing wrong in specifying the php_packages variable? If it's something I've done wrong, what should I change and why is this particular use case different to others?

Is it just a case of renaming this role's (internal only?) variable to something more unique? If so, I'm happy to provide a PR.

Thanks!

stale[bot] commented 4 years ago

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.

webarchitect609 commented 4 years ago

Today I have found this issue as affecting my playbook. I also have examined and tested the proposed solution - PR #39. It works with both - playbook vars and host vars.

@mloveday , as a temporary solution you can create host vars to avoid overwriting variables and also avoid endless waiting for PR #39 to be merged. I.e. create file ~/host_vars/hostname.yml where ~ = folder where your playbook or inventory file is; hostname = hostname, against which you use this role in your playbook. Reason: PR #4 let the tasks/main.yml file to watch for host vars only.

stale[bot] commented 4 years ago

This issue is no longer marked for closure.

webarchitect609 commented 4 years ago

@mloveday, another option is to use my fork webarchitect609.php_versions, where it has been fixed.

ymhuang0808 commented 4 years ago

@mloveday, another option is to use my fork webarchitect609.php_versions, where it has been fixed.

It works for me.

pierregaste commented 4 years ago

Same for me. Thanks for this workaround!

stale[bot] commented 4 years ago

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[bot] commented 4 years ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

webarchitect609 commented 3 years ago

@geerlingguy, I would like you to check this issue again. I believe this is a bug, formulated as: impossible to set php_packages from a playbook when using geerlingguy.php with geerlingguy.php-versions.

The fix is simple and I re-make PR #39 as a fresh PR #55 . Thank you! :)

stale[bot] commented 3 years ago

This issue is no longer marked for closure.

geerlingguy commented 3 years ago

Fixed in #55.