puppet-php
puppet-php copied to clipboard
Foreman ENC : Class[Php::Globals] is already declared when using php::globals:php_version
Affected Puppet, Ruby, OS and module versions/distributions
- Puppet: 6.14.0
- Ruby: 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
- Distribution: Ubuntu 18.04
- Module version: 7.0.0
How to reproduce (e.g Puppet code you use)
Relevant part of generated yaml :
classes:
php:
manage_repos: true
php::globals:
php_version: '7.4'
What are you seeing
# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Duplicate declaration: Class[Php::Globals] is already declared; cannot redeclare on node phptest.domain.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
What behaviour did you expect instead
Installation of PHP7.4 from ondrej repository
Output log
Nothing more
Any additional information you'd like to impart
The error can be reproduced by setting any values of php::globals. My tought is that php::globals class is already declared inside the php class and adding it to foreman led to redeclaration. But without adding the class to foreman, I'm unable to set the class parameter for PHP version (or I'm missing something).
More than one year later, sorry ...
I took the whole day trying to understand why we can't play with php versions with an ENC and found that it's because php::globals class is inherited from php::params in init.
I didn't found a way to pass a parameter (php::globals::php_version) from Foreman to an inherited class, even with :
class php::globals (
Optional[Pattern[/^(rh-)?(php)?[578](\.)?[0-9]/]] $php_version = $php::php_version,
And adding a php_version parameter to init.pp.
Any idea so I could manage the php version from Foreman ?
Thanks
Hello, I have the exact same problem. In manifests/globals.pp the php_version variable gets specified through the OS version. I think that this might be the issue. Maybe an additional boolean variable to decide if the "OS detection" should be used or not, could solve this.
I have currently version 8.0.2 of the puppet module installed.
Kind regards Max