简体   繁体   English

Vagrant / Puppet - 确保:从现在改变失败:无法设置'存在确保:没有这样的文件或目录

[英]Vagrant/Puppet — ensure: change from present failed: Could not set 'present on ensure: No such file or dir

I am using Vagrant and Puppet to install Apache and PHP on Ubuntu. 我正在使用Vagrant和Puppet在Ubuntu上安装Apache和PHP。 However I am getting the error below during vagrant up . 然而,我在vagrant up期间收到以下错误。 I think the path for the templates are correct, then why the error? 我认为模板的路径是正确的,那么为什么错误呢?

I'm using the setup here modified to ensure apt-get update runs before anything else 我正在使用此处修改的设置以确保apt-get update在其他任何操作之前运行

Error 错误

←[1;35merr: /Stage[main]/Php/File[/etc/php5/apache2/apc.ini]/ensure: change from absent to present failed: Could not set 'present on ensure: No such file or dir ectory - /etc/php5/apache2/apc.ini.puppettmp_6187 at /tmp/vagrant-puppet/modules -0/php/manifests/init.pp:44←[0m

←[1;35merr: /Stage[main]/Php/File[/etc/php5/apache2/php.ini]/ensure: change from absent to present failed: Could not set 'present on ensure: No such file or dir ectory - /etc/php5/apache2/php.ini.puppettmp_6687 at /tmp/vagrant-puppet/modules -0/php/manifests/init.pp:36←[0m

/modules/php/manifests/init.pp /modules/php/manifests/init.pp

file { "/etc/php5/apache2/php.ini":
  ensure => present,
  mode => 644,
  content => template("php/etc/php5/conf.d/php.ini.erb"),
  require => Package["php5"],
  notify => Service["apache"];
}

file { "/etc/php5/apache2/apc.ini":
  ensure => present,
  mode => 644,
  content => template("php/etc/php5/conf.d/apc.ini.erb"),
  require => [ Package["php5"], Package["php-apc"], Package["apache"] ],
  notify => Service["apache"];
}

Templates 模板

  • /modules/php/templates/etc/php5/conf.d/apc.ini.erb /modules/php/templates/etc/php5/conf.d/apc.ini.erb
  • /modules/php/templates/etc/php5/conf.d/php.ini.erb /modules/php/templates/etc/php5/conf.d/php.ini.erb

Just ensure that directory /etc/php5/apache2 exists. 只需确保目录/ etc / php5 / apache2存在。

file { [ "/etc", "/etc/php5", "/etc/php5/apache2" ]:
   ensure => directory,
   before => File['/etc/php5/apache2/php.ini'],
}

or little less Puppet-ish 或者更少的Puppet-ish

exec { "ensure /etc/php5/apache2":
  command => "mkdir -p /etc/php5/apache2",
  creates => "/etc/php5/apache2"
}

All this is probably because of assumptions on the order of execution. 所有这些可能是因为对执行顺序的假设。

More info @ the puppet docs 更多信息@ puppet docs

Are you sure Package["php5"] it's creating the path for you? 你确定Package [“php5”]它正在为你创造路径吗?

It seems to me that it's complaining because /etc/php5/apache2 folder does not exist when it tries to create the files from the templates. 在我看来,它抱怨,因为/ etc / php5 / apache2文件夹在尝试从模板创建文件时不存在。

If you want to discard your puppetmaster side you can find puppetmaster process id and run: 如果你想放弃你的puppetmaster一边你可以找到puppetmaster进程ID并运行:

strace -v -f -ff -p $PID -o strace.log

Then, run the agent again and go to puppetmaster and run: 然后,再次运行代理并转到puppetmaster并运行:

grep "etc/php5/apache2" strace.log.*

If puppetmaster it's ok you will see the reading call without errors, else you will see that puppetmaster receives "no such file or directory" when trying to open the file. 如果puppetmaster没问题,你会看到没有错误的阅读电话,否则你会看到puppetmaster在尝试打开文件时收到“没有这样的文件或目录”。 Anyway as you I don't think the problem it's with template call, seems ok to me,. 无论如何,我不认为这是模板调用的问题,对我来说似乎没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM