php5enmod mcrypt with Puppet

Another Puppet related question.

As part of my installation with Puppet, I'm installing: -

  • Ubuntu 14.04.2 LTS
  • PHP5-FPM
  • Nginx
  • MySQL etc

As part of the PHP class I have the following: -

package {[
        'php5-fpm',
        'php5-mysql',
        'php5-cli',
        'php5-mcrypt',
        'php5-curl',
    ]:
    ensure => present,
    require => Exec['apt-get update'],
}

This part works fine. No issues.

Once the server has finished doing its thing, I'm able to run: -

php5enmod mcrypt

This, again, runs without issue and mcrypt is enabled in the php5-fpm installation. The problem is arising with the following code block.

exec { 'enable-mcrypt':
    command => 'php5enmod mcrypt',
    path => '/usr/sbin',
    require => [
        Package['php5-mcrypt'],
        Package['php5-fpm']
    ],
    notify => [
        Service['php5-fpm'],
        Service['nginx'],
    ],
}

I've tried running it in various incarnations, and there are no issues regarding syntax or dependencies for it to execute.

However, when I look through the debug information I'm seeing this: -

Debug: Exec[enable-mcrypt](provider=posix): Executing 'php5enmod pdo'
Debug: Executing 'php5enmod pdo'
Notice: /Stage[main]/Php/Exec[enable-mcrypt]/returns: /usr/sbin/php5enmod: 233: /usr/sbin/php5enmod: expr: not found
Notice: /Stage[main]/Php/Exec[enable-mcrypt]/returns: /usr/sbin/php5query: 181: /usr/sbin/php5query: expr: not found
Notice: /Stage[main]/Php/Exec[enable-mcrypt]/returns: /usr/sbin/php5query: 203: /usr/sbin/php5query: find: not found
Notice: /Stage[main]/Php/Exec[enable-mcrypt]/returns: WARNING:
Notice: /Stage[main]/Php/Exec[enable-mcrypt]/returns: usage: php5enmod [ -s ALL|sapi_name ] module_name [ module_name_2 ]
Error: php5enmod pdo returned 1 instead of one of [0]
Error: /Stage[main]/Php/Exec[enable-mcrypt]/returns: change from notrun to 0 failed: php5enmod pdo returned 1 instead of one of [0]

I cannot make heads nor tails of it. It would almost appear that php5enmod is not seeing the argument that's being passed to it, hence the WARNING: usage php5enmod [ -s ALL|sapi_name ] etc...

I say this because if I run phpenmod without any arguments, that's the same error you get.

If anybody has any ideas, I'd be outrageously thankful.

dtj4307
dtj4307 kubuntuforums.net/showthread.php?60122-find-not-found
5 年多之前 回复

2个回答



看来这样做的正确方法(正如引用@Bob的评论)是为了确保Puppet知道“find”命令的位置 在尝试执行php5enmod之前。 </ p>

我的木偶配置如下:</ p>

 #确保Mcrypt已启用
exec {“enablemcrypt”:
path =&gt; [“/ bin /”,“/ sbin /”,“/ usr / bin /”,“/ usr / sbin /”],
command =&gt; “php5enmod mcrypt”,
notify =&gt; 服务[“apache2”],
require =&gt; 包[“php5-common”],
}
</ code> </ pre>

如您所见,添加“/ bin”,“/ sbin”,“/ usr / bin“和”/ usr / sbin“到path参数,puppet现在可以使用”find“命令,它在执行带参数的命令时似乎在内部使用。 php5enmod现在可以在Ubuntu 14.04 LTS上正确运行。</ p>
</ div>

展开原文

原文

It appears the correct way to do this (As referenced @BMW's comment) is to ensure that Puppet knows where the "find" command is before attempting to execute php5enmod.

My puppet configuration is below:

# Ensure Mcrypt is enabled
exec { "enablemcrypt":
  path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ],
  command => "php5enmod mcrypt",
  notify => Service["apache2"],
  require => Package["php5-common"],
}

As you can see, by adding "/bin", "/sbin", "/usr/bin" and "/usr/sbin" to the path parameter, puppet can now use the "find" command, which it seems to use internally when executing commands with arguments. php5enmod now runs correctly for me on Ubuntu 14.04 LTS.

douxiong1994
douxiong1994 我同意,但是在path参数中你只需要find的路径和php5enmod的路径。 或者我认为你可以只有安装了find的目录,并用它的完整路径调用php5enmod(例如:/ usr / sbin / php5enmod)
5 年多之前 回复
dongtou2097
dongtou2097 好的,这是有道理的。 它似乎有点冗长,但逻辑是合理的。
5 年多之前 回复



不幸的是,我无法像我希望的那样使用它。 我不确定Puppet是不是与php5enmod打得不好,或者php5enmod是否存在内部问题以及Puppet脚本调用它的方式。</ p>

但是,我确实设法 手动创建符号链接并使用以下代码块重新启动服务。</ p>

  file {'/ etc / php5 /fpm / conf.d / -20-miltpt.ini'  :
ensure =&gt; 'link',
target =&gt; '/etc/php5/mods-available/mcrypt.ini',
require =&gt; [
Package ['php5-mcrypt'],
Package ['php5-fpm'],
],
notify =&gt; 服务['php5-fpm'],
}
</ code> </ pre>

希望将来可以帮助某人。</ p>
</ div>

展开原文

原文

Unfortunately, I wasn't able to get this to work as I would have liked. I'm unsure if Puppet is just not playing nicely with php5enmod, or whether there's some internal issues with php5enmod and the way it's being called by the Puppet scripts.

However, I did manage to manually create the symbolic link and restart the service with the following block of code.

file { '/etc/php5/fpm/conf.d/20-mcrypt.ini':
    ensure => 'link',
    target => '/etc/php5/mods-available/mcrypt.ini',
    require => [
        Package['php5-mcrypt'],
        Package['php5-fpm'],
    ],
    notify => Service['php5-fpm'],
}

Hopefully this helps somebody out in the future.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐