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

Do not manage mysql.ini when using Ubuntu repo #330

Closed
wants to merge 1 commit into from

Conversation

tdm4
Copy link
Contributor

@tdm4 tdm4 commented Mar 16, 2017

When using the Ubuntu PPA repo, the php::extension::config tries to manage mysql.ini even though it does not exist in PHP 7.0 or 7.1. This results in a PHP warning about mysql.so not existing. This diff disables and removes the mysql.ini file if using PHP 7.0 or 7.1.

@jackdpeterson
Copy link

As a workaround, one can utilize stages if on a new version of puppet to execute this outside of the scope of the module until this PR gets merged in (bump).

@jackdpeterson
Copy link

jackdpeterson commented Jun 5, 2017

  before => Stage['main']
}
stage { 'last':
}
Stage['main'] -> Stage['last']```
### PHP Module workarounds ###


class last_stuff () {
  file { '/usr/lib/php/20160303/pdo-mysql.so':
    ensure => 'link',
    target => '/usr/lib/php/20160303/pdo_mysql.so',
    owner  => 'root',
    group  => 'root',
    mode   => '0755'
  }
  exec { 'Remove_php_mysql_ini':
    command => "phpdismod mysql; rm -f /etc/php/${php::globals::php_version}/mods-available/mysql.ini",
    onlyif  => "test -f /etc/php/${php::globals::php_version}/mods-available/mysql.ini",
    path    => '/bin/:/sbin/:/usr/bin/:/usr/sbin/',
  }

  exec { 'Remove_php_pdo_mysql_ini':
    command => "rm -f /etc/php/${php::globals::php_version}/mods-available/pdo_mysql.ini",
    onlyif  => "test -f /etc/php/${php::globals::php_version}/mods-available/pdo_mysql.ini",
    path    => '/bin/:/sbin/:/usr/bin/:/usr/sbin/',
  }
}

class { 'last_stuff':
  stage => last
}



### End of PHP Module Workarounds ###

is what that potential workaround looks like

@BenConstable
Copy link

BenConstable commented Aug 2, 2017

Another temporary workaround, which may be a bit simpler, is to override the extension ini setting when defining the MySQL extension dependency. For example:

class { '::php':
  extensions => {
    mysql => {
      settings => {
        extension => undef,
      },
    },
  },
}

Using this method, the mysql.ini file will still be created (which isn't perfect), but the extension=mysql.so entry will be removed.

@Yggdrasil
Copy link

Yggdrasil commented Nov 30, 2017

@BenConstable That was a clever idea, but in my case it simply puts extenstion=undef in the mysql.ini file, which of course leads to the error:
Unable to load dynamic library '/usr/lib/php/20160303/undef'

To be fair I set the config via Hiera, so perhaps that makes a difference in my case. It appears Hiera treats the undef as a string.

php::extensions:
  mysql: { 'settings': { 'extension': undef } }

Any idea how to apply this workaround correctly via Hiera?

@Yggdrasil
Copy link

@BenConstable I managed to answer my own question. The correct setting in Hiera is:

php::extensions:
  mysql: { 'settings': { 'extension': } }

This indeed causes the mysql.ini file to be empty and prevents the warning. Thanks again for this relatively clean workaround.

@jonhattan
Copy link
Contributor

In yaml you can use null to mean undef

@bastelfreak
Copy link
Member

@tdm4 thanks for this PR. Are you able to rebase? I also added a few inline comments.

@@ -67,46 +67,61 @@
$module_path = undef
}

$ini_name = downcase($so_name)
if $::operatingsystem == 'Ubuntu' and $zend != true and $name == 'mysql' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the new $facts hash instead of topscope facts

# If mysql.ini exists and version is 7.0 or 7.1, then remove it
if $php::globals::php_version == '7.0' or $php::globals::php_version == '7.1' {
exec { 'Remove_php_mysql_ini':
command => "phpdismod mysql; rm -f /etc/php/${php::globals::php_version}/mods-available/mysql.ini",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't think that an exec() doing rm is the correct approach here. A file resource with ensure => absent is probably the way to go.

@bastelfreak
Copy link
Member

Thanks for opening this issue. It hasn't seen activity in a while, so I'm going to close the issue. This doesn't mean that we don't think this issue is valid, we're just trying to assess what issues are still relevant. If you still need this(even if you're not willing to work on it yourself) please feel free to reopen it. Again thanks for opening the issue, users who report bugs and ask for features are some of the most important players in the open source community. Feel free to hop by #voxpupuli on irc.freenode.net if you'd like to chat with us about any of this.

@bastelfreak bastelfreak closed this Feb 9, 2019
@jonhattan
Copy link
Contributor

@bastelfreak Only project managers can reopen PRs/issues.

This PR is still relevant.

@bastelfreak bastelfreak reopened this Feb 19, 2019
@bastelfreak
Copy link
Member

@jonhattan are you interested in rebasing this and adressing the inline comments I made in the last review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants