puppet - 要求 puppet 在开始服务之前放置一个文件

标签 puppet

我在使用 puppet 配置时遇到了问题。当我们运行 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'],
} 

这是 puppet 输出:

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

最佳答案

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

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

这会达到同样的效果。

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

关于puppet - 要求 puppet 在开始服务之前放置一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17310333/

相关文章:

puppet - 由标题数组定义的资源是否总是按顺序评估?

git - Puppet 代理无法从 Git 下载代码

java - %JAVA_HOME% 在 Windows PATH 中如何工作?

linux - 使用puppet创建动态大小的lvm

class - Puppet:命名空间如何与虚拟资源、类和定义一起工作?

rspec - 为什么我会得到 puppet-rspec 'class does not exist' ?

linux - 为puppet中的用户设置默认密码管理

dependencies - 可选类的 puppet 运行顺序

Puppet 的 Exec[] 忽略 onlyif?