saltstack-formulas / php-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
57 stars 232 forks source link

[FEATURE] Handling of Modules Across Distrobutions #224

Open B1ue-W01f opened 3 years ago

B1ue-W01f commented 3 years ago

Is your feature request related to a problem?

Adding some modules to the 'php.modules' pillar results in an incorrectly configured 'pkgs' list for Debian but works on Gentoo.

Modules such as: php7-fileinfo (fileinfo), php7-tokenizer(tokenizer), php7-ctype(ctype).

The error isn't clear and the modules pillar works on some platforms but not others.

Describe the solution you'd like

I would suggest that lookup entries could be added for the relevant packages to the map.jinja file lookup to prevent the pkgs error.

All the above missing modules are included in the php7-common package on Debian so could be simply referenced in the lookup pillar as such.

A similar approach appears to have been taken for Redhat with Curl and Json.

Describe alternatives you've considered

The simplest alternative could be to perhaps just add comment into the example pillar to check against the map.jinja lookup / check if the packages are included in the PHP install. However, this doesn't prevent a pillar that works on one distribution from failing on another distribution.

Additional context

FYI, the section of the map.jinja referenced is:

{%- if salt['grains.get']('os') == "Ubuntu" %}
    {%- set use_external_repo = salt['pillar.get']('php:use_external_repo', False) %}
    {%- if use_external_repo %}
        {%- if salt['grains.get']('osrelease')|string >= '16.04' %}
            {%- set php = salt['pillar.get']('php', {
                'lookup': salt['grains.filter_by']({
                    'Debian': {
                        'pkgs': {
                            'adodb': 'libphp-adodb',
                            'apache2': 'libapache2-mod-php' + php_version,
                            'apc': 'php-apcu',
                            'apcu': 'php-apcu-bc',
                            'bcmath': 'php' + php_version + '-bcmath',
                            'build_pkgs': [
                                'libssl-dev',
                                'libcurl4-openssl-dev',
                                'pkg-config',
                                'libsslcommon2-dev',
                                'gcc',
                                'make',
                                'autoconf',
                                'libc-dev',
                                'pkg-config',
                            ],
                            'bz2': 'php' + php_version + '-bz2',
                            'cache-lite': 'php-cache-lite',
                            'cgi': 'php' + php_version + '-cgi',
                            'cli': 'php' + php_version + '-cli',
                            'composer_bin': 'composer',
                            'console-table': 'php-console-table',
                            'curl': 'php' + php_version + '-curl',
                            'dba': 'php' + php_version + '-dba',
                            'dev': 'php' + php_version + '-dev',
                            'ext_conf_path': '/etc/php/' + php_version + '/mods-available',
                            'fpm': 'php' + php_version + '-fpm',
                            'gd': 'php' + php_version + '-gd',
                            'gearman': 'php-gearman',
                            'geoip': 'php-geoip',
                            'geshi': 'php-geshi',
                            'gettext': 'php' + php_version,
                            'gmp': 'php' + php_version + '-gmp',
                            'hhvm': 'hhvm',
                            'imagick': 'php-imagick',
                            'imap': 'php' + php_version + '-imap',
                            'intl': 'php' + php_version + '-intl',
                            'json': 'php' + php_version + '-json',
                            'ldap': 'php' + php_version + '-ldap',
                            'local_bin': '/usr/local/bin',
                            'auth-sasl': 'php-auth-sasl',
                            'mail': 'php-mail',
                            'mbstring': 'php' + php_version + '-mbstring',
                            'mcrypt': 'php' + php_version + '-mcrypt',
                            'memcache': 'php-memcache',
                            'memcached': 'php-memcached',
                            'mongo': 'php-mongo',
                            'mongodb': 'php-mongodb',
                            'mysql': 'php' + php_version + '-mysql',
                            'mysqlnd': 'php' + php_version + '-mysql',
                            'net-smtp': 'php-net-smtp',
                            'net4': 'php-net-ipv4',
                            'net6': 'php-net-ipv6',
                            'oauth': 'php-oauth',
                            'odbc': 'php-odbc',
                            'opcache': 'php' + php_version + '-opcache',
                            'pear': 'php-pear',
                            'pgsql': 'php' + php_version + '-pgsql',
                            'php': 'php' + php_version,
                            'phpenmod_command': 'phpenmod -v' + php_version,
                            'pspell': 'php' + php_version + '-pspell',
                            'readline': 'php' + php_version + '-readline',
                            'redis': 'php-redis',
                            'seclib': ['php-phpseclib', 'php-seclib'],
                            'snmp': 'php' + php_version + '-snmp',
                            'soap': 'php' + php_version + '-soap',
                            'ssh2': 'php-ssh2',
                            'sqlite': 'php' + php_version + '-sqlite3',
                            'suhosin5_ext': 'suhosin.so',
                            'suhosin5_repo': 'https://github.com/sektioneins/suhosin',
                            'suhosin7_ext': 'suhosin7.so',
                            'suhosin7_repo': 'https://github.com/sektioneins/suhosin7',
                            'sybase': 'php' + php_version + '-sybase',
                            'tcpdf': 'php-tcpdf',
                            'temp_dir': '/tmp',
                            'tidy': 'php' + php_version + '-tidy',
                            'xdebug': 'php-xdebug',
                            'xml': ['php' + php_version + '-xml', 'php' + php_version + '-xmlrpc'],
                            'xsl': 'php' + php_version + '-xsl',
                            'zip': 'php' + php_version + '-zip',
                        },

I would suggest the update could be to add the below to the list:

 'common': 'php' + php_version + '-common',
 'fileinfo': 'php' + php_version + '-common',
 'tokenizer': 'php' + php_version + '-common',
 'ctype': 'php' + php_version + '-common',