2

我的人偶配置有问题。当我们运行 puppet 时,它会在放置 www.conf 文件之前启动 php5-fpm 服务。然后我必须登录并重新启动服务,以使所有人都能按预期运行。

这是我试图对 php/manifests/init.pp 文件执行的操作:

    file { 'www.conf':
    path => '/etc/php5/fpm/pool.d/www.conf',
    ensure => file,
    owner => root,
    group => root,
    source => 'puppet:///modules/php/www.conf',
    require => Package['php5-fpm'],
}

service { 'php5-fpm':
    ensure => running,
    enable => true,
    require => File['php.ini','www.conf'],
} 

这是木偶输出:

notice: /Stage[first]/Apt_get::Update/Exec[apt-get update]/returns: executed successfully
notice: /Stage[second]/Tools/Package[python-software-properties]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[second]/Tools/Package[imagemagick]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[second]/Tools/Package[curl]/ensure: ensure changed 'purged' to 'present'
notice: /Stage[third]/Php/Exec[add_repo]/returns: executed successfully
notice: /Stage[third]/Php/Exec[update_repo]/returns: executed successfully
notice: /Stage[third]/Php/Package[php5-mysql]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/Package[php-apc]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/Package[php5-mcrypt]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/Package[php5-xdebug]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/Package[php5]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/Service[apache2]/ensure: ensure changed 'running' to 'stopped'
notice: /Stage[third]/Php/Package[php5-fpm]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/File[php.ini]/content: content changed '{md5}a199da053cb070fcd15210120e49cd20' to '{md5}9291336844ec35b4b45a84e16975a321'
notice: /Stage[third]/Php/Package[php-pear]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/Package[php-xml-parser]/ensure: ensure changed 'purged' to 'latest'  
notice: /Stage[third]/Php/Package[php5-curl]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php/File[browscap.ini]/ensure: defined content as '{md5}1393b32a89ea6af06e8e419ac4d4944d'
 notice: /Stage[third]/Php/File[www.conf]/content: content changed '{md5}7f7f6459440a5944275303d06866cec2' to '{md5}68cd4723a3549ce1a81959a0fb104ff3'
notice: /Stage[third]/Php::Pear/Exec[pear-update-channel]/returns: executed successfully
notice: /Stage[third]/Php::Pear/Exec[pear-upgrade]/returns: executed successfully
notice: /Stage[third]/Php/Package[libssh2-1-dev]/ensure: ensure changed 'purged' to 'latest'
notice: /Stage[third]/Php::Pear/Exec[pear-config-set]/returns: executed successfully
notice: /Stage[third]/Php::Pear/Exec[pear-channel-discover-pear-phpunit-de]/returns: executed successfully
notice: /Stage[third]/Php::Pear/Exec[pear-channel-discover-components-ez-no]/returns: executed successfully
notice: /Stage[third]/Php::Pear/Exec[pear-channel-discover-pear-symfony-project-com]/returns: executed successfully
notice: /Stage[third]/Php::Pear/Exec[pear-clear-cache]/returns: executed successfully
notice: /Stage[third]/Php::Pear/Exec[pear-install]/returns: executed successfully
4

3 回答 3

4

或者您可以将服务上的“要求”更改为“订阅”

service { 'php5-fpm':
    ensure => running,
    enable => true,
    subscribe => File['php.ini','www.conf'],
}

这将达到相同的效果。

订阅 == 要求 + 刷新事件。

于 2013-06-26T06:26:48.840 回答
2

我相信同时需要多个资源的方法是提供一个列表(source):

service { 'php5-fpm':
    ensure => running,
    enable => true,
    require => [ File['php.ini'], File['www.conf'] ],
}

然后,如果您还打算在任何时候php.iniwww.conf更改时重新启动 php-fpm 服务,您可以将上面的内容更改requiresubscribe

service { 'php5-fpm':
    ...
    subscribe => [ File['php.ini'], File['www.conf'] ],
}
于 2013-06-26T09:54:27.513 回答
1

所以,我想通了。必须向文件块添加通知,以便它知道在文件更改时重新启动服务。

file { 'www.conf':
    notify  => Service['php5-fpm'],
    path => '/etc/php5/fpm/pool.d/www.conf',
    ensure => file,
    owner => root,
    group => root,
    source => 'puppet:///modules/php/www.conf',
    require => Package['php5-fpm'],
}
于 2013-06-26T03:09:06.050 回答