1

I'm pretty new to Puppet. So, I'm here asking for help on how the best way to fix my problem.

I'm using this puppet module to provision PHP into my Ubuntu 13.10 box. But, it seems that package php5-mcrypt is broken since, mcrypt.ini is misplaced at /etc/php5/conf.d instead of /etc/php5/apache2/available-modules/

(For the record, I'm working with Apache 2.4 and PHP 5.5)

I've made a class php-mcrypt that 'works for me'. But, I want to know if there's a better/cleaner way to do it.

Here's my workaround:

# https://github.com/lucasvscn/puppet-php-mcrypt
#
class php-mcrypt() {


  Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }

  package { "php5-mcrypt":
    ensure  => "installed",
    require => Class['php'],
  }

  file { '/etc/php5/conf.d/mcrypt.ini':
    require => Package['php5-mcrypt'],
  }

  exec {
    "copying_mcrypt":
    command => 'cp -v /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/',
    require => Package['php5-mcrypt'],
  }->

  exec {
    "enabling_mcrypt":
    command => 'php5enmod mcrypt && service apache2 reload',
    require => Package['php5-mcrypt'],
  }

}
lucasvscn
  • 113
  • 4

3 Answers3

1

The issue with the package itself was discussed in this thread (https://stackoverflow.com/questions/19446679/mcrypt-not-present-after-ubuntu-upgrade-to-13-10) and this Ubuntu bug (https://bugs.launchpad.net/ubuntu/+source/php-mcrypt/+bug/1241286).

The commonly accepted resolution is to create a symlink as opposed to copying the file. That method has the advantage of having your configuration point to a file that is still under the package management system's control.

Here is a Puppet example: http://www.puppetcookbook.com/posts/creating-a-symlink.html

Mark Sturgill
  • 889
  • 5
  • 9
0

Manage the link as a Puppet File resource type instead of the more convoluted Exec of ln. Ensure => link and specify target => param.

Yolo Perdiem
  • 606
  • 1
  • 5
  • 14
0

Enable php5-mcrypt with puppet in Ubuntu 13.10 or 14.04

case $lsbdistid {
    'Ubuntu': {

        case $lsbdistrelease {
            '13.10': {
                file { '/etc/php5/apache2/conf.d/20-mcrypt.ini':
                    ensure => link,
                    target => '/etc/php5/conf.d/mcrypt.ini',
                    notify => Service['apache2'],
                    require => [
                        Package['libapache2-mod-php5'],
                        Package['php5-mcrypt'],
                    ],
                }
                file { '/etc/php5/cli/conf.d/20-mcrypt.ini':
                    ensure => link,
                    target => '/etc/php5/conf.d/mcrypt.ini',
                    require => [
                        Package['php5-mcrypt'],
                        Package['php5-cli'],
                    ],
                }
            }

            '14.04': {
                file { '/etc/php5/apache2/conf.d/20-mcrypt.ini':
                    ensure => link,
                    target => '../../mods-available/mcrypt.ini',
                    notify => Service['apache2'],
                    require => [
                        Package['libapache2-mod-php5'],
                        Package['php5-mcrypt'],
                    ],
                }
                file { '/etc/php5/cli/conf.d/20-mcrypt.ini':
                    ensure => link,
                    target => '../../mods-available/mcrypt.ini',
                    require => [
                        Package['php5-mcrypt'],
                        Package['php5-cli'],
                    ],
                }
            }
        }
    }
}
Bob Fanger
  • 351
  • 3
  • 9